Code

Allow builtin-fetch to work on a detached HEAD
authorShawn O. Pearce <spearce@spearce.org>
Sun, 16 Sep 2007 06:31:26 +0000 (02:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Sep 2007 10:22:31 +0000 (03:22 -0700)
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>
builtin-fetch.c

index 300d5635b09ff123918a2c5797c121223b8d70cb..d9272edae92921f51f139e5e60c89882f07bc362 100644 (file)
@@ -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)) {
                /*