Allow builtin-fetch to work on a detached HEAD
If we are running fetch in a repository that has a detached HEAD then there is no current_branch available. In such a case any ref that the fetch might update by definition cannot also be the current branch so we should always bypass the "don't update HEAD" test. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Sep 16, 2007 at 02:31 UTC
b3abdd9d216c578383b66bb10b95edb3380640e7
1 file changed
+2
-1
builtin-fetch.c
+2
-1
@@ -151,7 +151,8 @@ static int update_local_ref(struct ref *ref,
151
return 0;
152
}
153
154
- if (!strcmp(ref->name, current_branch->name) &&
154
+ if (current_branch &&
155
+ !strcmp(ref->name, current_branch->name) &&
156
!(update_head_ok || is_bare_repository()) &&
157
!is_null_sha1(ref->old_sha1)) {
158
/*