summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-09-16 06:31:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-09-19 10:22:31 (GMT)
commitb3abdd9d216c578383b66bb10b95edb3380640e7 (patch)
treedd88b15779554faab706c0c5be033dec4f445b7b
parente5f4e214636f9c9bd36c2897634108d5ad5587a1 (diff)
downloadgit-b3abdd9d216c578383b66bb10b95edb3380640e7.zip
git-b3abdd9d216c578383b66bb10b95edb3380640e7.tar.gz
git-b3abdd9d216c578383b66bb10b95edb3380640e7.tar.bz2
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>
-rw-r--r--builtin-fetch.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 300d563..d9272ed 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -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)) {
/*