name_ref(): rewrite to take an object_id argument
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>
Michael Haggerty committed
May 25, 2015 at 18:38 UTC
73868486f0ef6c5572681913fc2d204f12846bc5
1 file changed
+4
-6
builtin/name-rev.c
+4
-6
@@ -138,9 +138,9 @@ static int tipcmp(const void *a_, const void *b_)
138
return hashcmp(a->sha1, b->sha1);
139
}
140
141
-static int name_ref(const char *path, const unsigned char *sha1, int flags, void *cb_data)
141
+static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data)
142
{
143
- struct object *o = parse_object(sha1);
143
+ struct object *o = parse_object(oid->hash);
144
struct name_ref_data *data = cb_data;
145
int can_abbreviate_output = data->tags_only && data->name_only;
146
int deref = 0;
@@ -160,7 +160,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void
160
}
161
}
162
163
- add_to_tip_table(sha1, path, can_abbreviate_output);
163
+ add_to_tip_table(oid->hash, path, can_abbreviate_output);
164
165
while (o && o->type == OBJ_TAG) {
166
struct tag *t = (struct tag *) o;
@@ -305,8 +305,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
305
struct object_array revs = OBJECT_ARRAY_INIT;
306
int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;
307
struct name_ref_data data = { 0, 0, NULL };
308
- struct each_ref_fn_sha1_adapter wrapped_name_ref =
309
- {name_ref, &data};
308
struct option opts[] = {
309
OPT_BOOL(0, "name-only", &data.name_only, N_("print only names (no SHA-1)")),
310
OPT_BOOL(0, "tags", &data.tags_only, N_("only use tags to name the commits")),
@@ -379,7 +377,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
377
378
if (cutoff)
379
cutoff = cutoff - CUTOFF_DATE_SLOP;
382
- for_each_ref(each_ref_fn_adapter, &wrapped_name_ref);
380
+ for_each_ref(name_ref, &data);
381
382
if (transform_stdin) {
383
char buffer[2048];