-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
4 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/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 | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters