add and use a convenience macro ce_intent_to_add()
[gitweb.git] / builtin / apply.c
index 525db4a2a237fa0b12a254fd72b86dcd66738e93..0769b09287b2bcf6b3f85ff503a396fa245c31a0 100644 (file)
@@ -1601,6 +1601,9 @@ static int parse_fragment(const char *line, unsigned long size,
                        if (!deleted && !added)
                                leading++;
                        trailing++;
+                       if (!apply_in_reverse &&
+                           ws_error_action == correct_ws_error)
+                               check_whitespace(line, len, patch->ws_rule);
                        break;
                case '-':
                        if (apply_in_reverse &&
@@ -2773,7 +2776,8 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
                default:
                        if (apply_verbosely)
                                error(_("invalid start of line: '%c'"), first);
-                       return -1;
+                       applied_pos = -1;
+                       goto out;
                }
                if (added_blank_line) {
                        if (!new_blank_lines_at_end)
@@ -2912,6 +2916,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
                              (int)(old - oldlines), oldlines);
        }
 
+out:
        free(oldlines);
        strbuf_release(&newlines);
        free(preimage.line_allocated);