File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -3522,6 +3522,29 @@ void diff_flush(struct diff_options *options)
3522
3522
separator ++ ;
3523
3523
}
3524
3524
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
+
3525
3548
if (output_format & DIFF_FORMAT_PATCH ) {
3526
3549
if (separator ) {
3527
3550
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'
5
5
. ./test-lib.sh
6
6
7
7
test_expect_success ' setup' '
8
+ echo "1 " >a &&
9
+ git add . &&
10
+ git commit -m zeroth &&
8
11
echo 1 >a &&
9
12
git add . &&
10
13
git commit -m first &&
@@ -13,6 +16,18 @@ test_expect_success 'setup' '
13
16
git commit -a -m second
14
17
'
15
18
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
+
16
31
test_expect_success ' git diff-tree HEAD^ HEAD' '
17
32
git diff-tree --exit-code HEAD^ HEAD
18
33
test $? = 1
You can’t perform that action at this time.
0 commit comments