Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti <vicent@github.com>2014-04-01 15:47:52 +0400
committerVicent Marti <vicent@github.com>2014-04-01 15:47:52 +0400
commita2d18a0219a1d76f0914d59bb8dc73689e9ab1b5 (patch)
tree124983e5196f1905b7cdc496fd3dbe9f57cb9ec2 /examples
parent9325460a9360516c10e1d79f5b85882d84725e29 (diff)
parent6ad59ef1d461180a51a59d5809dcfd01e2d8cfd9 (diff)
Merge pull request #2228 from mekishizufu/example_short_id
Use git_object_short_id in examples
Diffstat (limited to 'examples')
-rw-r--r--examples/tag.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/examples/tag.c b/examples/tag.c
index 4c689cc55..ebb8e37b2 100644
--- a/examples/tag.c
+++ b/examples/tag.c
@@ -169,20 +169,22 @@ static void action_delete_tag(tag_state *state)
{
tag_options *opts = state->opts;
git_object *obj;
- char oid[GIT_OID_HEXSZ + 1];
+ git_buf abbrev_oid = {0};
check(!opts->tag_name, "Name required");
check_lg2(git_revparse_single(&obj, state->repo, opts->tag_name),
"Failed to lookup rev", opts->tag_name);
+ check_lg2(git_object_short_id(&abbrev_oid, obj),
+ "Unable to get abbreviated OID", opts->tag_name);
+
check_lg2(git_tag_delete(state->repo, opts->tag_name),
"Unable to delete tag", opts->tag_name);
- git_oid_tostr(oid, sizeof(oid), git_object_id(obj));
-
- printf("Deleted tag '%s' (was %s)\n", opts->tag_name, oid);
+ printf("Deleted tag '%s' (was %s)\n", opts->tag_name, abbrev_oid.ptr);
+ git_buf_free(&abbrev_oid);
git_object_free(obj);
}