@@ -4,7 +4,13 @@ test_description='git checkout --patch'
4
4
5
5
. ./lib-patch-mode.sh
6
6
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' '
8
14
mkdir dir &&
9
15
echo parent > dir/foo &&
10
16
echo dummy > bar &&
@@ -18,66 +24,62 @@ test_expect_success PERL 'setup' '
18
24
19
25
# note: bar sorts before dir/foo, so the first 'n' is always to skip 'bar'
20
26
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' '
26
28
set_and_save_state dir/foo work head &&
27
29
test_write_lines n n | git checkout -p &&
28
30
verify_saved_state bar &&
29
31
verify_saved_state dir/foo
30
32
'
31
33
32
- test_expect_success PERL ' git checkout -p' '
34
+ test_expect_success ' git checkout -p' '
33
35
test_write_lines n y | git checkout -p &&
34
36
verify_saved_state bar &&
35
37
verify_state dir/foo head head
36
38
'
37
39
38
- test_expect_success PERL ' git checkout -p with staged changes' '
40
+ test_expect_success ' git checkout -p with staged changes' '
39
41
set_state dir/foo work index &&
40
42
test_write_lines n y | git checkout -p &&
41
43
verify_saved_state bar &&
42
44
verify_state dir/foo index index
43
45
'
44
46
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' '
46
48
set_and_save_state dir/foo work head &&
47
49
test_write_lines n y n | git checkout -p HEAD &&
48
50
verify_saved_state bar &&
49
51
verify_saved_state dir/foo
50
52
'
51
53
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' '
53
55
test_write_lines n y y | git checkout -p HEAD &&
54
56
verify_saved_state bar &&
55
57
verify_state dir/foo head head
56
58
'
57
59
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' '
59
61
set_state dir/foo index index &&
60
62
# the third n is to get out in case it mistakenly does not apply
61
63
test_write_lines n y n | git checkout -p HEAD &&
62
64
verify_saved_state bar &&
63
65
verify_state dir/foo head head
64
66
'
65
67
66
- test_expect_success PERL ' git checkout -p HEAD^...' '
68
+ test_expect_success ' git checkout -p HEAD^...' '
67
69
# the third n is to get out in case it mistakenly does not apply
68
70
test_write_lines n y n | git checkout -p HEAD^... &&
69
71
verify_saved_state bar &&
70
72
verify_state dir/foo parent parent
71
73
'
72
74
73
- test_expect_success PERL ' git checkout -p HEAD^' '
75
+ test_expect_success ' git checkout -p HEAD^' '
74
76
# the third n is to get out in case it mistakenly does not apply
75
77
test_write_lines n y n | git checkout -p HEAD^ &&
76
78
verify_saved_state bar &&
77
79
verify_state dir/foo parent parent
78
80
'
79
81
80
- test_expect_success PERL ' git checkout -p handles deletion' '
82
+ test_expect_success ' git checkout -p handles deletion' '
81
83
set_state dir/foo work index &&
82
84
rm dir/foo &&
83
85
test_write_lines n y | git checkout -p &&
@@ -90,40 +92,40 @@ test_expect_success PERL 'git checkout -p handles deletion' '
90
92
# dir/foo. There's always an extra 'n' to reject edits to dir/foo in
91
93
# the failure case (and thus get out of the loop).
92
94
93
- test_expect_success PERL ' path limiting works: dir' '
95
+ test_expect_success ' path limiting works: dir' '
94
96
set_state dir/foo work head &&
95
97
test_write_lines y n | git checkout -p dir &&
96
98
verify_saved_state bar &&
97
99
verify_state dir/foo head head
98
100
'
99
101
100
- test_expect_success PERL ' path limiting works: -- dir' '
102
+ test_expect_success ' path limiting works: -- dir' '
101
103
set_state dir/foo work head &&
102
104
test_write_lines y n | git checkout -p -- dir &&
103
105
verify_saved_state bar &&
104
106
verify_state dir/foo head head
105
107
'
106
108
107
- test_expect_success PERL ' path limiting works: HEAD^ -- dir' '
109
+ test_expect_success ' path limiting works: HEAD^ -- dir' '
108
110
# the third n is to get out in case it mistakenly does not apply
109
111
test_write_lines y n n | git checkout -p HEAD^ -- dir &&
110
112
verify_saved_state bar &&
111
113
verify_state dir/foo parent parent
112
114
'
113
115
114
- test_expect_success PERL ' path limiting works: foo inside dir' '
116
+ test_expect_success ' path limiting works: foo inside dir' '
115
117
set_state dir/foo work head &&
116
118
# the third n is to get out in case it mistakenly does not apply
117
119
test_write_lines y n n | (cd dir && git checkout -p foo) &&
118
120
verify_saved_state bar &&
119
121
verify_state dir/foo head head
120
122
'
121
123
122
- test_expect_success PERL ' none of this moved HEAD' '
124
+ test_expect_success ' none of this moved HEAD' '
123
125
verify_saved_head
124
126
'
125
127
126
- test_expect_success PERL ' empty tree can be handled' '
128
+ test_expect_success ' empty tree can be handled' '
127
129
test_when_finished "git reset --hard" &&
128
130
git checkout -p $(test_oid empty_tree) --
129
131
'
0 commit comments