diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-06-06 15:02:23 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2017-06-08 12:05:35 +0200 |
commit | 90388aa836fc463f87cc9dfd41823022055a40fa (patch) | |
tree | 4c6e5e85790d5f3c1245202109fe6d53d493ee92 /src | |
parent | 78a8f68f06b51b064020e5f9c3b564ccf3ad02d9 (diff) | |
download | libgit2-90388aa836fc463f87cc9dfd41823022055a40fa.tar.gz |
refdb_fs: be explicit about using null-OID if we cannot resolve ref
Diffstat (limited to 'src')
-rw-r--r-- | src/refdb_fs.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c index b325d2763..988a14b85 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -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; |