mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
Merge branch 'sb/diff-color-move'
A recently added "--color-moved" feature of "diff" fell into infinite loop when ignoring whitespace changes, which has been fixed. * sb/diff-color-move: diff: fix infinite loop with --color-moved --ignore-space-change
This commit is contained in:
commit
91ccfb8517
28
diff.c
28
diff.c
|
@ -712,20 +712,22 @@ static int next_byte(const char **cp, const char **endp,
|
||||||
if (*cp > *endp)
|
if (*cp > *endp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE_CHANGE)) {
|
if (isspace(**cp)) {
|
||||||
while (*cp < *endp && isspace(**cp))
|
if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE_CHANGE)) {
|
||||||
(*cp)++;
|
while (*cp < *endp && isspace(**cp))
|
||||||
/*
|
(*cp)++;
|
||||||
* After skipping a couple of whitespaces, we still have to
|
/*
|
||||||
* account for one space.
|
* After skipping a couple of whitespaces,
|
||||||
*/
|
* we still have to account for one space.
|
||||||
return (int)' ';
|
*/
|
||||||
}
|
return (int)' ';
|
||||||
|
}
|
||||||
|
|
||||||
if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE)) {
|
if (DIFF_XDL_TST(diffopt, IGNORE_WHITESPACE)) {
|
||||||
while (*cp < *endp && isspace(**cp))
|
while (*cp < *endp && isspace(**cp))
|
||||||
(*cp)++;
|
(*cp)++;
|
||||||
/* return the first non-ws character via the usual below */
|
/* return the first non-ws character via the usual below */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = (unsigned char)(**cp);
|
retval = (unsigned char)(**cp);
|
||||||
|
|
|
@ -1530,4 +1530,13 @@ test_expect_success 'move detection with submodules' '
|
||||||
test_cmp expect decoded_actual
|
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
|
test_done
|
||||||
|
|
Loading…
Reference in a new issue