示例#1
0
static void
git_ref_command_finalize (GObject *object)
{
	GitRefCommand *self;
	
	self = GIT_REF_COMMAND (object);
	
	g_regex_unref (self->priv->branch_ref_regex);
	g_regex_unref (self->priv->tag_ref_regex);
	g_regex_unref (self->priv->remote_ref_regex);
	g_hash_table_unref (self->priv->refs);
	
	g_free (self->priv);

	G_OBJECT_CLASS (git_ref_command_parent_class)->finalize (object);
}
示例#2
0
static void
on_ref_command_finished (AnjutaCommand *command, guint return_code,
                         GitLogPane *self)
{
	Git *plugin;

	plugin = ANJUTA_PLUGIN_GIT (anjuta_dock_pane_get_plugin (ANJUTA_DOCK_PANE (self)));

	if (self->priv->refs)
		g_hash_table_unref (self->priv->refs);

	self->priv->refs = git_ref_command_get_refs (GIT_REF_COMMAND (command));

	/* Unref the previous command if it's still running. */
	if (self->priv->branch_list_command)
		g_object_unref (self->priv->branch_list_command);
	
	/* Refresh the branch display after the refs get updated */
	self->priv->branch_list_command =
		git_branch_list_command_new (plugin->project_root_directory,
		                             GIT_BRANCH_TYPE_ALL);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "command-started",
	                         G_CALLBACK (on_branch_list_command_started),
	                         self, 0);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "command-finished",
	                         G_CALLBACK (on_branch_list_command_finished),
	                         self, 0);

	g_signal_connect_object (G_OBJECT (self->priv->branch_list_command), "data-arrived",
	                         G_CALLBACK (on_branch_list_command_data_arrived),
	                         self, 0);

	anjuta_command_start (ANJUTA_COMMAND (self->priv->branch_list_command));
}
示例#3
0
static void
git_ref_command_handle_output (GitCommand *git_command, const gchar *output)
{
	GitRefCommand *self;
	GMatchInfo *branch_match_info;
	GMatchInfo *tag_match_info;
	GMatchInfo *remote_match_info;
	gchar *sha;
	gchar *name;
	GitRef *ref;
	
	self = GIT_REF_COMMAND (git_command);

	branch_match_info = NULL;
	tag_match_info = NULL;
	remote_match_info = NULL;
	
	if (g_regex_match (self->priv->branch_ref_regex, output, 0, 
					   &branch_match_info))
	{
		sha = g_match_info_fetch (branch_match_info, 1);
		name = g_match_info_fetch (branch_match_info, 2);
		ref = git_ref_new (name, GIT_REF_TYPE_BRANCH);
		
		git_ref_command_insert_ref (self, sha, ref);
		
		g_free (sha);
		g_free (name);
	}
	else if (g_regex_match (self->priv->tag_ref_regex, output, 0, 
							&tag_match_info))
	{
		sha = g_match_info_fetch (tag_match_info, 1);
		name = g_match_info_fetch (tag_match_info, 2);
		
		if (g_str_has_suffix (name, "^{}"))
			(g_strrstr (name, "^{}")) [0] = '\0';
		
		ref = git_ref_new (name, GIT_REF_TYPE_TAG);
		
		
		git_ref_command_insert_ref (self, sha, ref);
		
		g_free (sha);
		g_free (name);
	}
	else if (g_regex_match (self->priv->remote_ref_regex, output, 0, 
							&remote_match_info))
	{
		sha = g_match_info_fetch (remote_match_info, 1);
		name = g_match_info_fetch (remote_match_info, 2);
		ref = git_ref_new (name, GIT_REF_TYPE_REMOTE);
		
		git_ref_command_insert_ref (self, sha, ref);
		
		g_free (sha);
		g_free (name);
	}
	
	if (branch_match_info)
		g_match_info_free (branch_match_info);

	if (tag_match_info)
		g_match_info_free (tag_match_info);

	if (remote_match_info)
		g_match_info_free (remote_match_info);
}