]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/helper/ref-store: initialize oid in resolve-ref
authorHan-Wen Nienhuys <hanwen@google.com>
Mon, 31 May 2021 16:56:17 +0000 (16:56 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Jun 2021 01:01:54 +0000 (10:01 +0900)
This will print $ZERO_OID when asking for a non-existent ref from the
test-helper.

Since resolve-ref provides direct access to refs_resolve_ref_unsafe(), it
provides a reliable mechanism for accessing REFNAME, while avoiding the implicit
resolution to refs/heads/REFNAME.

Reviewed-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/helper/test-ref-store.c

index bba5f841c6ab00362aa81313fcf3ef3fa7ddfe9d..b314b81a45b27cac548e1c5628f3dd96685ceb09 100644 (file)
@@ -118,7 +118,7 @@ static int cmd_for_each_ref(struct ref_store *refs, const char **argv)
 
 static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
 {
-       struct object_id oid;
+       struct object_id oid = *null_oid();
        const char *refname = notnull(*argv++, "refname");
        int resolve_flags = arg_flags(*argv++, "resolve-flags");
        int flags;