ref-filter: use "struct object_id" consistently
authorJeff King <peff@peff.net>
Fri, 6 Apr 2018 18:58:32 +0000 (14:58 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Apr 2018 21:14:45 +0000 (06:14 +0900)
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>
builtin/tag.c
builtin/verify-tag.c
ref-filter.c
ref-filter.h
index da186691ed8853bc5848c4106c752b015756eda3..42278f51672acae675785b90aad43eb415f3fb14 100644 (file)
@@ -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;
 }
index ad7b79fa5cd718daf3be5f1a46a1fbb2bed41ad5..6fa04b751ac1d6ae18b8a42e700e2cefa6427a41 100644 (file)
@@ -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;
 }
index 45fc56216aaa8fd084a10514f6f4912878ab1627..ade97a8486a5cc2422d9ec64c4a89f34b0238d39 100644 (file)
@@ -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);
index 0d98342b343196387c0f4e2dcd5978a9361d8edb..68268f9ebcbc683ac2df348a9096a5ebd2227e85 100644 (file)
@@ -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  */