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>
Michael Haggerty committed
May 25, 2015 at 18:38 UTC
30a3fd40500c31a74ebab808d741d2fc6c449a29
1 file changed
+4
-5
builtin/for-each-ref.c
+4
-5
@@ -840,7 +840,8 @@ struct grab_ref_cbdata {
840
* A call-back given to for_each_ref(). Filter refs and keep them for
841
* later object processing.
842
*/
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)
845
{
846
struct grab_ref_cbdata *cb = cb_data;
847
struct refinfo *ref;
@@ -878,7 +879,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
879
*/
880
ref = xcalloc(1, sizeof(*ref));
881
ref->refname = xstrdup(refname);
881
- hashcpy(ref->objectname, sha1);
882
+ hashcpy(ref->objectname, oid->hash);
883
ref->flag = flag;
884
885
cnt = cb->grab_cnt;
@@ -1072,8 +1073,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1073
int maxcount = 0, quote_style = 0;
1074
struct refinfo **refs;
1075
struct grab_ref_cbdata cbdata;
1075
- struct each_ref_fn_sha1_adapter wrapped_grab_single_ref =
1076
- {grab_single_ref, &cbdata};
1076
1077
struct option opts[] = {
1078
OPT_BIT('s', "shell", "e_style,
@@ -1113,7 +1112,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
1112
1113
memset(&cbdata, 0, sizeof(cbdata));
1114
cbdata.grab_pattern = argv;
1116
- for_each_rawref(each_ref_fn_adapter, &wrapped_grab_single_ref);
1115
+ for_each_rawref(grab_single_ref, &cbdata);
1116
refs = cbdata.grab_array;
1117
num_refs = cbdata.grab_cnt;
1118