Merge branch 'eb/apply' into next
[gitweb.git] / combine-diff.c
index e17afd109633da16e8aad0cced23556fa41171be..011bb8db2dd4b5cbc22591c6e613247c14de4d2b 100644 (file)
@@ -111,52 +111,6 @@ static char *grab_blob(const unsigned char *sha1, unsigned long *size)
        return blob;
 }
 
-static int parse_num(char **cp_p, unsigned int *num_p)
-{
-       char *cp = *cp_p;
-       unsigned int num = 0;
-       int read_some;
-
-       while ('0' <= *cp && *cp <= '9')
-               num = num * 10 + *cp++ - '0';
-       if (!(read_some = cp - *cp_p))
-               return -1;
-       *cp_p = cp;
-       *num_p = num;
-       return 0;
-}
-
-static int parse_hunk_header(char *line, int len,
-                            unsigned int *ob, unsigned int *on,
-                            unsigned int *nb, unsigned int *nn)
-{
-       char *cp;
-       cp = line + 4;
-       if (parse_num(&cp, ob)) {
-       bad_line:
-               return error("malformed diff output: %s", line);
-       }
-       if (*cp == ',') {
-               cp++;
-               if (parse_num(&cp, on))
-                       goto bad_line;
-       }
-       else
-               *on = 1;
-       if (*cp++ != ' ' || *cp++ != '+')
-               goto bad_line;
-       if (parse_num(&cp, nb))
-               goto bad_line;
-       if (*cp == ',') {
-               cp++;
-               if (parse_num(&cp, nn))
-                       goto bad_line;
-       }
-       else
-               *nn = 1;
-       return -!!memcmp(cp, " @@", 3);
-}
-
 static void append_lost(struct sline *sline, int n, const char *line, int len)
 {
        struct lline *lline;
@@ -197,7 +151,8 @@ static void append_lost(struct sline *sline, int n, const char *line, int len)
 struct combine_diff_state {
        struct xdiff_emit_state xm;
 
-       unsigned int lno, ob, on, nb, nn;
+       unsigned int lno;
+       int ob, on, nb, nn;
        unsigned long nmask;
        int num_parent;
        int n;
@@ -877,6 +832,7 @@ const char *diff_tree_combined_merge(const unsigned char *sha1,
 
        diffopts = *opt;
        diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
+       diffopts.with_raw = 0;
        diffopts.recursive = 1;
 
        /* count parents */
@@ -903,6 +859,16 @@ const char *diff_tree_combined_merge(const unsigned char *sha1,
                        num_paths++;
        }
        if (num_paths) {
+               if (opt->with_raw) {
+                       int saved_format = opt->output_format;
+                       opt->output_format = DIFF_FORMAT_RAW;
+                       for (p = paths; p; p = p->next) {
+                               if (show_combined_diff(p, num_parent, dense,
+                                                      header, opt))
+                                       header = NULL;
+                       }
+                       opt->output_format = saved_format;
+               }
                for (p = paths; p; p = p->next) {
                        if (show_combined_diff(p, num_parent, dense,
                                               header, opt))