summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-06-25 11:46:23 -0700
committerJunio C Hamano <gitster@pobox.com>2014-06-25 11:46:23 -0700
commitc122c9a968d5528b799fd5aeab8e67fffb45ef4d (patch)
treebd71efe988e971408b48572a23b9032540465d05 /builtin
parentff7e96b78f3ad9db61fbdfdeaf7b71f254f76310 (diff)
parent14d3bb4955a41e146b6f1cd6571602a6b46b2af9 (diff)
downloadgit-c122c9a968d5528b799fd5aeab8e67fffb45ef4d.tar.gz
Merge branch 'jc/apply-ignore-whitespace' into maint
"--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
Diffstat (limited to 'builtin')
-rw-r--r--builtin/apply.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 87439fad11..9c5724eacc 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -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;