summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff.c28
-rwxr-xr-xt/t4015-diff-whitespace.sh9
2 files changed, 24 insertions, 13 deletions
diff --git a/diff.c b/diff.c
index 0c604726c0..af9b952886 100644
--- a/diff.c
+++ b/diff.c
@@ -720,20 +720,22 @@ static int next_byte(const char **cp, const char **endp,
if (*cp > *endp)
return -1;
- if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE_CHANGE)) {
- while (*cp < *endp && isspace(**cp))
- (*cp)++;
- /*
- * After skipping a couple of whitespaces, we still have to
- * account for one space.
- */
- return (int)' ';
- }
+ if (isspace(**cp)) {
+ if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE_CHANGE)) {
+ while (*cp < *endp && isspace(**cp))
+ (*cp)++;
+ /*
+ * After skipping a couple of whitespaces,
+ * we still have to account for one space.
+ */
+ return (int)' ';
+ }
- if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE)) {
- while (*cp < *endp && isspace(**cp))
- (*cp)++;
- /* return the first non-ws character via the usual below */
+ if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE)) {
+ while (*cp < *endp && isspace(**cp))
+ (*cp)++;
+ /* return the first non-ws character via the usual below */
+ }
}
retval = (unsigned char)(**cp);
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index c3b697411a..66cad4d629 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -1406,4 +1406,13 @@ test_expect_success 'move detection with submodules' '
test_cmp expect decoded_actual
'
+test_expect_success 'move detection with whitespace changes' '
+ test_when_finished "git reset --hard" &&
+ test_seq 10 >test &&
+ git add test &&
+ sed s/3/42/ <test >test.tmp &&
+ mv test.tmp test &&
+ git -c diff.colormoved diff --ignore-space-change -- test
+'
+
test_done