Skip to content

Commit db271e7

Browse files
committed
Merge branch 'rs/external-diff-with-exit-code'
* rs/external-diff-with-exit-code: Revert "diff: fix --exit-code with external diff"
2 parents 19fe900 + e37423f commit db271e7

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
@@ -4405,33 +4404,8 @@ static void run_external_diff(const char *pgm,
44054404
diff_free_filespec_data(one);
44064405
diff_free_filespec_data(two);
44074406
cmd.use_shell = 1;
4408-
if (o->flags.diff_from_contents) {
4409-
int got_output = 0;
4410-
cmd.out = -1;
4411-
if (start_command(&cmd))
4412-
die(_("external diff died, stopping at %s"), name);
4413-
for (;;) {
4414-
char buffer[8192];
4415-
ssize_t len = xread(cmd.out, buffer, sizeof(buffer));
4416-
if (!len)
4417-
break;
4418-
if (len < 0)
4419-
die(_("unable to read from external diff,"
4420-
" stopping at %s"), name);
4421-
got_output = 1;
4422-
if (write_in_full(1, buffer, len) < 0)
4423-
die(_("unable to write output of external diff,"
4424-
" stopping at %s"), name);
4425-
}
4426-
close(cmd.out);
4427-
if (finish_command(&cmd))
4428-
die(_("external diff died, stopping at %s"), name);
4429-
if (got_output)
4430-
o->found_changes = 1;
4431-
} else {
4432-
if (run_command(&cmd))
4433-
die(_("external diff died, stopping at %s"), name);
4434-
}
4407+
if (run_command(&cmd))
4408+
die(_("external diff died, stopping at %s"), name);
44354409

44364410
remove_tempfile();
44374411
}
@@ -4878,7 +4852,6 @@ void diff_setup_done(struct diff_options *options)
48784852
*/
48794853

48804854
if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
4881-
options->flags.exit_with_status ||
48824855
options->ignore_regex_nr)
48834856
options->flags.diff_from_contents = 1;
48844857
else
@@ -6769,7 +6742,7 @@ void diff_flush(struct diff_options *options)
67696742
if (output_format & DIFF_FORMAT_CALLBACK)
67706743
options->format_callback(q, options, options->format_callback_data);
67716744

6772-
if ((!output_format || output_format & DIFF_FORMAT_NO_OUTPUT) &&
6745+
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
67736746
options->flags.exit_with_status &&
67746747
options->flags.diff_from_contents) {
67756748
/*

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)