@matheusbsbs / matheus-bagliano / commits / 8d3e33dadd
Fork 0

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 <sandals@crustytoothpaste.net> Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 21, 2020 at 02:07 UTC 8d3e33dadd359495e43cb65dfadd775987e3da26
1 file changed +8
t/t2060-switch.sh
+8
@@ -68,6 +68,14 @@ test_expect_success 'new orphan branch from empty' '
68 test_cmp expected tracked-files
69 '
70
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 +
79 test_expect_success 'switching ignores file of same branch name' '
80 test_when_finished git switch master &&
81 : >first-branch &&