Skip to content

Commit

Permalink
diff -b: ignore whitespace at end of line
Browse files Browse the repository at this point in the history
This is _not_ the same as "treat eol as whitespace", since that would mean
that multiple empty lines would be treated as equal to e.g. a space.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Dec 5, 2006
1 parent ba988a8 commit c7c2488
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions t/t4015-diff-whitespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ index d99af23..8b32fb5 100644
+ whitespace at beginning
whitespace change
-whitespace in the middle
-whitespace at end
+white space in the middle
+whitespace at end
whitespace at end
unchanged line
-CR at endQ
+CR at end
CR at endQ
EOF
git-diff -b > out
test_expect_success 'another test, with -b' 'diff -u expect out'
Expand Down
3 changes: 2 additions & 1 deletion xdiff/xutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
while (ptr + 1 < top && isspace(ptr[1])
&& ptr[1] != '\n')
ptr++;
if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
if (flags & XDF_IGNORE_WHITESPACE_CHANGE
&& ptr[1] != '\n') {
ha += (ha << 5);
ha ^= (unsigned long) ' ';
}
Expand Down

0 comments on commit c7c2488

Please sign in to comment.