{"thread":{"id":"9874","subject":"[PATCH 1/3] Allow builtin-fetch to work on a detached HEAD","startedAt":"2007-09-16T06:31:26Z","lastAt":"2007-09-16T06:31:26Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"53169","messageId":"20070916063126.GA6487@spearce.org","threadId":"9874","inReplyTo":null,"subject":"[PATCH 1/3] Allow builtin-fetch to work on a detached HEAD","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-16T06:31:26Z","receivedAt":"2007-09-16T06:31:26Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If we are running fetch in a repository that has a detached HEAD\nthen there is no current_branch available.  In such a case any ref\nthat the fetch might update by definition cannot also be the current\nbranch so we should always bypass the \"don't update HEAD\" test.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n builtin-fetch.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 300d563..d9272ed 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -151,7 +151,8 @@ static int update_local_ref(struct ref *ref,\n \t\treturn 0;\n \t}\n \n-\tif (!strcmp(ref->name, current_branch->name) &&\n+\tif (current_branch &&\n+\t    !strcmp(ref->name, current_branch->name) &&\n \t    !(update_head_ok || is_bare_repository()) &&\n \t    !is_null_sha1(ref->old_sha1)) {\n \t\t/*\n-- \n1.5.3.1.1000.g7319b\n"}]}