Skip to content

Commit 6978ec5

Browse files
committed
Merge branch 'js/use-builtin-add-i' into seen
"git add -i" was rewritten in C some time ago and has been in testing; the reimplementation is now exposed to general public by default. * js/use-builtin-add-i: add -i: default to the built-in implementation t2016: require the PERL prereq only when necessary
2 parents f838eb0 + 0527ccb commit 6978ec5

File tree

5 files changed

+32
-35
lines changed

5 files changed

+32
-35
lines changed

Documentation/config/add.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ add.ignore-errors (deprecated)::
77
variables.
88

99
add.interactive.useBuiltin::
10-
[EXPERIMENTAL] Set to `true` to use the experimental built-in
11-
implementation of the interactive version of linkgit:git-add[1]
12-
instead of the Perl script version. Is `false` by default.
10+
Set to `false` to fall back to the original Perl implementation of
11+
the interactive version of linkgit:git-add[1] instead of the built-in
12+
version. Is `true` by default.

builtin/add.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,12 @@ int run_add_interactive(const char *revision, const char *patch_mode,
245245
int use_builtin_add_i =
246246
git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1);
247247

248-
if (use_builtin_add_i < 0) {
249-
int experimental;
250-
if (!git_config_get_bool("add.interactive.usebuiltin",
251-
&use_builtin_add_i))
252-
; /* ok */
253-
else if (!git_config_get_bool("feature.experimental", &experimental) &&
254-
experimental)
255-
use_builtin_add_i = 1;
256-
}
248+
if (use_builtin_add_i < 0 &&
249+
git_config_get_bool("add.interactive.usebuiltin",
250+
&use_builtin_add_i))
251+
use_builtin_add_i = 1;
257252

258-
if (use_builtin_add_i == 1) {
253+
if (use_builtin_add_i != 0) {
259254
enum add_p_mode mode;
260255

261256
if (!patch_mode)

ci/run-build-and-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ linux-TEST-vars)
2626
export GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1
2727
export GIT_TEST_MULTI_PACK_INDEX=1
2828
export GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=1
29-
export GIT_TEST_ADD_I_USE_BUILTIN=1
29+
export GIT_TEST_ADD_I_USE_BUILTIN=0
3030
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
3131
export GIT_TEST_WRITE_REV_INDEX=1
3232
export GIT_TEST_CHECKOUT_WORKERS=2

t/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ the --sparse command-line argument.
419419
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
420420
by overriding the minimum number of cache entries required per thread.
421421

422-
GIT_TEST_ADD_I_USE_BUILTIN=<boolean>, when true, enables the
422+
GIT_TEST_ADD_I_USE_BUILTIN=<boolean>, when false, disables the
423423
built-in version of git add -i. See 'add.interactive.useBuiltin' in
424424
git-config(1).
425425

t/t2016-checkout-patch.sh

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)