http-backend: 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
f72f54210728a3550fa314e99470dcbbef001297
1 file changed
+9
-14
http-backend.c
+9
-14
@@ -350,16 +350,16 @@ static void run_service(const char **argv)
350
exit(1);
351
}
352
353
-static int show_text_ref(const char *name, const unsigned char *sha1,
354
- int flag, void *cb_data)
353
+static int show_text_ref(const char *name, const struct object_id *oid,
354
+ int flag, void *cb_data)
355
{
356
const char *name_nons = strip_namespace(name);
357
struct strbuf *buf = cb_data;
358
- struct object *o = parse_object(sha1);
358
+ struct object *o = parse_object(oid->hash);
359
if (!o)
360
return 0;
361
362
- strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name_nons);
362
+ strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
363
if (o->type == OBJ_TAG) {
364
o = deref_tag(o, name, 0);
365
if (!o)
@@ -395,18 +395,15 @@ static void get_info_refs(char *arg)
395
run_service(argv);
396
397
} else {
398
- struct each_ref_fn_sha1_adapter wrapped_show_text_ref =
399
- {show_text_ref, &buf};
400
-
398
select_getanyfile();
402
- for_each_namespaced_ref(each_ref_fn_adapter, &wrapped_show_text_ref);
399
+ for_each_namespaced_ref(show_text_ref, &buf);
400
send_strbuf("text/plain", &buf);
401
}
402
strbuf_release(&buf);
403
}
404
408
-static int show_head_ref(const char *refname, const unsigned char *sha1,
409
- int flag, void *cb_data)
405
+static int show_head_ref(const char *refname, const struct object_id *oid,
406
+ int flag, void *cb_data)
407
{
408
struct strbuf *buf = cb_data;
409
@@ -419,7 +416,7 @@ static int show_head_ref(const char *refname, const unsigned char *sha1,
416
417
strbuf_addf(buf, "ref: %s\n", target_nons);
418
} else {
422
- strbuf_addf(buf, "%s\n", sha1_to_hex(sha1));
419
+ strbuf_addf(buf, "%s\n", oid_to_hex(oid));
420
}
421
422
return 0;
@@ -428,11 +425,9 @@ static int show_head_ref(const char *refname, const unsigned char *sha1,
425
static void get_head(char *arg)
426
{
427
struct strbuf buf = STRBUF_INIT;
431
- struct each_ref_fn_sha1_adapter wrapped_show_head_ref =
432
- {show_head_ref, &buf};
428
429
select_getanyfile();
435
- head_ref_namespaced(each_ref_fn_adapter, &wrapped_show_head_ref);
430
+ head_ref_namespaced(show_head_ref, &buf);
431
send_strbuf("text/plain", &buf);
432
strbuf_release(&buf);
433
}