author | Junio C Hamano <gitster@pobox.com> | |
Fri, 5 Mar 2010 06:26:39 +0000 (22:26 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 5 Mar 2010 06:26:39 +0000 (22:26 -0800) |
* ld/maint-diff-quiet-w:
git-diff: add a test for git diff --quiet -w
git diff --quiet -w: check and report the status
git-diff: add a test for git diff --quiet -w
git diff --quiet -w: check and report the status
diff.c | patch | blob | history | |
t/t4017-diff-retval.sh | patch | blob | history |
index 989dbc54cbb31c095cc45fb5bb74f62077f1c635..0d465faa1e546382267dc0779116a013647ecf41 100644 (file)
--- a/diff.c
+++ b/diff.c
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 (separator) {
putc(options->line_termination, options->file);
diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh
index 60dd2014d5ae5d5e9e168b8b60278d90ef93cc53..0391a5827ea8ba196b7796b7df818f8ac860c387 100755 (executable)
--- a/t/t4017-diff-retval.sh
+++ b/t/t4017-diff-retval.sh
. ./test-lib.sh
test_expect_success 'setup' '
+ echo "1 " >a &&
+ git add . &&
+ git commit -m zeroth &&
echo 1 >a &&
git add . &&
git commit -m first &&
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' '
git diff-tree --exit-code HEAD^ HEAD
test $? = 1