summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-04-06 18:58:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-08 21:14:45 (GMT)
commit53df97a29d78070f3dfaf3e4d9a5ae61f33d7906 (patch)
tree98aa44a9d000da1f66fd8ff7c9eabc9377d1ec9d
parent468165c1d8a442994a825f3684528361727cd8c0 (diff)
downloadgit-53df97a29d78070f3dfaf3e4d9a5ae61f33d7906.zip
git-53df97a29d78070f3dfaf3e4d9a5ae61f33d7906.tar.gz
git-53df97a29d78070f3dfaf3e4d9a5ae61f33d7906.tar.bz2
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>
-rw-r--r--builtin/tag.c2
-rw-r--r--builtin/verify-tag.c2
-rw-r--r--ref-filter.c10
-rw-r--r--ref-filter.h2
4 files changed, 8 insertions, 8 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index da18669..42278f5 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -117,7 +117,7 @@ static int verify_tag(const char *name, const char *ref,
return -1;
if (format->format)
- pretty_print_ref(name, oid->hash, format);
+ pretty_print_ref(name, oid, format);
return 0;
}
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index ad7b79f..6fa04b7 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -72,7 +72,7 @@ int cmd_verify_tag(int argc, const char **argv, const char *prefix)
}
if (format.format)
- pretty_print_ref(name, oid.hash, &format);
+ pretty_print_ref(name, &oid, &format);
}
return had_error;
}
diff --git a/ref-filter.c b/ref-filter.c
index 45fc562..ade97a8 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1826,12 +1826,12 @@ static const struct object_id *match_points_at(struct oid_array *points_at,
/* Allocate space for a new ref_array_item and copy the objectname and flag to it */
static struct ref_array_item *new_ref_array_item(const char *refname,
- const unsigned char *objectname,
+ const struct object_id *oid,
int flag)
{
struct ref_array_item *ref;
FLEX_ALLOC_STR(ref, refname, refname);
- hashcpy(ref->objectname.hash, objectname);
+ oidcpy(&ref->objectname, oid);
ref->flag = flag;
return ref;
@@ -1927,7 +1927,7 @@ static int ref_filter_handler(const char *refname, const struct object_id *oid,
* to do its job and the resulting list may yet to be pruned
* by maxcount logic.
*/
- ref = new_ref_array_item(refname, oid->hash, flag);
+ ref = new_ref_array_item(refname, oid, flag);
ref->commit = commit;
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,
putchar('\n');
}
-void pretty_print_ref(const char *name, const unsigned char *sha1,
+void pretty_print_ref(const char *name, const struct object_id *oid,
const struct ref_format *format)
{
struct ref_array_item *ref_item;
- ref_item = new_ref_array_item(name, sha1, 0);
+ ref_item = new_ref_array_item(name, oid, 0);
ref_item->kind = ref_kind_from_refname(name);
show_ref_array_item(ref_item, format);
free_array_item(ref_item);
diff --git a/ref-filter.h b/ref-filter.h
index 0d98342..68268f9 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -132,7 +132,7 @@ void setup_ref_filter_porcelain_msg(void);
* Print a single ref, outside of any ref-filter. Note that the
* name must be a fully qualified refname.
*/
-void pretty_print_ref(const char *name, const unsigned char *sha1,
+void pretty_print_ref(const char *name, const struct object_id *oid,
const struct ref_format *format);
#endif /* REF_FILTER_H */