Merge branch 'ld/maint-diff-quiet-w' into maint
* ld/maint-diff-quiet-w: git-diff: add a test for git diff --quiet -w git diff --quiet -w: check and report the status
This commit is contained in:
commit
8cc3709df0
23
diff.c
23
diff.c
@ -3522,6 +3522,29 @@ void diff_flush(struct diff_options *options)
|
|||||||
separator++;
|
separator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
|
||||||
|
DIFF_OPT_TST(options, EXIT_WITH_STATUS) &&
|
||||||
|
DIFF_OPT_TST(options, DIFF_FROM_CONTENTS)) {
|
||||||
|
/*
|
||||||
|
* run diff_flush_patch for the exit status. setting
|
||||||
|
* options->file to /dev/null should be safe, becaue we
|
||||||
|
* aren't supposed to produce any output anyway.
|
||||||
|
*/
|
||||||
|
if (options->close_file)
|
||||||
|
fclose(options->file);
|
||||||
|
options->file = fopen("/dev/null", "w");
|
||||||
|
if (!options->file)
|
||||||
|
die_errno("Could not open /dev/null");
|
||||||
|
options->close_file = 1;
|
||||||
|
for (i = 0; i < q->nr; i++) {
|
||||||
|
struct diff_filepair *p = q->queue[i];
|
||||||
|
if (check_pair_status(p))
|
||||||
|
diff_flush_patch(p, options);
|
||||||
|
if (options->found_changes)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (output_format & DIFF_FORMAT_PATCH) {
|
if (output_format & DIFF_FORMAT_PATCH) {
|
||||||
if (separator) {
|
if (separator) {
|
||||||
putc(options->line_termination, options->file);
|
putc(options->line_termination, options->file);
|
||||||
|
@ -5,6 +5,9 @@ test_description='Return value of diffs'
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
|
echo "1 " >a &&
|
||||||
|
git add . &&
|
||||||
|
git commit -m zeroth &&
|
||||||
echo 1 >a &&
|
echo 1 >a &&
|
||||||
git add . &&
|
git add . &&
|
||||||
git commit -m first &&
|
git commit -m first &&
|
||||||
@ -13,6 +16,18 @@ test_expect_success 'setup' '
|
|||||||
git commit -a -m second
|
git commit -a -m second
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git diff --quiet -w HEAD^^ HEAD^' '
|
||||||
|
git diff --quiet -w HEAD^^ HEAD^
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git diff --quiet HEAD^^ HEAD^' '
|
||||||
|
test_must_fail git diff --quiet HEAD^^ HEAD^
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'git diff --quiet -w HEAD^ HEAD' '
|
||||||
|
test_must_fail git diff --quiet -w HEAD^ HEAD
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'git diff-tree HEAD^ HEAD' '
|
test_expect_success 'git diff-tree HEAD^ HEAD' '
|
||||||
git diff-tree --exit-code HEAD^ HEAD
|
git diff-tree --exit-code HEAD^ HEAD
|
||||||
test $? = 1
|
test $? = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user