ref-filter: use "struct object_id" consistently
Internally we store a "struct object_id", and all of our callers have one to pass us. But we insist that they peel it to its bare-sha1 hash, which we then hashcpy() into place. Let's pass it around as an object_id, which future-proofs us for a post-sha1 world. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Apr 6, 2018 at 14:58 UTC
53df97a29d78070f3dfaf3e4d9a5ae61f33d7906
4 files changed
+8
-8
builtin/tag.c
+1
-1
@@ -117,7 +117,7 @@ static int verify_tag(const char *name, const char *ref,
117
return -1;
118
119
if (format->format)
120
- pretty_print_ref(name, oid->hash, format);
120
+ pretty_print_ref(name, oid, format);
121
122
return 0;
123
}
builtin/verify-tag.c
+1
-1
@@ -72,7 +72,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
72
}
73
74
if (format.format)
75
- pretty_print_ref(name, oid.hash, &format);
75
+ pretty_print_ref(name, &oid, &format);
76
}
77
return had_error;
78
}
ref-filter.c
+5
-5
@@ -1826,12 +1826,12 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
1826
1827
/* Allocate space for a new ref_array_item and copy the objectname and flag to it */
1828
static struct ref_array_item *new_ref_array_item(const char *refname,
1829
- const unsigned char *objectname,
1829
+ const struct object_id *oid,
1830
int flag)
1831
{
1832
struct ref_array_item *ref;
1833
FLEX_ALLOC_STR(ref, refname, refname);
1834
- hashcpy(ref->objectname.hash, objectname);
1834
+ oidcpy(&ref->objectname, oid);
1835
ref->flag = flag;
1836
1837
return ref;
@@ -1927,7 +1927,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
1927
* to do its job and the resulting list may yet to be pruned
1928
* by maxcount logic.
1929
*/
1930
- ref = new_ref_array_item(refname, oid->hash, flag);
1930
+ ref = new_ref_array_item(refname, oid, flag);
1931
ref->commit = commit;
1932
1933
REALLOC_ARRAY(ref_cbdata->array->items, ref_cbdata->array->nr + 1);
@@ -2165,11 +2165,11 @@ void show_ref_array_item(struct ref_array_item *info,
2165
putchar('\n');
2166
}
2167
2168
-void pretty_print_ref(const char *name, const unsigned char *sha1,
2168
+void pretty_print_ref(const char *name, const struct object_id *oid,
2169
const struct ref_format *format)
2170
{
2171
struct ref_array_item *ref_item;
2172
- ref_item = new_ref_array_item(name, sha1, 0);
2172
+ ref_item = new_ref_array_item(name, oid, 0);
2173
ref_item->kind = ref_kind_from_refname(name);
2174
show_ref_array_item(ref_item, format);
2175
free_array_item(ref_item);
ref-filter.h
+1
-1
@@ -132,7 +132,7 @@ void setup_ref_filter_porcelain_msg(void);
132
* Print a single ref, outside of any ref-filter. Note that the
133
* name must be a fully qualified refname.
134
*/
135
-void pretty_print_ref(const char *name, const unsigned char *sha1,
135
+void pretty_print_ref(const char *name, const struct object_id *oid,
136
const struct ref_format *format);
137
138
#endif /* REF_FILTER_H */