Skip to content

Commit bb8efa1

Browse files
sahildua2305gitster
authored andcommitted
t3200: add test for single parameter passed to -m option
Add a test for the case when only one parameter is passed to '-m' (move/rename) option. For example - if 'git branch -m bbb' is run while checked out on aaa branch, it should rename the currently checked out branch to bbb. There was no test for this particular case with only one parameter for -m option. However, there's one similar test case for -M option. Add test for making sure HEAD points to the bbb (new branch name). Also add a test for making sure the reflog that is moved to 'bbb' retains entries created for the currently checked out branch. Note that since the topmost entry on reflog for bbb will be about branch creation, we compare bbb@{1} (instead of bbb@{0}) with aaa@{0} to make sure the reflog for bbb retains entries from aaa. Signed-off-by: Sahil Dua <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7633952 commit bb8efa1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

t/t3200-branch.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,23 @@ test_expect_success 'git branch -m n/n n should work' '
100100
git reflog exists refs/heads/n
101101
'
102102

103+
# The topmost entry in reflog for branch bbb is about branch creation.
104+
# Hence, we compare bbb@{1} (instead of bbb@{0}) with aaa@{0}.
105+
106+
test_expect_success 'git branch -m bbb should rename checked out branch' '
107+
test_when_finished git branch -D bbb &&
108+
test_when_finished git checkout master &&
109+
git checkout -b aaa &&
110+
git commit --allow-empty -m "a new commit" &&
111+
git rev-parse aaa@{0} >expect &&
112+
git branch -m bbb &&
113+
git rev-parse bbb@{1} >actual &&
114+
test_cmp expect actual &&
115+
git symbolic-ref HEAD >actual &&
116+
echo refs/heads/bbb >expect &&
117+
test_cmp expect actual
118+
'
119+
103120
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
104121
git branch o/o &&
105122
git branch o/p &&

0 commit comments

Comments
 (0)