Commit 7f058b86682e2a1566b192dfd1f0d333cc5b8c7c

Ben Straub 2014-02-01T19:29:48

Check for errors when dereferencing symbolic refs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 829e7c5..89c77c1 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -1452,8 +1452,12 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
 	if (error < 0)
 		return error;
 
-	if (git_reference_symbolic_target(ref) != NULL)
-		git_reference_name_to_id(&new_id, repo, git_reference_symbolic_target(ref));
+	if (git_reference_symbolic_target(ref) != NULL) {
+		error = git_reference_name_to_id(&new_id, repo, git_reference_symbolic_target(ref));
+		if (error != 0 && error != GIT_ENOTFOUND)
+			goto cleanup;
+		giterr_clear();
+	}
 	else if (git_reference_target(ref) != NULL)
 		git_oid_cpy(&new_id, git_reference_target(ref));