From: Junio C Hamano Date: Thu, 15 Mar 2018 22:11:02 +0000 (-0700) Subject: Merge branch 'ks/t3200-typofix' into next X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8b8d397787fd243a90414ea444ac83a0c9f177a1?ds=inline;hp=-c Merge branch 'ks/t3200-typofix' into next Test typofix. * ks/t3200-typofix: t/t3200: fix a typo in a test description --- 8b8d397787fd243a90414ea444ac83a0c9f177a1 diff --combined t/t3200-branch.sh index 503a88d029,e6b9a210d2..6c0b7ea4ad --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@@ -100,33 -100,6 +100,33 @@@ test_expect_success 'git branch -m n/n git reflog exists refs/heads/n ' +# The topmost entry in reflog for branch bbb is about branch creation. +# Hence, we compare bbb@{1} (instead of bbb@{0}) with aaa@{0}. + +test_expect_success 'git branch -m bbb should rename checked out branch' ' + test_when_finished git branch -D bbb && + test_when_finished git checkout master && + git checkout -b aaa && + git commit --allow-empty -m "a new commit" && + git rev-parse aaa@{0} >expect && + git branch -m bbb && + git rev-parse bbb@{1} >actual && + test_cmp expect actual && + git symbolic-ref HEAD >actual && + echo refs/heads/bbb >expect && + test_cmp expect actual +' + +test_expect_success 'renaming checked out branch works with d/f conflict' ' + test_when_finished "git branch -D foo/bar || git branch -D foo" && + test_when_finished git checkout master && + git checkout -b foo && + git branch -m foo/bar && + git symbolic-ref HEAD >actual && + echo refs/heads/foo/bar >expect && + test_cmp expect actual +' + test_expect_success 'git branch -m o/o o should fail when o/p exists' ' git branch o/o && git branch o/p && @@@ -172,29 -145,6 +172,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 && @@@ -472,7 -422,7 +472,7 @@@ test_expect_success 'git branch --copy test_cmp expect actual ' -test_expect_success 'git branch -c ee ef should copy and checkout branch ef' ' +test_expect_success 'git branch -c ee ef should copy ee to create branch ef' ' git checkout -b ee && git reflog exists refs/heads/ee && git config branch.ee.dummy Hello && @@@ -481,7 -431,7 +481,7 @@@ git reflog exists refs/heads/ef && test $(git config branch.ee.dummy) = Hello && test $(git config branch.ef.dummy) = Hello && - test $(git rev-parse --abbrev-ref HEAD) = ef + test $(git rev-parse --abbrev-ref HEAD) = ee ' test_expect_success 'git branch -c f/f g/g should work' ' @@@ -528,7 -478,7 +528,7 @@@ test_expect_success 'git branch -c -f o git branch -c -f o/q o/p ' - test_expect_success 'git branch -c qq rr/qq should fail when r exists' ' + test_expect_success 'git branch -c qq rr/qq should fail when rr exists' ' git branch qq && git branch rr && test_must_fail git branch -c qq rr/qq @@@ -544,12 -494,12 +544,12 @@@ test_expect_success 'git branch -C c1 c git checkout -b c1 && git branch c2 && git branch -C c1 c2 && - test $(git rev-parse --abbrev-ref HEAD) = c2 + test $(git rev-parse --abbrev-ref HEAD) = c1 ' -test_expect_success 'git branch -C c1 c2 should add entries to .git/logs/HEAD' ' +test_expect_success 'git branch -C c1 c2 should never touch HEAD' ' msg="Branch: copied refs/heads/c1 to refs/heads/c2" && - grep "$msg$" .git/logs/HEAD + ! grep "$msg$" .git/logs/HEAD ' test_expect_success 'git branch -C master should work when master is checked out' ' @@@ -838,7 -788,6 +838,7 @@@ test_expect_success 'use --set-upstream test_expect_success 'use --set-upstream-to modify a particular branch' ' git branch my13 && git branch --set-upstream-to master my13 && + test_when_finished "git branch --unset-upstream my13" && test "$(git config branch.my13.remote)" = "." && test "$(git config branch.my13.merge)" = "refs/heads/master" ' @@@ -884,8 -833,38 +884,8 @@@ test_expect_success 'test --unset-upstr test_must_fail git config branch.my14.merge ' -test_expect_success '--set-upstream shows message when creating a new branch that exists as remote-tracking' ' - git update-ref refs/remotes/origin/master HEAD && - git branch --set-upstream origin/master 2>actual && - test_when_finished git update-ref -d refs/remotes/origin/master && - test_when_finished git branch -d origin/master && - cat >expected <actual && - test_when_finished git branch --unset-upstream master && - cat >expected <actual && - test_when_finished git branch --unset-upstream my13 && - cat >expected <"$1"