Skip to content

Commit 8d3e33d

Browse files
bk2204gitster
authored andcommitted
t2060: add a test for switch with --orphan and --discard-changes
We have several code paths in the checkout code which are traversed only in this case, due to switch having different defaults from checkout. Let's add a test that the combination of options works and produces the expected behavior. Signed-off-by: brian m. carlson <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8186128 commit 8d3e33d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

t/t2060-switch.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ test_expect_success 'new orphan branch from empty' '
6868
test_cmp expected tracked-files
6969
'
7070

71+
test_expect_success 'orphan branch works with --discard-changes' '
72+
test_when_finished git switch master &&
73+
echo foo >foo.txt &&
74+
git switch --discard-changes --orphan new-orphan2 &&
75+
git ls-files >tracked-files &&
76+
test_must_be_empty tracked-files
77+
'
78+
7179
test_expect_success 'switching ignores file of same branch name' '
7280
test_when_finished git switch master &&
7381
: >first-branch &&

0 commit comments

Comments
 (0)