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>
This commit is contained in:
parent
91d6e94ea6
commit
f72f542107
@ -350,16 +350,16 @@ static void run_service(const char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_text_ref(const char *name, const unsigned char *sha1,
|
static int show_text_ref(const char *name, const struct object_id *oid,
|
||||||
int flag, void *cb_data)
|
int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
const char *name_nons = strip_namespace(name);
|
const char *name_nons = strip_namespace(name);
|
||||||
struct strbuf *buf = cb_data;
|
struct strbuf *buf = cb_data;
|
||||||
struct object *o = parse_object(sha1);
|
struct object *o = parse_object(oid->hash);
|
||||||
if (!o)
|
if (!o)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
strbuf_addf(buf, "%s\t%s\n", sha1_to_hex(sha1), name_nons);
|
strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
|
||||||
if (o->type == OBJ_TAG) {
|
if (o->type == OBJ_TAG) {
|
||||||
o = deref_tag(o, name, 0);
|
o = deref_tag(o, name, 0);
|
||||||
if (!o)
|
if (!o)
|
||||||
@ -395,17 +395,14 @@ static void get_info_refs(char *arg)
|
|||||||
run_service(argv);
|
run_service(argv);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
struct each_ref_fn_sha1_adapter wrapped_show_text_ref =
|
|
||||||
{show_text_ref, &buf};
|
|
||||||
|
|
||||||
select_getanyfile();
|
select_getanyfile();
|
||||||
for_each_namespaced_ref(each_ref_fn_adapter, &wrapped_show_text_ref);
|
for_each_namespaced_ref(show_text_ref, &buf);
|
||||||
send_strbuf("text/plain", &buf);
|
send_strbuf("text/plain", &buf);
|
||||||
}
|
}
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_head_ref(const char *refname, const unsigned char *sha1,
|
static int show_head_ref(const char *refname, const struct object_id *oid,
|
||||||
int flag, void *cb_data)
|
int flag, void *cb_data)
|
||||||
{
|
{
|
||||||
struct strbuf *buf = cb_data;
|
struct strbuf *buf = cb_data;
|
||||||
@ -419,7 +416,7 @@ static int show_head_ref(const char *refname, const unsigned char *sha1,
|
|||||||
|
|
||||||
strbuf_addf(buf, "ref: %s\n", target_nons);
|
strbuf_addf(buf, "ref: %s\n", target_nons);
|
||||||
} else {
|
} else {
|
||||||
strbuf_addf(buf, "%s\n", sha1_to_hex(sha1));
|
strbuf_addf(buf, "%s\n", oid_to_hex(oid));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -428,11 +425,9 @@ static int show_head_ref(const char *refname, const unsigned char *sha1,
|
|||||||
static void get_head(char *arg)
|
static void get_head(char *arg)
|
||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
struct each_ref_fn_sha1_adapter wrapped_show_head_ref =
|
|
||||||
{show_head_ref, &buf};
|
|
||||||
|
|
||||||
select_getanyfile();
|
select_getanyfile();
|
||||||
head_ref_namespaced(each_ref_fn_adapter, &wrapped_show_head_ref);
|
head_ref_namespaced(show_head_ref, &buf);
|
||||||
send_strbuf("text/plain", &buf);
|
send_strbuf("text/plain", &buf);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user