@@ -4,7 +4,13 @@ test_description='git checkout --patch'
44
55. ./lib-patch-mode.sh
66
7- test_expect_success PERL ' setup' '
7+ if ! test_bool_env GIT_TEST_ADD_I_USE_BUILTIN true && ! test_have_prereq PERL
8+ then
9+ skip_all=' skipping interactive add tests, PERL not set'
10+ test_done
11+ fi
12+
13+ test_expect_success ' setup' '
814 mkdir dir &&
915 echo parent > dir/foo &&
1016 echo dummy > bar &&
@@ -18,66 +24,62 @@ test_expect_success PERL 'setup' '
1824
1925# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
2026
21- # NEEDSWORK: Since the builtin add-p is used when $GIT_TEST_ADD_I_USE_BUILTIN
22- # is given, we should replace the PERL prerequisite with an ADD_I prerequisite
23- # which first checks if $GIT_TEST_ADD_I_USE_BUILTIN is defined before checking
24- # PERL.
25- test_expect_success PERL ' saying "n" does nothing' '
27+ test_expect_success ' saying "n" does nothing' '
2628 set_and_save_state dir/foo work head &&
2729 test_write_lines n n | git checkout -p &&
2830 verify_saved_state bar &&
2931 verify_saved_state dir/foo
3032'
3133
32- test_expect_success PERL ' git checkout -p' '
34+ test_expect_success ' git checkout -p' '
3335 test_write_lines n y | git checkout -p &&
3436 verify_saved_state bar &&
3537 verify_state dir/foo head head
3638'
3739
38- test_expect_success PERL ' git checkout -p with staged changes' '
40+ test_expect_success ' git checkout -p with staged changes' '
3941 set_state dir/foo work index &&
4042 test_write_lines n y | git checkout -p &&
4143 verify_saved_state bar &&
4244 verify_state dir/foo index index
4345'
4446
45- test_expect_success PERL ' git checkout -p HEAD with NO staged changes: abort' '
47+ test_expect_success ' git checkout -p HEAD with NO staged changes: abort' '
4648 set_and_save_state dir/foo work head &&
4749 test_write_lines n y n | git checkout -p HEAD &&
4850 verify_saved_state bar &&
4951 verify_saved_state dir/foo
5052'
5153
52- test_expect_success PERL ' git checkout -p HEAD with NO staged changes: apply' '
54+ test_expect_success ' git checkout -p HEAD with NO staged changes: apply' '
5355 test_write_lines n y y | git checkout -p HEAD &&
5456 verify_saved_state bar &&
5557 verify_state dir/foo head head
5658'
5759
58- test_expect_success PERL ' git checkout -p HEAD with change already staged' '
60+ test_expect_success ' git checkout -p HEAD with change already staged' '
5961 set_state dir/foo index index &&
6062 # the third n is to get out in case it mistakenly does not apply
6163 test_write_lines n y n | git checkout -p HEAD &&
6264 verify_saved_state bar &&
6365 verify_state dir/foo head head
6466'
6567
66- test_expect_success PERL ' git checkout -p HEAD^...' '
68+ test_expect_success ' git checkout -p HEAD^...' '
6769 # the third n is to get out in case it mistakenly does not apply
6870 test_write_lines n y n | git checkout -p HEAD^... &&
6971 verify_saved_state bar &&
7072 verify_state dir/foo parent parent
7173'
7274
73- test_expect_success PERL ' git checkout -p HEAD^' '
75+ test_expect_success ' git checkout -p HEAD^' '
7476 # the third n is to get out in case it mistakenly does not apply
7577 test_write_lines n y n | git checkout -p HEAD^ &&
7678 verify_saved_state bar &&
7779 verify_state dir/foo parent parent
7880'
7981
80- test_expect_success PERL ' git checkout -p handles deletion' '
82+ test_expect_success ' git checkout -p handles deletion' '
8183 set_state dir/foo work index &&
8284 rm dir/foo &&
8385 test_write_lines n y | git checkout -p &&
@@ -90,40 +92,40 @@ test_expect_success PERL 'git checkout -p handles deletion' '
9092# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
9193# the failure case (and thus get out of the loop).
9294
93- test_expect_success PERL ' path limiting works: dir' '
95+ test_expect_success ' path limiting works: dir' '
9496 set_state dir/foo work head &&
9597 test_write_lines y n | git checkout -p dir &&
9698 verify_saved_state bar &&
9799 verify_state dir/foo head head
98100'
99101
100- test_expect_success PERL ' path limiting works: -- dir' '
102+ test_expect_success ' path limiting works: -- dir' '
101103 set_state dir/foo work head &&
102104 test_write_lines y n | git checkout -p -- dir &&
103105 verify_saved_state bar &&
104106 verify_state dir/foo head head
105107'
106108
107- test_expect_success PERL ' path limiting works: HEAD^ -- dir' '
109+ test_expect_success ' path limiting works: HEAD^ -- dir' '
108110 # the third n is to get out in case it mistakenly does not apply
109111 test_write_lines y n n | git checkout -p HEAD^ -- dir &&
110112 verify_saved_state bar &&
111113 verify_state dir/foo parent parent
112114'
113115
114- test_expect_success PERL ' path limiting works: foo inside dir' '
116+ test_expect_success ' path limiting works: foo inside dir' '
115117 set_state dir/foo work head &&
116118 # the third n is to get out in case it mistakenly does not apply
117119 test_write_lines y n n | (cd dir && git checkout -p foo) &&
118120 verify_saved_state bar &&
119121 verify_state dir/foo head head
120122'
121123
122- test_expect_success PERL ' none of this moved HEAD' '
124+ test_expect_success ' none of this moved HEAD' '
123125 verify_saved_head
124126'
125127
126- test_expect_success PERL ' empty tree can be handled' '
128+ test_expect_success ' empty tree can be handled' '
127129 test_when_finished "git reset --hard" &&
128130 git checkout -p $(test_oid empty_tree) --
129131'
0 commit comments