summaryrefslogtreecommitdiff
path: root/builtin/describe.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-05-25 18:38:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-05-25 19:19:29 (GMT)
commit99a2cfbfe639ccd13e48ac48e8bd4461c9c1b178 (patch)
tree15de291543522330902a48c86b56a9890b4663d3 /builtin/describe.c
parentfcb615f51f303177a8454e988f8e8ef9fb3e94d9 (diff)
downloadgit-99a2cfbfe639ccd13e48ac48e8bd4461c9c1b178.zip
git-99a2cfbfe639ccd13e48ac48e8bd4461c9c1b178.tar.gz
git-99a2cfbfe639ccd13e48ac48e8bd4461c9c1b178.tar.bz2
get_name(): rewrite to take an object_id argument
Rewrite to take an object_id argument and convert the local variable "peeled" object_id. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/describe.c')
-rw-r--r--builtin/describe.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 7d0c855..a36c829 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -119,10 +119,10 @@ static void add_to_known_names(const char *path,
}
}
-static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
+static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
{
int is_tag = starts_with(path, "refs/tags/");
- unsigned char peeled[20];
+ struct object_id peeled;
int is_annotated, prio;
/* Reject anything outside refs/tags/ unless --all */
@@ -134,10 +134,10 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
return 0;
/* Is it annotated? */
- if (!peel_ref(path, peeled)) {
- is_annotated = !!hashcmp(sha1, peeled);
+ if (!peel_ref(path, peeled.hash)) {
+ is_annotated = !!oidcmp(oid, &peeled);
} else {
- hashcpy(peeled, sha1);
+ oidcpy(&peeled, oid);
is_annotated = 0;
}
@@ -154,7 +154,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
else
prio = 0;
- add_to_known_names(all ? path + 5 : path + 10, peeled, prio, sha1);
+ add_to_known_names(all ? path + 5 : path + 10, peeled.hash, prio, oid->hash);
return 0;
}
@@ -413,8 +413,6 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
PARSE_OPT_OPTARG, NULL, (intptr_t) "-dirty"},
OPT_END(),
};
- struct each_ref_fn_sha1_adapter wrapped_get_name =
- {get_name, NULL};
git_config(git_default_config, NULL);
argc = parse_options(argc, argv, prefix, options, describe_usage, 0);
@@ -453,7 +451,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
}
hashmap_init(&names, (hashmap_cmp_fn) commit_name_cmp, 0);
- for_each_rawref(each_ref_fn_adapter, &wrapped_get_name);
+ for_each_rawref(get_name, NULL);
if (!names.size && !always)
die(_("No names found, cannot describe anything."));