diff: change semantics of "ignore whitespace" options
Traditionally, the --ignore-whitespace* options have merely meant to tell
the diff output routine that some class of differences are not worth
showing in the textual diff output, so that the end user has easier time
to review the remaining (presumably more meaningful) changes. These
options never affected the outcome of the command, given as the exit
status when the --exit-code option was in effect (either directly or
indirectly).
When you have only whitespace changes, however, you might expect
git diff -b --exit-code
to report that there is _no_ change with zero exit status.
Change the semantics of --ignore-whitespace* options to mean more than
"omit showing the difference in text".
The exit status, when --exit-code is in effect, is computed by checking if
we found any differences at the path level, while diff frontends feed
filepairs to the diffcore engine. When "ignore whitespace" options are in
effect, we defer this determination until the very end of diffcore
transformation. We simply do not know until the textual diff is
generated, which comes very late in the pipeline.
When --quiet is in effect, various diff frontends optimize by breaking out
early from the loop that enumerates the filepairs, when we find the first
path level difference; when --ignore-whitespace* is used the above change
automatically disables this optimization.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-22 21:45:29 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='diff --exit-code with whitespace'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
mkdir a b &&
|
|
|
|
echo >c &&
|
|
|
|
echo >a/d &&
|
|
|
|
echo >b/e &&
|
|
|
|
git add . &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
echo " " >a/d &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -a -m second &&
|
|
|
|
echo " " >a/d &&
|
|
|
|
echo " " >b/e &&
|
|
|
|
git add a/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-tree --exit-code' '
|
|
|
|
test_must_fail git diff --exit-code HEAD^ HEAD &&
|
|
|
|
test_must_fail git diff-tree --exit-code HEAD^ HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-tree -b --exit-code' '
|
|
|
|
git diff -b --exit-code HEAD^ HEAD &&
|
|
|
|
git diff-tree -b -p --exit-code HEAD^ HEAD &&
|
|
|
|
git diff-tree -b --exit-code HEAD^ HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-index --cached --exit-code' '
|
|
|
|
test_must_fail git diff --cached --exit-code HEAD &&
|
|
|
|
test_must_fail git diff-index --cached --exit-code HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-index -b -p --cached --exit-code' '
|
|
|
|
git diff -b --cached --exit-code HEAD &&
|
|
|
|
git diff-index -b -p --cached --exit-code HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-index --exit-code' '
|
|
|
|
test_must_fail git diff --exit-code HEAD &&
|
|
|
|
test_must_fail git diff-index --exit-code HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-index -b -p --exit-code' '
|
|
|
|
git diff -b --exit-code HEAD &&
|
|
|
|
git diff-index -b -p --exit-code HEAD
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files --exit-code' '
|
|
|
|
test_must_fail git diff --exit-code &&
|
|
|
|
test_must_fail git diff-files --exit-code
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff-files -b -p --exit-code' '
|
|
|
|
git diff -b --exit-code &&
|
|
|
|
git diff-files -b -p --exit-code
|
|
|
|
'
|
|
|
|
|
2011-03-16 23:46:08 +01:00
|
|
|
test_expect_success 'diff-files --diff-filter --quiet' '
|
|
|
|
git reset --hard &&
|
|
|
|
rm a/d &&
|
|
|
|
echo x >>b/e &&
|
|
|
|
test_must_fail git diff-files --diff-filter=M --quiet
|
|
|
|
'
|
|
|
|
|
2011-05-31 17:33:56 +02:00
|
|
|
test_expect_success 'diff-tree --diff-filter --quiet' '
|
|
|
|
git commit -a -m "worktree state" &&
|
|
|
|
test_must_fail git diff-tree --diff-filter=M --quiet HEAD^ HEAD
|
|
|
|
'
|
|
|
|
|
diff: change semantics of "ignore whitespace" options
Traditionally, the --ignore-whitespace* options have merely meant to tell
the diff output routine that some class of differences are not worth
showing in the textual diff output, so that the end user has easier time
to review the remaining (presumably more meaningful) changes. These
options never affected the outcome of the command, given as the exit
status when the --exit-code option was in effect (either directly or
indirectly).
When you have only whitespace changes, however, you might expect
git diff -b --exit-code
to report that there is _no_ change with zero exit status.
Change the semantics of --ignore-whitespace* options to mean more than
"omit showing the difference in text".
The exit status, when --exit-code is in effect, is computed by checking if
we found any differences at the path level, while diff frontends feed
filepairs to the diffcore engine. When "ignore whitespace" options are in
effect, we defer this determination until the very end of diffcore
transformation. We simply do not know until the textual diff is
generated, which comes very late in the pipeline.
When --quiet is in effect, various diff frontends optimize by breaking out
early from the loop that enumerates the filepairs, when we find the first
path level difference; when --ignore-whitespace* is used the above change
automatically disables this optimization.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-22 21:45:29 +02:00
|
|
|
test_done
|