mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-24 18:36:25 +00:00
Remove tools
This commit is contained in:
parent
431ea91e9d
commit
fc43844ac6
|
@ -2,7 +2,7 @@
|
|||
|
||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||
|
||||
SUBDIRS = libgitg libgitg-gtk gitg data po tests tools
|
||||
SUBDIRS = libgitg libgitg-gtk gitg data po tests
|
||||
|
||||
DISTCLEANFILES = \
|
||||
intltool-extract \
|
||||
|
|
|
@ -260,7 +260,6 @@ data/icons/Makefile
|
|||
data/org.gnome.gitg.gschema.xml.in
|
||||
po/Makefile.in
|
||||
tests/Makefile
|
||||
tools/Makefile
|
||||
plugins/Makefile
|
||||
plugins/dash/Makefile
|
||||
plugins/history/Makefile
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
INCLUDES = -g -I$(top_srcdir) -I$(top_srcdir)/gitg -I$(top_srcdir)/libgitg $(GITG_DEBUG_FLAGS) $(GITG_CFLAGS)
|
||||
|
||||
noinst_PROGRAMS = $(TOOLS_PROGS)
|
||||
tools_ldadd = $(top_builddir)/libgitg/libgitg-1.0.la $(PACKAGE_LIBS) $(GITG_LIBS)
|
||||
|
||||
TOOLS_PROGS = gitg-shell gitg-config
|
||||
|
||||
gitg_shell_SOURCES = gitg-shell.c
|
||||
gitg_shell_LDADD = $(tools_ldadd)
|
||||
|
||||
gitg_config_SOURCES = gitg-config.c
|
||||
gitg_config_LDADD = $(tools_ldadd)
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
|
@ -1,159 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgitg/gitg-config.h>
|
||||
#include <libgitg/gitg-debug.h>
|
||||
|
||||
static gchar *repository_path = NULL;
|
||||
static gboolean global = FALSE;
|
||||
static gboolean regex = FALSE;
|
||||
|
||||
static GOptionEntry entries[] =
|
||||
{
|
||||
{ "repository", 'r', 0, G_OPTION_ARG_FILENAME, &repository_path, "Repository path" },
|
||||
{ "global", 'g', 0, G_OPTION_ARG_NONE, &global, "Use the global configuration" },
|
||||
{ "regex", 'r', 0, G_OPTION_ARG_NONE, ®ex, "Config name is a regular expression" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static GFile *
|
||||
find_git_dir (GFile *work_tree)
|
||||
{
|
||||
GFile *ret;
|
||||
|
||||
work_tree = g_file_dup (work_tree);
|
||||
|
||||
while (work_tree)
|
||||
{
|
||||
ret = g_file_get_child (work_tree, ".git");
|
||||
|
||||
if (g_file_query_exists (ret, NULL))
|
||||
{
|
||||
g_object_unref (work_tree);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *tmp;
|
||||
|
||||
tmp = g_file_get_parent (work_tree);
|
||||
g_object_unref (work_tree);
|
||||
|
||||
work_tree = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_options (int *argc,
|
||||
char ***argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
|
||||
context = g_option_context_new ("- git config tool");
|
||||
|
||||
g_option_context_set_ignore_unknown_options (context, TRUE);
|
||||
g_option_context_add_main_entries (context, entries, "gitg");
|
||||
|
||||
if (!g_option_context_parse (context, argc, argv, &error))
|
||||
{
|
||||
g_print ("option parsing failed: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
g_option_context_free (context);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GitgRepository *repository = NULL;
|
||||
GMainLoop *loop;
|
||||
GError *error = NULL;
|
||||
GitgConfig *config;
|
||||
gint i;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
parse_options (&argc, &argv);
|
||||
|
||||
gitg_debug_init ();
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
g_print ("Please specify a config name...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!global)
|
||||
{
|
||||
GFile *work_tree;
|
||||
GFile *git_dir;
|
||||
|
||||
if (!repository_path)
|
||||
{
|
||||
gchar *path;
|
||||
GFile *file;
|
||||
|
||||
path = g_get_current_dir ();
|
||||
file = g_file_new_for_path (path);
|
||||
|
||||
git_dir = find_git_dir (file);
|
||||
g_free (path);
|
||||
g_object_unref (file);
|
||||
|
||||
if (git_dir)
|
||||
{
|
||||
work_tree = g_file_get_parent (git_dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
work_tree = g_file_new_for_commandline_arg (repository_path);
|
||||
git_dir = find_git_dir (work_tree);
|
||||
}
|
||||
|
||||
if (!git_dir)
|
||||
{
|
||||
g_print ("Could not find git dir...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
repository = gitg_repository_new (git_dir, work_tree);
|
||||
|
||||
g_object_unref (work_tree);
|
||||
g_object_unref (git_dir);
|
||||
}
|
||||
|
||||
config = gitg_config_new (repository);
|
||||
|
||||
/* Create commands */
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
gchar *ret;
|
||||
|
||||
if (regex)
|
||||
{
|
||||
ret = gitg_config_get_value_regex (config, argv[i], NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = gitg_config_get_value (config, argv[i]);
|
||||
}
|
||||
|
||||
g_print ("%s = %s\n", argv[i], ret);
|
||||
}
|
||||
|
||||
if (repository)
|
||||
{
|
||||
g_object_unref (repository);
|
||||
}
|
||||
|
||||
g_object_unref (config);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgitg/gitg-shell.h>
|
||||
#include <gio/gunixinputstream.h>
|
||||
#include <gio/gunixoutputstream.h>
|
||||
#include <libgitg/gitg-debug.h>
|
||||
|
||||
static gchar *repository_path = NULL;
|
||||
|
||||
static GOptionEntry entries[] =
|
||||
{
|
||||
{ "repository", 'r', 0, G_OPTION_ARG_FILENAME, &repository_path, "Repository path" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static GFile *
|
||||
find_git_dir (GFile *work_tree)
|
||||
{
|
||||
GFile *ret;
|
||||
|
||||
work_tree = g_file_dup (work_tree);
|
||||
|
||||
while (work_tree)
|
||||
{
|
||||
ret = g_file_get_child (work_tree, ".git");
|
||||
|
||||
if (g_file_query_exists (ret, NULL))
|
||||
{
|
||||
g_object_unref (work_tree);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *tmp;
|
||||
|
||||
tmp = g_file_get_parent (work_tree);
|
||||
g_object_unref (work_tree);
|
||||
|
||||
work_tree = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_options (int *argc,
|
||||
char ***argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GOptionContext *context;
|
||||
|
||||
context = g_option_context_new ("- git shell tool");
|
||||
|
||||
g_option_context_set_ignore_unknown_options (context, TRUE);
|
||||
g_option_context_add_main_entries (context, entries, "gitg");
|
||||
|
||||
if (!g_option_context_parse (context, argc, argv, &error))
|
||||
{
|
||||
g_print ("option parsing failed: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
g_option_context_free (context);
|
||||
}
|
||||
|
||||
static void
|
||||
on_shell_end (GitgShell *shell,
|
||||
GError *error,
|
||||
GMainLoop *loop)
|
||||
{
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GitgRepository *repository;
|
||||
GFile *work_tree;
|
||||
GFile *git_dir;
|
||||
gint i;
|
||||
GString *cmdstr;
|
||||
gchar *cs;
|
||||
GitgCommand **commands;
|
||||
GitgShell *shell;
|
||||
GMainLoop *loop;
|
||||
GError *error = NULL;
|
||||
GInputStream *input;
|
||||
GOutputStream *output;
|
||||
|
||||
g_type_init ();
|
||||
|
||||
parse_options (&argc, &argv);
|
||||
|
||||
gitg_debug_init ();
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
g_print ("Please specify a command...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!repository_path)
|
||||
{
|
||||
gchar *path;
|
||||
GFile *file;
|
||||
|
||||
path = g_get_current_dir ();
|
||||
file = g_file_new_for_path (path);
|
||||
|
||||
git_dir = find_git_dir (file);
|
||||
g_free (path);
|
||||
g_object_unref (file);
|
||||
|
||||
if (git_dir)
|
||||
{
|
||||
work_tree = g_file_get_parent (git_dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
work_tree = g_file_new_for_commandline_arg (repository_path);
|
||||
git_dir = find_git_dir (work_tree);
|
||||
}
|
||||
|
||||
if (!git_dir)
|
||||
{
|
||||
g_print ("Could not find git dir...\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
repository = gitg_repository_new (git_dir, work_tree);
|
||||
|
||||
g_object_unref (work_tree);
|
||||
g_object_unref (git_dir);
|
||||
|
||||
cmdstr = g_string_new ("");
|
||||
|
||||
/* Create commands */
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
gchar *quoted;
|
||||
|
||||
if (strcmp (argv[i], "!") == 0)
|
||||
{
|
||||
quoted = g_strdup ("|");
|
||||
}
|
||||
else
|
||||
{
|
||||
quoted = g_shell_quote (argv[i]);
|
||||
}
|
||||
|
||||
if (i != 1)
|
||||
{
|
||||
g_string_append_c (cmdstr, ' ');
|
||||
}
|
||||
|
||||
g_string_append (cmdstr, quoted);
|
||||
}
|
||||
|
||||
cs = g_string_free (cmdstr, FALSE);
|
||||
g_print ("Running: %s\n\n", cs);
|
||||
|
||||
commands = gitg_shell_parse_commands (repository, cs, &error);
|
||||
|
||||
g_free (cs);
|
||||
g_object_unref (repository);
|
||||
|
||||
if (error)
|
||||
{
|
||||
g_print ("Could not parse arguments: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
shell = gitg_shell_new (1000);
|
||||
|
||||
input = g_unix_input_stream_new (STDIN_FILENO, TRUE);
|
||||
output = g_unix_output_stream_new (STDOUT_FILENO, TRUE);
|
||||
|
||||
gitg_io_set_input (GITG_IO (shell), input);
|
||||
gitg_io_set_output (GITG_IO (shell), output);
|
||||
|
||||
g_signal_connect (shell,
|
||||
"end",
|
||||
G_CALLBACK (on_shell_end),
|
||||
loop);
|
||||
|
||||
if (!gitg_shell_run_list (shell, commands, &error))
|
||||
{
|
||||
g_print ("Error launching shell: %s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_free (commands);
|
||||
|
||||
g_main_loop_run (loop);
|
||||
g_main_loop_unref (loop);
|
||||
g_object_unref (shell);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue