Merge branch 'jc/apply-ignore-whitespace'
"--ignore-space-change" option of "git apply" ignored the spaces at the beginning of line too aggressively, which is inconsistent with the option of the same name "diff" and "git diff" have. * jc/apply-ignore-whitespace: apply --ignore-space-change: lines with and without leading whitespaces do not match
This commit is contained in:
@ -300,11 +300,13 @@ static int fuzzy_matchlines(const char *s1, size_t n1,
|
||||
while ((*last2 == '\r') || (*last2 == '\n'))
|
||||
last2--;
|
||||
|
||||
/* skip leading whitespace */
|
||||
while (isspace(*s1) && (s1 <= last1))
|
||||
s1++;
|
||||
while (isspace(*s2) && (s2 <= last2))
|
||||
s2++;
|
||||
/* skip leading whitespaces, if both begin with whitespace */
|
||||
if (s1 <= last1 && s2 <= last2 && isspace(*s1) && isspace(*s2)) {
|
||||
while (isspace(*s1) && (s1 <= last1))
|
||||
s1++;
|
||||
while (isspace(*s2) && (s2 <= last2))
|
||||
s2++;
|
||||
}
|
||||
/* early return if both lines are empty */
|
||||
if ((s1 > last1) && (s2 > last2))
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user