File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3522,6 +3522,29 @@ void diff_flush(struct diff_options *options)
35223522 separator ++ ;
35233523 }
35243524
3525+ if (output_format & DIFF_FORMAT_NO_OUTPUT &&
3526+ DIFF_OPT_TST (options , EXIT_WITH_STATUS ) &&
3527+ DIFF_OPT_TST (options , DIFF_FROM_CONTENTS )) {
3528+ /*
3529+ * run diff_flush_patch for the exit status. setting
3530+ * options->file to /dev/null should be safe, becaue we
3531+ * aren't supposed to produce any output anyway.
3532+ */
3533+ if (options -> close_file )
3534+ fclose (options -> file );
3535+ options -> file = fopen ("/dev/null" , "w" );
3536+ if (!options -> file )
3537+ die_errno ("Could not open /dev/null" );
3538+ options -> close_file = 1 ;
3539+ for (i = 0 ; i < q -> nr ; i ++ ) {
3540+ struct diff_filepair * p = q -> queue [i ];
3541+ if (check_pair_status (p ))
3542+ diff_flush_patch (p , options );
3543+ if (options -> found_changes )
3544+ break ;
3545+ }
3546+ }
3547+
35253548 if (output_format & DIFF_FORMAT_PATCH ) {
35263549 if (separator ) {
35273550 putc (options -> line_termination , options -> file );
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ test_description='Return value of diffs'
55. ./test-lib.sh
66
77test_expect_success ' setup' '
8+ echo "1 " >a &&
9+ git add . &&
10+ git commit -m zeroth &&
811 echo 1 >a &&
912 git add . &&
1013 git commit -m first &&
@@ -13,6 +16,18 @@ test_expect_success 'setup' '
1316 git commit -a -m second
1417'
1518
19+ test_expect_success ' git diff --quiet -w HEAD^^ HEAD^' '
20+ git diff --quiet -w HEAD^^ HEAD^
21+ '
22+
23+ test_expect_success ' git diff --quiet HEAD^^ HEAD^' '
24+ test_must_fail git diff --quiet HEAD^^ HEAD^
25+ '
26+
27+ test_expect_success ' git diff --quiet -w HEAD^ HEAD' '
28+ test_must_fail git diff --quiet -w HEAD^ HEAD
29+ '
30+
1631test_expect_success ' git diff-tree HEAD^ HEAD' '
1732 git diff-tree --exit-code HEAD^ HEAD
1833 test $? = 1
You can’t perform that action at this time.
0 commit comments