Skip to content

Commit b3abdd9

Browse files
spearcegitster
authored andcommitted
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>
1 parent e5f4e21 commit b3abdd9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin-fetch.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ static int update_local_ref(struct ref *ref,
151151
return 0;
152152
}
153153

154-
if (!strcmp(ref->name, current_branch->name) &&
154+
if (current_branch &&
155+
!strcmp(ref->name, current_branch->name) &&
155156
!(update_head_ok || is_bare_repository()) &&
156157
!is_null_sha1(ref->old_sha1)) {
157158
/*

0 commit comments

Comments
 (0)