difftool: retire the scripted version
It served its purpose, but now we have a builtin difftool. Time for the Perl script to enjoy Florida. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jan 19, 2017 at 21:30 UTC
019678d6b1f83419cdc35e3d455175adce3a379c
6 files changed
+47
-97
.gitignore
-1
@@ -76,7 +76,6 @@
76
/git-init-db
77
/git-interpret-trailers
78
/git-instaweb
79
-/git-legacy-difftool
79
/git-log
80
/git-ls-files
81
/git-ls-remote
Makefile
-1
@@ -527,7 +527,6 @@ SCRIPT_LIB += git-sh-setup
527
SCRIPT_LIB += git-sh-i18n
528
529
SCRIPT_PERL += git-add--interactive.perl
530
-SCRIPT_PERL += git-legacy-difftool.perl
530
SCRIPT_PERL += git-archimport.perl
531
SCRIPT_PERL += git-cvsexportcommit.perl
532
SCRIPT_PERL += git-cvsimport.perl
builtin/difftool.c
-41
@@ -616,30 +616,6 @@ static int run_file_diff(int prompt, const char *prefix,
616
exit(ret);
617
}
618
619
-/*
620
- * NEEDSWORK: this function can go once the legacy-difftool Perl script is
621
- * retired.
622
- *
623
- * We intentionally avoid reading the config directly here, to avoid messing up
624
- * the GIT_* environment variables when we need to fall back to exec()ing the
625
- * Perl script.
626
- */
627
-static int use_builtin_difftool(void) {
628
- struct child_process cp = CHILD_PROCESS_INIT;
629
- struct strbuf out = STRBUF_INIT;
630
- int ret;
631
-
632
- argv_array_pushl(&cp.args,
633
- "config", "--bool", "difftool.usebuiltin", NULL);
634
- cp.git_cmd = 1;
635
- if (capture_command(&cp, &out, 6))
636
- return 0;
637
- strbuf_trim(&out);
638
- ret = !strcmp("true", out.buf);
639
- strbuf_release(&out);
640
- return ret;
641
-}
642
-
619
int cmd_difftool(int argc, const char **argv, const char *prefix)
620
{
621
int use_gui_tool = 0, dir_diff = 0, prompt = -1, symlinks = 0,
@@ -671,23 +647,6 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
647
OPT_END()
648
};
649
674
- /*
675
- * NEEDSWORK: Once the builtin difftool has been tested enough
676
- * and git-legacy-difftool.perl is retired to contrib/, this preamble
677
- * can be removed.
678
- */
679
- if (!use_builtin_difftool()) {
680
- const char *path = mkpath("%s/git-legacy-difftool",
681
- git_exec_path());
682
-
683
- if (sane_execvp(path, (char **)argv) < 0)
684
- die_errno("could not exec %s", path);
685
-
686
- return 0;
687
- }
688
- prefix = setup_git_directory();
689
- trace_repo_setup(prefix);
690
- setup_work_tree();
650
/* NEEDSWORK: once we no longer spawn anything, remove this */
651
setenv(GIT_DIR_ENVIRONMENT, absolute_path(get_git_dir()), 1);
652
setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(get_git_work_tree()), 1);
contrib/examples/git-difftool.perl
renamed
git.c
+1
-6
@@ -424,12 +424,7 @@ static struct cmd_struct commands[] = {
424
{ "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE },
425
{ "diff-index", cmd_diff_index, RUN_SETUP },
426
{ "diff-tree", cmd_diff_tree, RUN_SETUP },
427
- /*
428
- * NEEDSWORK: Once the redirection to git-legacy-difftool.perl in
429
- * builtin/difftool.c has been removed, this entry should be changed to
430
- * RUN_SETUP | NEED_WORK_TREE
431
- */
432
- { "difftool", cmd_difftool },
427
+ { "difftool", cmd_difftool, RUN_SETUP | NEED_WORK_TREE },
428
{ "fast-export", cmd_fast_export, RUN_SETUP },
429
{ "fetch", cmd_fetch, RUN_SETUP },
430
{ "fetch-pack", cmd_fetch_pack, RUN_SETUP },
t/t7800-difftool.sh
+46
-48
@@ -23,10 +23,8 @@ prompt_given ()
23
test "$prompt" = "Launch 'test-tool' [Y/n]? branch"
24
}
25
26
-# NEEDSWORK: lose all the PERL prereqs once legacy-difftool is retired.
27
-
26
# Create a file on master and change it on branch
29
-test_expect_success PERL 'setup' '
27
+test_expect_success 'setup' '
28
echo master >file &&
29
git add file &&
30
git commit -m "added file" &&
@@ -38,7 +36,7 @@ test_expect_success PERL 'setup' '
36
'
37
38
# Configure a custom difftool.<tool>.cmd and use it
41
-test_expect_success PERL 'custom commands' '
39
+test_expect_success 'custom commands' '
40
difftool_test_setup &&
41
test_config difftool.test-tool.cmd "cat \"\$REMOTE\"" &&
42
echo master >expect &&
@@ -51,21 +49,21 @@ test_expect_success PERL 'custom commands' '
49
test_cmp expect actual
50
'
51
54
-test_expect_success PERL 'custom tool commands override built-ins' '
52
+test_expect_success 'custom tool commands override built-ins' '
53
test_config difftool.vimdiff.cmd "cat \"\$REMOTE\"" &&
54
echo master >expect &&
55
git difftool --tool vimdiff --no-prompt branch >actual &&
56
test_cmp expect actual
57
'
58
61
-test_expect_success PERL 'difftool ignores bad --tool values' '
59
+test_expect_success 'difftool ignores bad --tool values' '
60
: >expect &&
61
test_must_fail \
62
git difftool --no-prompt --tool=bad-tool branch >actual &&
63
test_cmp expect actual
64
'
65
68
-test_expect_success PERL 'difftool forwards arguments to diff' '
66
+test_expect_success 'difftool forwards arguments to diff' '
67
difftool_test_setup &&
68
>for-diff &&
69
git add for-diff &&
@@ -78,40 +76,40 @@ test_expect_success PERL 'difftool forwards arguments to diff' '
76
rm for-diff
77
'
78
81
-test_expect_success PERL 'difftool ignores exit code' '
79
+test_expect_success 'difftool ignores exit code' '
80
test_config difftool.error.cmd false &&
81
git difftool -y -t error branch
82
'
83
86
-test_expect_success PERL 'difftool forwards exit code with --trust-exit-code' '
84
+test_expect_success 'difftool forwards exit code with --trust-exit-code' '
85
test_config difftool.error.cmd false &&
86
test_must_fail git difftool -y --trust-exit-code -t error branch
87
'
88
91
-test_expect_success PERL 'difftool forwards exit code with --trust-exit-code for built-ins' '
89
+test_expect_success 'difftool forwards exit code with --trust-exit-code for built-ins' '
90
test_config difftool.vimdiff.path false &&
91
test_must_fail git difftool -y --trust-exit-code -t vimdiff branch
92
'
93
96
-test_expect_success PERL 'difftool honors difftool.trustExitCode = true' '
94
+test_expect_success 'difftool honors difftool.trustExitCode = true' '
95
test_config difftool.error.cmd false &&
96
test_config difftool.trustExitCode true &&
97
test_must_fail git difftool -y -t error branch
98
'
99
102
-test_expect_success PERL 'difftool honors difftool.trustExitCode = false' '
100
+test_expect_success 'difftool honors difftool.trustExitCode = false' '
101
test_config difftool.error.cmd false &&
102
test_config difftool.trustExitCode false &&
103
git difftool -y -t error branch
104
'
105
108
-test_expect_success PERL 'difftool ignores exit code with --no-trust-exit-code' '
106
+test_expect_success 'difftool ignores exit code with --no-trust-exit-code' '
107
test_config difftool.error.cmd false &&
108
test_config difftool.trustExitCode true &&
109
git difftool -y --no-trust-exit-code -t error branch
110
'
111
114
-test_expect_success PERL 'difftool stops on error with --trust-exit-code' '
112
+test_expect_success 'difftool stops on error with --trust-exit-code' '
113
test_when_finished "rm -f for-diff .git/fail-right-file" &&
114
test_when_finished "git reset -- for-diff" &&
115
write_script .git/fail-right-file <<-\EOF &&
@@ -126,13 +124,13 @@ test_expect_success PERL 'difftool stops on error with --trust-exit-code' '
124
test_cmp expect actual
125
'
126
129
-test_expect_success PERL 'difftool honors exit status if command not found' '
127
+test_expect_success 'difftool honors exit status if command not found' '
128
test_config difftool.nonexistent.cmd i-dont-exist &&
129
test_config difftool.trustExitCode false &&
130
test_must_fail git difftool -y -t nonexistent branch
131
'
132
135
-test_expect_success PERL 'difftool honors --gui' '
133
+test_expect_success 'difftool honors --gui' '
134
difftool_test_setup &&
135
test_config merge.tool bogus-tool &&
136
test_config diff.tool bogus-tool &&
@@ -143,7 +141,7 @@ test_expect_success PERL 'difftool honors --gui' '
141
test_cmp expect actual
142
'
143
146
-test_expect_success PERL 'difftool --gui last setting wins' '
144
+test_expect_success 'difftool --gui last setting wins' '
145
difftool_test_setup &&
146
: >expect &&
147
git difftool --no-prompt --gui --no-gui >actual &&
@@ -157,7 +155,7 @@ test_expect_success PERL 'difftool --gui last setting wins' '
155
test_cmp expect actual
156
'
157
160
-test_expect_success PERL 'difftool --gui works without configured diff.guitool' '
158
+test_expect_success 'difftool --gui works without configured diff.guitool' '
159
difftool_test_setup &&
160
echo branch >expect &&
161
git difftool --no-prompt --gui branch >actual &&
@@ -165,7 +163,7 @@ test_expect_success PERL 'difftool --gui works without configured diff.guitool'
163
'
164
165
# Specify the diff tool using $GIT_DIFF_TOOL
168
-test_expect_success PERL 'GIT_DIFF_TOOL variable' '
166
+test_expect_success 'GIT_DIFF_TOOL variable' '
167
difftool_test_setup &&
168
git config --unset diff.tool &&
169
echo branch >expect &&
@@ -175,7 +173,7 @@ test_expect_success PERL 'GIT_DIFF_TOOL variable' '
173
174
# Test the $GIT_*_TOOL variables and ensure
175
# that $GIT_DIFF_TOOL always wins unless --tool is specified
178
-test_expect_success PERL 'GIT_DIFF_TOOL overrides' '
176
+test_expect_success 'GIT_DIFF_TOOL overrides' '
177
difftool_test_setup &&
178
test_config diff.tool bogus-tool &&
179
test_config merge.tool bogus-tool &&
@@ -193,7 +191,7 @@ test_expect_success PERL 'GIT_DIFF_TOOL overrides' '
191
192
# Test that we don't have to pass --no-prompt to difftool
193
# when $GIT_DIFFTOOL_NO_PROMPT is true
196
-test_expect_success PERL 'GIT_DIFFTOOL_NO_PROMPT variable' '
194
+test_expect_success 'GIT_DIFFTOOL_NO_PROMPT variable' '
195
difftool_test_setup &&
196
echo branch >expect &&
197
GIT_DIFFTOOL_NO_PROMPT=true git difftool branch >actual &&
@@ -202,7 +200,7 @@ test_expect_success PERL 'GIT_DIFFTOOL_NO_PROMPT variable' '
200
201
# git-difftool supports the difftool.prompt variable.
202
# Test that GIT_DIFFTOOL_PROMPT can override difftool.prompt = false
205
-test_expect_success PERL 'GIT_DIFFTOOL_PROMPT variable' '
203
+test_expect_success 'GIT_DIFFTOOL_PROMPT variable' '
204
difftool_test_setup &&
205
test_config difftool.prompt false &&
206
echo >input &&
@@ -212,7 +210,7 @@ test_expect_success PERL 'GIT_DIFFTOOL_PROMPT variable' '
210
'
211
212
# Test that we don't have to pass --no-prompt when difftool.prompt is false
215
-test_expect_success PERL 'difftool.prompt config variable is false' '
213
+test_expect_success 'difftool.prompt config variable is false' '
214
difftool_test_setup &&
215
test_config difftool.prompt false &&
216
echo branch >expect &&
@@ -221,7 +219,7 @@ test_expect_success PERL 'difftool.prompt config variable is false' '
219
'
220
221
# Test that we don't have to pass --no-prompt when mergetool.prompt is false
224
-test_expect_success PERL 'difftool merge.prompt = false' '
222
+test_expect_success 'difftool merge.prompt = false' '
223
difftool_test_setup &&
224
test_might_fail git config --unset difftool.prompt &&
225
test_config mergetool.prompt false &&
@@ -231,7 +229,7 @@ test_expect_success PERL 'difftool merge.prompt = false' '
229
'
230
231
# Test that the -y flag can override difftool.prompt = true
234
-test_expect_success PERL 'difftool.prompt can overridden with -y' '
232
+test_expect_success 'difftool.prompt can overridden with -y' '
233
difftool_test_setup &&
234
test_config difftool.prompt true &&
235
echo branch >expect &&
@@ -240,7 +238,7 @@ test_expect_success PERL 'difftool.prompt can overridden with -y' '
238
'
239
240
# Test that the --prompt flag can override difftool.prompt = false
243
-test_expect_success PERL 'difftool.prompt can overridden with --prompt' '
241
+test_expect_success 'difftool.prompt can overridden with --prompt' '
242
difftool_test_setup &&
243
test_config difftool.prompt false &&
244
echo >input &&
@@ -250,7 +248,7 @@ test_expect_success PERL 'difftool.prompt can overridden with --prompt' '
248
'
249
250
# Test that the last flag passed on the command-line wins
253
-test_expect_success PERL 'difftool last flag wins' '
251
+test_expect_success 'difftool last flag wins' '
252
difftool_test_setup &&
253
echo branch >expect &&
254
git difftool --prompt --no-prompt branch >actual &&
@@ -263,7 +261,7 @@ test_expect_success PERL 'difftool last flag wins' '
261
262
# git-difftool falls back to git-mergetool config variables
263
# so test that behavior here
266
-test_expect_success PERL 'difftool + mergetool config variables' '
264
+test_expect_success 'difftool + mergetool config variables' '
265
test_config merge.tool test-tool &&
266
test_config mergetool.test-tool.cmd "cat \$LOCAL" &&
267
echo branch >expect &&
@@ -277,49 +275,49 @@ test_expect_success PERL 'difftool + mergetool config variables' '
275
test_cmp expect actual
276
'
277
280
-test_expect_success PERL 'difftool.<tool>.path' '
278
+test_expect_success 'difftool.<tool>.path' '
279
test_config difftool.tkdiff.path echo &&
280
git difftool --tool=tkdiff --no-prompt branch >output &&
281
lines=$(grep file output | wc -l) &&
282
test "$lines" -eq 1
283
'
284
287
-test_expect_success PERL 'difftool --extcmd=cat' '
285
+test_expect_success 'difftool --extcmd=cat' '
286
echo branch >expect &&
287
echo master >>expect &&
288
git difftool --no-prompt --extcmd=cat branch >actual &&
289
test_cmp expect actual
290
'
291
294
-test_expect_success PERL 'difftool --extcmd cat' '
292
+test_expect_success 'difftool --extcmd cat' '
293
echo branch >expect &&
294
echo master >>expect &&
295
git difftool --no-prompt --extcmd=cat branch >actual &&
296
test_cmp expect actual
297
'
298
301
-test_expect_success PERL 'difftool -x cat' '
299
+test_expect_success 'difftool -x cat' '
300
echo branch >expect &&
301
echo master >>expect &&
302
git difftool --no-prompt -x cat branch >actual &&
303
test_cmp expect actual
304
'
305
308
-test_expect_success PERL 'difftool --extcmd echo arg1' '
306
+test_expect_success 'difftool --extcmd echo arg1' '
307
echo file >expect &&
308
git difftool --no-prompt \
309
--extcmd sh\ -c\ \"echo\ \$1\" branch >actual &&
310
test_cmp expect actual
311
'
312
315
-test_expect_success PERL 'difftool --extcmd cat arg1' '
313
+test_expect_success 'difftool --extcmd cat arg1' '
314
echo master >expect &&
315
git difftool --no-prompt \
316
--extcmd sh\ -c\ \"cat\ \$1\" branch >actual &&
317
test_cmp expect actual
318
'
319
322
-test_expect_success PERL 'difftool --extcmd cat arg2' '
320
+test_expect_success 'difftool --extcmd cat arg2' '
321
echo branch >expect &&
322
git difftool --no-prompt \
323
--extcmd sh\ -c\ \"cat\ \$2\" branch >actual &&
@@ -327,7 +325,7 @@ test_expect_success PERL 'difftool --extcmd cat arg2' '
325
'
326
327
# Create a second file on master and a different version on branch
330
-test_expect_success PERL 'setup with 2 files different' '
328
+test_expect_success 'setup with 2 files different' '
329
echo m2 >file2 &&
330
git add file2 &&
331
git commit -m "added file2" &&
@@ -339,7 +337,7 @@ test_expect_success PERL 'setup with 2 files different' '
337
git checkout master
338
'
339
342
-test_expect_success PERL 'say no to the first file' '
340
+test_expect_success 'say no to the first file' '
341
(echo n && echo) >input &&
342
git difftool -x cat branch <input >output &&
343
grep m2 output &&
@@ -348,7 +346,7 @@ test_expect_success PERL 'say no to the first file' '
346
! grep branch output
347
'
348
351
-test_expect_success PERL 'say no to the second file' '
349
+test_expect_success 'say no to the second file' '
350
(echo && echo n) >input &&
351
git difftool -x cat branch <input >output &&
352
grep master output &&
@@ -357,7 +355,7 @@ test_expect_success PERL 'say no to the second file' '
355
! grep br2 output
356
'
357
360
-test_expect_success PERL 'ending prompt input with EOF' '
358
+test_expect_success 'ending prompt input with EOF' '
359
git difftool -x cat branch </dev/null >output &&
360
! grep master output &&
361
! grep branch output &&
@@ -365,12 +363,12 @@ test_expect_success PERL 'ending prompt input with EOF' '
363
! grep br2 output
364
'
365
368
-test_expect_success PERL 'difftool --tool-help' '
366
+test_expect_success 'difftool --tool-help' '
367
git difftool --tool-help >output &&
368
grep tool output
369
'
370
373
-test_expect_success PERL 'setup change in subdirectory' '
371
+test_expect_success 'setup change in subdirectory' '
372
git checkout master &&
373
mkdir sub &&
374
echo master >sub/sub &&
@@ -383,11 +381,11 @@ test_expect_success PERL 'setup change in subdirectory' '
381
'
382
383
run_dir_diff_test () {
386
- test_expect_success PERL "$1 --no-symlinks" "
384
+ test_expect_success "$1 --no-symlinks" "
385
symlinks=--no-symlinks &&
386
$2
387
"
390
- test_expect_success PERL,SYMLINKS "$1 --symlinks" "
388
+ test_expect_success SYMLINKS "$1 --symlinks" "
389
symlinks=--symlinks &&
390
$2
391
"
@@ -472,7 +470,7 @@ do
470
done >actual
471
EOF
472
475
-test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
473
+test_expect_success SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
474
cat >expect <<-EOF &&
475
file
476
$PWD/file
@@ -509,7 +507,7 @@ write_script modify-file <<\EOF
507
echo "new content" >file
508
EOF
509
512
-test_expect_success PERL 'difftool --no-symlinks does not overwrite working tree file ' '
510
+test_expect_success 'difftool --no-symlinks does not overwrite working tree file ' '
511
echo "orig content" >file &&
512
git difftool --dir-diff --no-symlinks --extcmd "$PWD/modify-file" branch &&
513
echo "new content" >expect &&
@@ -522,7 +520,7 @@ echo "tmp content" >"$2/file" &&
520
echo "$2" >tmpdir
521
EOF
522
525
-test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
523
+test_expect_success 'difftool --no-symlinks detects conflict ' '
524
(
525
TMPDIR=$TRASH_DIRECTORY &&
526
export TMPDIR &&
@@ -535,7 +533,7 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
533
)
534
'
535
538
-test_expect_success PERL 'difftool properly honors gitlink and core.worktree' '
536
+test_expect_success 'difftool properly honors gitlink and core.worktree' '
537
git submodule add ./. submod/ule &&
538
test_config -C submod/ule diff.tool checktrees &&
539
test_config -C submod/ule difftool.checktrees.cmd '\''
@@ -549,7 +547,7 @@ test_expect_success PERL 'difftool properly honors gitlink and core.worktree' '
547
)
548
'
549
552
-test_expect_success PERL,SYMLINKS 'difftool --dir-diff symlinked directories' '
550
+test_expect_success SYMLINKS 'difftool --dir-diff symlinked directories' '
551
git init dirlinks &&
552
(
553
cd dirlinks &&