Beispiel #1
0
static void
git_log_command_finalize (GObject *object)
{
	GitLogCommand *self;
	GList *current_output;
	
	self = GIT_LOG_COMMAND (object);
	current_output = self->priv->output_queue->head;
	
	while (current_output)
	{
		g_object_unref (current_output->data);
		current_output = g_list_next (current_output);
	}
	
	g_queue_free (self->priv->output_queue);
	g_hash_table_destroy (self->priv->revisions);
	g_regex_unref (self->priv->commit_regex);
	g_regex_unref (self->priv->parent_regex);
	g_regex_unref (self->priv->author_regex);
	g_regex_unref (self->priv->time_regex);
	g_regex_unref (self->priv->short_log_regex);
	g_free (self->priv->branch);
	g_free (self->priv->path);
	
	g_free (self->priv->author);
	g_free (self->priv->grep);
	g_free (self->priv->since_date);
	g_free (self->priv->until_date);
	g_free (self->priv->since_commit);
	g_free (self->priv->until_commit);
	g_free (self->priv);

	G_OBJECT_CLASS (git_log_command_parent_class)->finalize (object);
}
Beispiel #2
0
static void
git_log_command_handle_output (GitCommand *git_command, const gchar *output)
{
	GitLogCommand *self;
	
	self = GIT_LOG_COMMAND (git_command);

	git_log_data_command_push_line (self->priv->data_command, output);
}
Beispiel #3
0
static void
on_log_command_finished (AnjutaCommand *command, guint return_code, 
						 GitLogPane *self)
{
	GtkTreeView *log_view;
	GQueue *queue;
	GtkTreeIter iter;
	GitRevision *revision;

	/* Show the actual log view */
	git_log_pane_set_view_mode (self, LOG_VIEW_NORMAL);

	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder, 
	                                                  "log_view"));
	
	if (return_code != 0)
	{
		/* Don't report erros in the log view as this is usually no user requested
		 * operation and thus error messages are confusing instead just show an
		 * empty log.
		 */
#if 0
		git_pane_report_errors (command, return_code,
		                        ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self))));
#endif
		goto out;
	}
	
	queue = git_log_command_get_output_queue (GIT_LOG_COMMAND (command));
	
	while (g_queue_peek_head (queue))
	{
		revision = g_queue_pop_head (queue);
		
		gtk_list_store_append (self->priv->log_model, &iter);
		gtk_list_store_set (self->priv->log_model, &iter, LOG_COL_REVISION, 
		                    revision, -1);

		g_object_unref (revision);
	}
	
	giggle_graph_renderer_validate_model (GIGGLE_GRAPH_RENDERER (self->priv->graph_renderer),
										  GTK_TREE_MODEL (self->priv->log_model),
										  0);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), 
							 GTK_TREE_MODEL (self->priv->log_model));

out:
	g_clear_object (&self->priv->log_command);
}
Beispiel #4
0
static void
on_log_command_finished (AnjutaCommand *command, guint return_code, 
						 GitLogPane *self)
{
	GtkTreeView *log_view;
	GQueue *queue;
	GtkTreeIter iter;
	GitRevision *revision;

	/* Show the actual log view */
	git_log_pane_set_view_mode (self, LOG_VIEW_NORMAL);
	
	if (return_code != 0)
	{
		git_pane_report_errors (command, return_code,
		                        ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self))));
		g_object_unref (command);
		
		return;
	}
	
	log_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder, 
	                                                  "log_view"));
	
	g_object_ref (self->priv->log_model);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), NULL);
	
	queue = git_log_command_get_output_queue (GIT_LOG_COMMAND (command));
	
	while (g_queue_peek_head (queue))
	{
		revision = g_queue_pop_head (queue);
		
		gtk_list_store_append (self->priv->log_model, &iter);
		gtk_list_store_set (self->priv->log_model, &iter, LOG_COL_REVISION, 
		                    revision, -1);

		g_object_unref (revision);
	}
	
	giggle_graph_renderer_validate_model (GIGGLE_GRAPH_RENDERER (self->priv->graph_renderer),
										  GTK_TREE_MODEL (self->priv->log_model),
										  0);
	gtk_tree_view_set_model (GTK_TREE_VIEW (log_view), 
							 GTK_TREE_MODEL (self->priv->log_model));
	g_object_unref (self->priv->log_model);
	
	g_object_unref (command);
}
Beispiel #5
0
static void
git_log_command_notify_complete (AnjutaCommand *command, guint return_code)
{
	GitLogCommand *self;

	self = GIT_LOG_COMMAND (command);

	/* Send an empty string to the data processing command so that it knows
	 * to stop when it's done processing data. The command will finish when 
	 * the processing thread finishes, and not when git stops executing */
	git_log_data_command_push_line (self->priv->data_command, "");

	/* Use the git return code */
	self->priv->return_code = return_code;
}
Beispiel #6
0
static void
git_log_command_finalize (GObject *object)
{
	GitLogCommand *self;
	
	self = GIT_LOG_COMMAND (object);
	
	g_object_unref (self->priv->data_command);
	g_free (self->priv->author);
	g_free (self->priv->grep);
	g_free (self->priv->since_date);
	g_free (self->priv->until_date);
	g_free (self->priv->since_commit);
	g_free (self->priv->until_commit);
	g_free (self->priv);

	G_OBJECT_CLASS (git_log_command_parent_class)->finalize (object);
}
Beispiel #7
0
static void
git_log_command_handle_output (GitCommand *git_command, const gchar *output)
{
	GitLogCommand *self;
	GMatchInfo *commit_match_info;
	GMatchInfo *parent_match_info;
	GMatchInfo *author_match_info;
	GMatchInfo *time_match_info;
	GMatchInfo *short_log_match_info;
	gchar *commit_sha;
	gchar *parents;
	gchar **parent_shas;
	gint i;
	GitRevision *parent_revision;
	gchar *author;
	gchar *time;
	gchar *short_log;
	
	self = GIT_LOG_COMMAND (git_command);

	commit_match_info = NULL;
	parent_match_info = NULL;
	author_match_info = NULL;
	time_match_info = NULL;
	short_log_match_info = NULL;
	
	/* Entries are delimited by the hex value 0x0c */
	if (*output == 0x0c && self->priv->current_revision)
	{	
		g_queue_push_tail (self->priv->output_queue, 
						   self->priv->current_revision);
		anjuta_command_notify_data_arrived (ANJUTA_COMMAND (git_command));
	}
	
	if (g_regex_match (self->priv->commit_regex, output, 0, &commit_match_info))
	{
		commit_sha = g_match_info_fetch (commit_match_info, 1);
		
		self->priv->current_revision = g_hash_table_lookup (self->priv->revisions, 
															commit_sha);
		
		if (!self->priv->current_revision)
		{
			self->priv->current_revision = git_revision_new ();
			git_revision_set_sha (self->priv->current_revision, commit_sha);
			g_hash_table_insert (self->priv->revisions, g_strdup (commit_sha),
								 g_object_ref (self->priv->current_revision));
		}
		
		g_free (commit_sha);
	}
	else if (g_regex_match (self->priv->parent_regex, output, 0, 
							&parent_match_info))
	{	
		parents = g_match_info_fetch (parent_match_info, 1);
		parent_shas = g_strsplit (parents, " ", -1);
		
		for (i = 0; parent_shas[i]; i++)
		{
			parent_revision = g_hash_table_lookup (self->priv->revisions,
												   parent_shas[i]);
			
			if (!parent_revision)
			{
				parent_revision = git_revision_new ();
				git_revision_set_sha (parent_revision, parent_shas[i]);
				g_hash_table_insert (self->priv->revisions,
									 g_strdup (parent_shas[i]),
									 g_object_ref (parent_revision));
			}
			
			git_revision_add_child (parent_revision,
									self->priv->current_revision);
		}
		
		g_free (parents);
		g_strfreev (parent_shas);
	}
	else if (g_regex_match (self->priv->author_regex, output, 0, 
			 &author_match_info))
	{
		author = g_match_info_fetch (author_match_info, 1);
		git_revision_set_author (self->priv->current_revision, author);
		
		g_free (author);
	}
	else if (g_regex_match (self->priv->time_regex, output, 0, 
			 &time_match_info))
	{
		time = g_match_info_fetch (time_match_info, 1);
		git_revision_set_date (self->priv->current_revision, atol (time));
		
		g_free (time);
	}
	else if (g_regex_match (self->priv->short_log_regex, output, 0, 
							&short_log_match_info))
	{
		short_log = g_match_info_fetch (short_log_match_info, 1);
		git_revision_set_short_log (self->priv->current_revision, short_log);
		
		g_free (short_log);
	}
	
	if (commit_match_info)
		g_match_info_free (commit_match_info);

	if (parent_match_info)
		g_match_info_free (parent_match_info);

	if (author_match_info)
		g_match_info_free (author_match_info);

	if (time_match_info)
		g_match_info_free (time_match_info);

	if (short_log_match_info)
		g_match_info_free (short_log_match_info);
}
Beispiel #8
0
static guint
git_log_command_run (AnjutaCommand *command)
{
	GitLogCommand *self;
	gchar *filter_arg;
	GString *commit_range;
	
	self = GIT_LOG_COMMAND (command);
	
	git_command_add_arg (GIT_COMMAND (command), "rev-list");
	git_command_add_arg (GIT_COMMAND (command), "--topo-order");
	git_command_add_arg (GIT_COMMAND (command), "--pretty=format:parents %P%n"
												"author %an%n"
												"time %at%n"
												"short log %s%n"
												"\x0c");
	
	if (self->priv->author)
	{
		filter_arg = g_strdup_printf ("--author=%s", self->priv->author);
		git_command_add_arg (GIT_COMMAND (command), filter_arg);
		g_free (filter_arg);
	}
	
	if (self->priv->grep)
	{
		filter_arg = g_strdup_printf ("--grep=%s", self->priv->grep);
		git_command_add_arg (GIT_COMMAND (command), filter_arg);
		g_free (filter_arg);
	}
	
	if (self->priv->since_date)
	{
		filter_arg = g_strdup_printf ("--since=%s", self->priv->since_date);
		git_command_add_arg (GIT_COMMAND (command), filter_arg);
		g_free (filter_arg);
	}
	
	if (self->priv->until_date)
	{
		filter_arg = g_strdup_printf ("--until=%s", self->priv->until_date);
		git_command_add_arg (GIT_COMMAND (command), filter_arg);
		g_free (filter_arg);
	}
	
	if (self->priv->since_commit || self->priv->until_commit)
	{
		commit_range = g_string_new ("");
		
		/* Not the most elegant way of doing it... */
		if (self->priv->since_commit)
			g_string_append (commit_range, self->priv->since_commit);
		
		g_string_append (commit_range, "..");
		
		if (self->priv->until_commit)
			g_string_append (commit_range, self->priv->until_commit);
		
		git_command_add_arg (GIT_COMMAND (command), commit_range->str);
		
		g_string_free (commit_range, TRUE);
	}

	if (self->priv->branch)
		git_command_add_arg (GIT_COMMAND (command), self->priv->branch);
	else
		git_command_add_arg (GIT_COMMAND (command), "HEAD");
	
	if (self->priv->path)
	{
		git_command_add_arg (GIT_COMMAND (command), "--");
		git_command_add_arg (GIT_COMMAND (command), self->priv->path);
	}
	
	return 0;
}