Skip to content

Commit 8c4c286

Browse files
committed
Merge branch 'kc/maint-diff-bwi-fix' into maint
* kc/maint-diff-bwi-fix: Fix combined use of whitespace ignore options to diff test more combinations of ignore-whitespace options to diff
2 parents f26b5dc + 6d12ace commit 8c4c286

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ index d99af23..8b32fb5 100644
9898
EOF
9999
git diff -w > out
100100
test_expect_success 'another test, with -w' 'test_cmp expect out'
101+
git diff -w -b > out
102+
test_expect_success 'another test, with -w -b' 'test_cmp expect out'
103+
git diff -w --ignore-space-at-eol > out
104+
test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
105+
git diff -w -b --ignore-space-at-eol > out
106+
test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
101107

102108
tr 'Q' '\015' << EOF > expect
103109
diff --git a/x b/x
@@ -116,6 +122,27 @@ index d99af23..8b32fb5 100644
116122
EOF
117123
git diff -b > out
118124
test_expect_success 'another test, with -b' 'test_cmp expect out'
125+
git diff -b --ignore-space-at-eol > out
126+
test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
127+
128+
tr 'Q' '\015' << EOF > expect
129+
diff --git a/x b/x
130+
index d99af23..8b32fb5 100644
131+
--- a/x
132+
+++ b/x
133+
@@ -1,6 +1,6 @@
134+
-whitespace at beginning
135+
-whitespace change
136+
-whitespace in the middle
137+
+ whitespace at beginning
138+
+whitespace change
139+
+white space in the middle
140+
whitespace at end
141+
unchanged line
142+
CR at endQ
143+
EOF
144+
git diff --ignore-space-at-eol > out
145+
test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect out'
119146

120147
test_expect_success 'check mixed spaces and tabs in indent' '
121148

xdiff/xutils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,14 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
245245
while (ptr + 1 < top && isspace(ptr[1])
246246
&& ptr[1] != '\n')
247247
ptr++;
248-
if (flags & XDF_IGNORE_WHITESPACE_CHANGE
248+
if (flags & XDF_IGNORE_WHITESPACE)
249+
; /* already handled */
250+
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
249251
&& ptr[1] != '\n') {
250252
ha += (ha << 5);
251253
ha ^= (unsigned long) ' ';
252254
}
253-
if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
255+
else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
254256
&& ptr[1] != '\n') {
255257
while (ptr2 != ptr + 1) {
256258
ha += (ha << 5);

0 commit comments

Comments
 (0)