Skip to contentSkip to conversation

Allow builtin-fetch to work on a detached HEAD

PATCH In review Shawn O. Pearce 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 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.

---
 builtin-fetch.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
builtin-fetch.c +2 -1
index 300d563..d9272ed 100644
@@ -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)) {
 		/*
Signature · 1 line
1.5.3.1.1000.g7319b