Skip to content

Commit 90388aa

Browse files
committed
refdb_fs: be explicit about using null-OID if we cannot resolve ref
1 parent 78a8f68 commit 90388aa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/refdb_fs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,15 +1140,16 @@ static int cmp_old_ref(int *cmp, git_refdb_backend *backend, const char *name,
11401140
static int maybe_append_head(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
11411141
{
11421142
int error;
1143-
git_oid old_id = {{0}};
1143+
git_oid old_id;
11441144
git_reference *tmp = NULL, *head = NULL, *peeled = NULL;
11451145
const char *name;
11461146

11471147
if (ref->type == GIT_REF_SYMBOLIC)
11481148
return 0;
11491149

11501150
/* if we can't resolve, we use {0}*40 as old id */
1151-
git_reference_name_to_id(&old_id, backend->repo, ref->name);
1151+
if (git_reference_name_to_id(&old_id, backend->repo, ref->name) < 0)
1152+
memset(&old_id, 0, sizeof(old_id));
11521153

11531154
if ((error = git_reference_lookup(&head, backend->repo, GIT_HEAD_FILE)) < 0)
11541155
return error;

0 commit comments

Comments
 (0)