Skip to content

Commit

Permalink
Allow builtin-fetch to work on a detached HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Sep 19, 2007
1 parent e5f4e21 commit b3abdd9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion builtin-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ static int update_local_ref(struct ref *ref,
return 0;
}

if (!strcmp(ref->name, current_branch->name) &&
if (current_branch &&
!strcmp(ref->name, current_branch->name) &&
!(update_head_ok || is_bare_repository()) &&
!is_null_sha1(ref->old_sha1)) {
/*
Expand Down

0 comments on commit b3abdd9

Please sign in to comment.