@matheusbsbs / matheus-bagliano / commits / 6d12acefd5
Fork 0

Fix combined use of whitespace ignore options to diff

The code used to misbehave when options to ignore certain whitespaces (-w -b and --ignore-at-eol) were combined. Signed-off-by: Keith Cascio <keith@cs.ucla.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Keith Cascio committed Jan 19, 2009 at 10:03 UTC 6d12acefd5ac0cd688bcc77470bb1d73859cdab1
2 files changed +8 -6
t/t4015-diff-whitespace.sh
+4 -4
@@ -99,11 +99,11 @@ EOF
99 git diff -w > out
100 test_expect_success 'another test, with -w' 'test_cmp expect out'
101 git diff -w -b > out
102 -test_expect_failure 'another test, with -w -b' 'test_cmp expect 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_failure 'another test, with -w --ignore-space-at-eol' 'test_cmp expect 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_failure 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
106 +test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
107
108 tr 'Q' '\015' << EOF > expect
109 diff --git a/x b/x
@@ -123,7 +123,7 @@ EOF
123 git diff -b > out
124 test_expect_success 'another test, with -b' 'test_cmp expect out'
125 git diff -b --ignore-space-at-eol > out
126 -test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect 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
xdiff/xutils.c
+4 -2
@@ -245,12 +245,14 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
245 while (ptr + 1 < top && isspace(ptr[1])
246 && ptr[1] != '\n')
247 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
251 && ptr[1] != '\n') {
252 ha += (ha << 5);
253 ha ^= (unsigned long) ' ';
254 }
253 - if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
255 + else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
256 && ptr[1] != '\n') {
257 while (ptr2 != ptr + 1) {
258 ha += (ha << 5);