Skip to content

Commit e37423f

Browse files
committed
Revert "diff: fix --exit-code with external diff"
This reverts commit 11be65c, per original author's request to come up with a better strategy.
1 parent 11be65c commit e37423f

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

diff.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "setup.h"
4141
#include "strmap.h"
4242
#include "ws.h"
43-
#include "write-or-die.h"
4443

4544
#ifdef NO_FAST_WORKING_DIRECTORY
4645
#define FAST_WORKING_DIRECTORY 0
@@ -4397,33 +4396,8 @@ static void run_external_diff(const char *pgm,
43974396
diff_free_filespec_data(one);
43984397
diff_free_filespec_data(two);
43994398
cmd.use_shell = 1;
4400-
if (o->flags.diff_from_contents) {
4401-
int got_output = 0;
4402-
cmd.out = -1;
4403-
if (start_command(&cmd))
4404-
die(_("external diff died, stopping at %s"), name);
4405-
for (;;) {
4406-
char buffer[8192];
4407-
ssize_t len = xread(cmd.out, buffer, sizeof(buffer));
4408-
if (!len)
4409-
break;
4410-
if (len < 0)
4411-
die(_("unable to read from external diff,"
4412-
" stopping at %s"), name);
4413-
got_output = 1;
4414-
if (write_in_full(1, buffer, len) < 0)
4415-
die(_("unable to write output of external diff,"
4416-
" stopping at %s"), name);
4417-
}
4418-
close(cmd.out);
4419-
if (finish_command(&cmd))
4420-
die(_("external diff died, stopping at %s"), name);
4421-
if (got_output)
4422-
o->found_changes = 1;
4423-
} else {
4424-
if (run_command(&cmd))
4425-
die(_("external diff died, stopping at %s"), name);
4426-
}
4399+
if (run_command(&cmd))
4400+
die(_("external diff died, stopping at %s"), name);
44274401

44284402
remove_tempfile();
44294403
}
@@ -4870,7 +4844,6 @@ void diff_setup_done(struct diff_options *options)
48704844
*/
48714845

48724846
if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
4873-
options->flags.exit_with_status ||
48744847
options->ignore_regex_nr)
48754848
options->flags.diff_from_contents = 1;
48764849
else
@@ -6759,7 +6732,7 @@ void diff_flush(struct diff_options *options)
67596732
if (output_format & DIFF_FORMAT_CALLBACK)
67606733
options->format_callback(q, options, options->format_callback_data);
67616734

6762-
if ((!output_format || output_format & DIFF_FORMAT_NO_OUTPUT) &&
6735+
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
67636736
options->flags.exit_with_status &&
67646737
options->flags.diff_from_contents) {
67656738
/*

t/t4020-diff-external.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,6 @@ test_expect_success 'no diff with -diff' '
172172
grep Binary out
173173
'
174174

175-
test_expect_success 'diff.external and --exit-code with output' '
176-
test_expect_code 1 git -c diff.external=echo diff --exit-code
177-
'
178-
179-
test_expect_success 'diff.external and --exit-code without output' '
180-
git -c diff.external=true diff --exit-code
181-
'
182-
183175
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
184176

185177
test_expect_success 'force diff with "diff"' '

0 commit comments

Comments
 (0)