summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Straub <bs@github.com>2014-01-27 13:12:31 -0800
committerBen Straub <bs@github.com>2014-01-30 15:51:00 -0800
commita2311f92c29e0fee5348d580c3318cf6724cd765 (patch)
treef4af06ba4ea36749b3f4a76789cd27aa13a457f6 /src
parent94f263f59be5be74945367b9793c57f297ed4a44 (diff)
downloadlibgit2-a2311f92c29e0fee5348d580c3318cf6724cd765.tar.gz
Ensure updating HEAD updates reflog
Diffstat (limited to 'src')
-rw-r--r--src/refdb_fs.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 53c42458f..9ae784782 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -1434,12 +1434,12 @@ success:
static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_signature *who, const char *message)
{
int error;
- git_oid old_id, new_id;
+ git_oid old_id, new_id = {{0}};
git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT;
git_repository *repo = backend->repo;
/* Creation of symbolic references doesn't get a reflog entry */
- if (ref->type == GIT_REF_SYMBOLIC)
+ if (ref->type == GIT_REF_SYMBOLIC && strcmp(ref->name, GIT_HEAD_FILE))
return 0;
error = git_reference_name_to_id(&old_id, repo, ref->name);
@@ -1450,7 +1450,8 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
if (error < 0)
return error;
- git_oid_cpy(&new_id, git_reference_target(ref));
+ if (git_reference_target(ref) != NULL)
+ git_oid_cpy(&new_id, git_reference_target(ref));
if ((error = serialize_reflog_entry(&buf, &old_id, &new_id, who, message)) < 0)
goto cleanup;