Skip to content

Commit

Permalink
Fix combined use of whitespace ignore options to diff
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Keith Cascio authored and Junio C Hamano committed Jan 20, 2009
1 parent 537a071 commit 6d12ace
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions t/t4015-diff-whitespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
git diff -w -b > out
test_expect_failure 'another test, with -w -b' 'test_cmp expect out'
test_expect_success 'another test, with -w -b' 'test_cmp expect out'
git diff -w --ignore-space-at-eol > out
test_expect_failure 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
git diff -w -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'

tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
Expand All @@ -123,7 +123,7 @@ EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
git diff -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'

tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
Expand Down
6 changes: 4 additions & 2 deletions xdiff/xutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
while (ptr + 1 < top && isspace(ptr[1])
&& ptr[1] != '\n')
ptr++;
if (flags & XDF_IGNORE_WHITESPACE_CHANGE
if (flags & XDF_IGNORE_WHITESPACE)
; /* already handled */
else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
&& ptr[1] != '\n') {
ha += (ha << 5);
ha ^= (unsigned long) ' ';
}
if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
&& ptr[1] != '\n') {
while (ptr2 != ptr + 1) {
ha += (ha << 5);
Expand Down

0 comments on commit 6d12ace

Please sign in to comment.