示例#1
0
/**
 * ggit_tag_get_target:
 * @tag: a #GgitTag.
 * @error: a #GError for error reporting, or %NULL.
 *
 * Gets the target #GgitObject of @tag.
 *
 * This method performs a repository lookup for the
 * given object and returns it.
 *
 * Returns: (transfer full): the target #GgitObject of the tag.
 */
GgitObject *
ggit_tag_get_target (GgitTag  *tag,
                     GError  **error)
{
	GgitObject *object = NULL;
	git_tag *t;
	git_object *obj;
	gint ret;

	g_return_val_if_fail (GGIT_IS_TAG (tag), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	t = (git_tag *)GGIT_OBJECT (tag)->priv->obj;
	ret = git_tag_target (&obj, t);

	if (ret != GIT_SUCCESS)
	{
		_ggit_error_set (error, ret);
	}
	else
	{
		object = ggit_utils_create_real_object (obj);
	}

	return object;
}
示例#2
0
static void
ggit_object_finalize (GObject *object)
{
	GgitObject *obj = GGIT_OBJECT (object);

	git_object_close (obj->priv->obj);

	G_OBJECT_CLASS (ggit_object_parent_class)->finalize (object);
}
示例#3
0
GgitTag *
_ggit_tag_new (git_tag *tag)
{
	GgitTag *gtag;

	gtag = g_object_new (GGIT_TYPE_TAG, NULL);
	GGIT_OBJECT (gtag)->priv->obj = (git_object *)tag;

	return gtag;
}
示例#4
0
/**
 * ggit_tag_get_message:
 * @tag: a #GgitTag.
 *
 * Gets the message of @tag.
 *
 * Returns: the message of the tag.
 */
const gchar *
ggit_tag_get_message (GgitTag *tag)
{
	git_tag *t;

	g_return_val_if_fail (GGIT_IS_TAG (tag), NULL);

	t = (git_tag *)GGIT_OBJECT (tag)->priv->obj;

	return git_tag_message (t);
}
示例#5
0
GgitObject *
ggit_utils_create_real_object (git_object *obj,
                               gboolean    owned)
{
	git_otype otype;

	otype = git_object_type (obj);

	switch (otype)
	{
		case GIT_OBJ_TAG:
			return GGIT_OBJECT (_ggit_tag_wrap ((git_tag *)obj, owned));
		case GIT_OBJ_BLOB:
			return GGIT_OBJECT (_ggit_blob_wrap ((git_blob *)obj, owned));
		case GIT_OBJ_COMMIT:
			return GGIT_OBJECT (_ggit_commit_wrap ((git_commit *)obj, owned));
		case GIT_OBJ_TREE:
			return GGIT_OBJECT (_ggit_tree_wrap ((git_tree *)obj, owned));
		default:
			return NULL;
	}
}
示例#6
0
/**
 * ggit_tag_get_tagger:
 * @tag: a #GgitTag.
 *
 * Get the tagger (author) of @tag. The returned value must be free with
 * ggit_signature_free().
 *
 * Returns: (transfer full): the tagger (author) of the tag.
 */
GgitSignature *
ggit_tag_get_tagger (GgitTag *tag)
{
	const git_signature *signature;
	git_tag *t;

	g_return_val_if_fail (GGIT_IS_TAG (tag), NULL);

	t = (git_tag *)GGIT_OBJECT (tag)->priv->obj;
	signature = git_tag_tagger (t);

	return _ggit_signature_wrap ((git_signature *)signature);
}
示例#7
0
/**
 * ggit_tag_get_target_oid:
 * @tag: a #GgitTag.
 *
 * Gets the target #GgitOId of @tag.
 *
 * Returns: (transfer full): the target #GgitOId of the tag.
 */
GgitOId *
ggit_tag_get_target_oid (GgitTag *tag)
{
	const git_oid *oid;
	git_tag *t;

	g_return_val_if_fail (GGIT_IS_TAG (tag), NULL);

	t = (git_tag *)GGIT_OBJECT (tag)->priv->obj;
	oid = git_tag_target_oid (t);

	return _ggit_oid_new ((git_oid *)oid);
}
示例#8
0
/**
 * ggit_index_entry_set_commit:
 * @entry: a #GgitIndexEntry.
 * @commit: a #GgitCommit.
 *
 * Set the index entry to point to a given commit. This sets the index entry
 * id to the commit id, changes the mode to #GGIT_FILE_MODE_COMMIT and updates
 * the timestamps to when the commit was made.
 *
 **/
void
ggit_index_entry_set_commit (GgitIndexEntry    *entry,
                             GgitCommit        *commit)
{
	GgitSignature *sig;
	gint64 ut;

	g_return_if_fail (entry != NULL);
	g_return_if_fail (GGIT_IS_COMMIT (commit));

	ggit_index_entry_set_id (entry, ggit_object_get_id (GGIT_OBJECT (commit)));
	ggit_index_entry_set_mode (entry, GIT_FILEMODE_COMMIT);

	sig = ggit_commit_get_committer (commit);
	ut = g_date_time_to_unix (ggit_signature_get_time (sig));

	entry->entry->ctime.seconds = ut;
	entry->entry->ctime.nanoseconds = 0;

	entry->entry->mtime.seconds = ut;
	entry->entry->mtime.nanoseconds = 0;

	g_object_unref (sig);
}