Skip to content

Commit 30a3fd4

Browse files
mhaggergitster
authored andcommitted
grab_single_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>
1 parent 0e0b7de commit 30a3fd4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

builtin/for-each-ref.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,8 @@ struct grab_ref_cbdata {
840840
* A call-back given to for_each_ref(). Filter refs and keep them for
841841
* later object processing.
842842
*/
843-
static int grab_single_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
843+
static int grab_single_ref(const char *refname, const struct object_id *oid,
844+
int flag, void *cb_data)
844845
{
845846
struct grab_ref_cbdata *cb = cb_data;
846847
struct refinfo *ref;
@@ -878,7 +879,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
878879
*/
879880
ref = xcalloc(1, sizeof(*ref));
880881
ref->refname = xstrdup(refname);
881-
hashcpy(ref->objectname, sha1);
882+
hashcpy(ref->objectname, oid->hash);
882883
ref->flag = flag;
883884

884885
cnt = cb->grab_cnt;
@@ -1072,8 +1073,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
10721073
int maxcount = 0, quote_style = 0;
10731074
struct refinfo **refs;
10741075
struct grab_ref_cbdata cbdata;
1075-
struct each_ref_fn_sha1_adapter wrapped_grab_single_ref =
1076-
{grab_single_ref, &cbdata};
10771076

10781077
struct option opts[] = {
10791078
OPT_BIT('s', "shell", &quote_style,
@@ -1113,7 +1112,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
11131112

11141113
memset(&cbdata, 0, sizeof(cbdata));
11151114
cbdata.grab_pattern = argv;
1116-
for_each_rawref(each_ref_fn_adapter, &wrapped_grab_single_ref);
1115+
for_each_rawref(grab_single_ref, &cbdata);
11171116
refs = cbdata.grab_array;
11181117
num_refs = cbdata.grab_cnt;
11191118

0 commit comments

Comments
 (0)