]> git.proxmox.com Git - libgit2.git/commitdiff
refdb_fs: be explicit about using null-OID if we cannot resolve ref
authorPatrick Steinhardt <ps@pks.im>
Tue, 6 Jun 2017 13:02:23 +0000 (15:02 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 8 Jun 2017 10:05:35 +0000 (12:05 +0200)
src/refdb_fs.c

index b325d2763d50356ef01fe468ff01df7c36224c15..988a14b85f0b0a4d61ee9f2012e443e32272887b 100644 (file)
@@ -1140,7 +1140,7 @@ out:
 static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
 {
        int error;
-       git_oid old_id = {{0}};
+       git_oid old_id;
        git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
        const char *name;
 
@@ -1148,7 +1148,8 @@ static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref
                return 0;
 
        /* if we can't resolve, we use {0}*40 as old id */
-       git_reference_name_to_id(&old_id, backend->repo, ref->name);
+       if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
+               memset(&old_id, 0, sizeof(old_id));
 
        if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0)
                return error;