Commit 32350e89d8e3ca245def9ccee05aa21c92e10726

Edward Thomson 2021-01-07T14:01:30

remote: don't update invalid refs If a symbolic reference points to something invalid, then do not try to update it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/remote.c b/src/remote.c
index 29e15bb..55effcc 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1141,6 +1141,16 @@ static int remote_head_for_ref(git_remote_head **out, git_remote *remote, git_re
 		ref_name = git_reference_name(resolved_ref);
 	}
 
+	/*
+	 * The ref name may be unresolvable - perhaps it's pointing to
+	 * something invalid.  In this case, there is no remote head for
+	 * this ref.
+	 */
+	if (!ref_name) {
+		error = 0;
+		goto cleanup;
+	}
+
 	if ((error = ref_to_update(&update, &remote_name, remote, spec, ref_name)) < 0)
 		goto cleanup;