Skip to content

Commit 53df97a

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit 53df97a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

builtin/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int verify_tag(const char *name, const char *ref,
117117
return -1;
118118

119119
if (format->format)
120-
pretty_print_ref(name, oid->hash, format);
120+
pretty_print_ref(name, oid, format);
121121

122122
return 0;
123123
}

builtin/verify-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
7272
}
7373

7474
if (format.format)
75-
pretty_print_ref(name, oid.hash, &format);
75+
pretty_print_ref(name, &oid, &format);
7676
}
7777
return had_error;
7878
}

ref-filter.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,12 +1826,12 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
18261826

18271827
/* Allocate space for a new ref_array_item and copy the objectname and flag to it */
18281828
static struct ref_array_item *new_ref_array_item(const char *refname,
1829-
const unsigned char *objectname,
1829+
const struct object_id *oid,
18301830
int flag)
18311831
{
18321832
struct ref_array_item *ref;
18331833
FLEX_ALLOC_STR(ref, refname, refname);
1834-
hashcpy(ref->objectname.hash, objectname);
1834+
oidcpy(&ref->objectname, oid);
18351835
ref->flag = flag;
18361836

18371837
return ref;
@@ -1927,7 +1927,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
19271927
* to do its job and the resulting list may yet to be pruned
19281928
* by maxcount logic.
19291929
*/
1930-
ref = new_ref_array_item(refname, oid->hash, flag);
1930+
ref = new_ref_array_item(refname, oid, flag);
19311931
ref->commit = commit;
19321932

19331933
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,
21652165
putchar('\n');
21662166
}
21672167

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,
21692169
const struct ref_format *format)
21702170
{
21712171
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);
21732173
ref_item->kind = ref_kind_from_refname(name);
21742174
show_ref_array_item(ref_item, format);
21752175
free_array_item(ref_item);

ref-filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void setup_ref_filter_porcelain_msg(void);
132132
* Print a single ref, outside of any ref-filter. Note that the
133133
* name must be a fully qualified refname.
134134
*/
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,
136136
const struct ref_format *format);
137137

138138
#endif /* REF_FILTER_H */

0 commit comments

Comments
 (0)