Skip to content

Commit 99a2cfb

Browse files
mhaggergitster
authored andcommitted
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>
1 parent fcb615f commit 99a2cfb

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

builtin/describe.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ static void add_to_known_names(const char *path,
119119
}
120120
}
121121

122-
static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data)
122+
static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data)
123123
{
124124
int is_tag = starts_with(path, "refs/tags/");
125-
unsigned char peeled[20];
125+
struct object_id peeled;
126126
int is_annotated, prio;
127127

128128
/* 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
134134
return 0;
135135

136136
/* Is it annotated? */
137-
if (!peel_ref(path, peeled)) {
138-
is_annotated = !!hashcmp(sha1, peeled);
137+
if (!peel_ref(path, peeled.hash)) {
138+
is_annotated = !!oidcmp(oid, &peeled);
139139
} else {
140-
hashcpy(peeled, sha1);
140+
oidcpy(&peeled, oid);
141141
is_annotated = 0;
142142
}
143143

@@ -154,7 +154,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
154154
else
155155
prio = 0;
156156

157-
add_to_known_names(all ? path + 5 : path + 10, peeled, prio, sha1);
157+
add_to_known_names(all ? path + 5 : path + 10, peeled.hash, prio, oid->hash);
158158
return 0;
159159
}
160160

@@ -413,8 +413,6 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
413413
PARSE_OPT_OPTARG, NULL, (intptr_t) "-dirty"},
414414
OPT_END(),
415415
};
416-
struct each_ref_fn_sha1_adapter wrapped_get_name =
417-
{get_name, NULL};
418416

419417
git_config(git_default_config, NULL);
420418
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)
453451
}
454452

455453
hashmap_init(&names, (hashmap_cmp_fn) commit_name_cmp, 0);
456-
for_each_rawref(each_ref_fn_adapter, &wrapped_get_name);
454+
for_each_rawref(get_name, NULL);
457455
if (!names.size && !always)
458456
die(_("No names found, cannot describe anything."));
459457

0 commit comments

Comments
 (0)