Skip to content

Commit c7c2488

Browse files
dschoJunio C Hamano
authored andcommitted
diff -b: ignore whitespace at end of line
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba988a8 commit c7c2488

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ index d99af23..8b32fb5 100644
109109
+ whitespace at beginning
110110
whitespace change
111111
-whitespace in the middle
112-
-whitespace at end
113112
+white space in the middle
114-
+whitespace at end
113+
whitespace at end
115114
unchanged line
116-
-CR at endQ
117-
+CR at end
115+
CR at endQ
118116
EOF
119117
git-diff -b > out
120118
test_expect_success 'another test, with -b' 'diff -u expect out'

xdiff/xutils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
230230
while (ptr + 1 < top && isspace(ptr[1])
231231
&& ptr[1] != '\n')
232232
ptr++;
233-
if (flags & XDF_IGNORE_WHITESPACE_CHANGE) {
233+
if (flags & XDF_IGNORE_WHITESPACE_CHANGE
234+
&& ptr[1] != '\n') {
234235
ha += (ha << 5);
235236
ha ^= (unsigned long) ' ';
236237
}

0 commit comments

Comments
 (0)