OSDN Git Service

Merge branch 'nd/worktree-kill-parse-ref'
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:08:23 +0000 (17:08 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:08:24 +0000 (17:08 +0900)
"git branch -M a b" while on a branch that is completely unrelated
to either branch a or branch b misbehaved when multiple worktree
was in use.  This has been fixed.

* nd/worktree-kill-parse-ref:
  branch: fix branch renaming not updating HEADs correctly

1  2 
branch.c
t/t3200-branch.sh
worktree.c

diff --cc branch.c
Simple merge
@@@ -162,16 -145,19 +162,29 @@@ test_expect_success 'git branch -M baz 
        grep "^0\{40\}.*$msg$" .git/logs/HEAD
  '
  
+ test_expect_success 'git branch -M should leave orphaned HEAD alone' '
+       git init orphan &&
+       (
+               cd orphan &&
+               test_commit initial &&
+               git checkout --orphan lonely &&
+               grep lonely .git/HEAD &&
+               test_path_is_missing .git/refs/head/lonely &&
+               git branch -M master mistress &&
+               grep lonely .git/HEAD
+       )
+ '
 +test_expect_success 'resulting reflog can be shown by log -g' '
 +      oid=$(git rev-parse HEAD) &&
 +      cat >expect <<-EOF &&
 +      HEAD@{0} $oid $msg
 +      HEAD@{2} $oid checkout: moving from foo to baz
 +      EOF
 +      git log -g --format="%gd %H %gs" -2 HEAD >actual &&
 +      test_cmp expect actual
 +'
 +
  test_expect_success 'git branch -M baz bam should succeed when baz is checked out as linked working tree' '
        git checkout master &&
        git worktree add -b baz bazdir &&
diff --cc worktree.c
Simple merge