Merge branch 'jc/apply-ignore-whitespace' into maint
[gitweb.git] / builtin / apply.c
index 0189523798f31711ad74eaf3dd90ece9c12fa61a..9c5724eaccfaee62ff10eb097adc39ace351cade 100644 (file)
@@ -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;
@@ -4061,7 +4063,7 @@ static int write_out_one_reject(struct patch *patch)
                return error(_("cannot open %s: %s"), namebuf, strerror(errno));
 
        /* Normal git tools never deal with .rej, so do not pretend
-        * this is a git patch by saying --git nor give extended
+        * this is a git patch by saying --git or giving extended
         * headers.  While at it, maybe please "kompare" that wants
         * the trailing TAB and some garbage at the end of line ;-).
         */