]> git.ipfire.org Git - thirdparty/git.git/blobdiff - combine-diff.c
fix segfault with git log -c --follow
[thirdparty/git.git] / combine-diff.c
index bb1cc96c4e73c90ee327858aa3b36cf2bfe043a4..21fd00ff6156f7eb7af6b74dd569325af3f37820 100644 (file)
@@ -982,14 +982,10 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
        free(sline);
 }
 
-#define COLONS "::::::::::::::::::::::::::::::::"
-
 static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
 {
        struct diff_options *opt = &rev->diffopt;
-       int i, offset;
-       const char *prefix;
-       int line_termination, inter_name_termination;
+       int line_termination, inter_name_termination, i;
 
        line_termination = opt->line_termination;
        inter_name_termination = '\t';
@@ -1000,17 +996,14 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct re
                show_log(rev);
 
        if (opt->output_format & DIFF_FORMAT_RAW) {
-               offset = strlen(COLONS) - num_parent;
-               if (offset < 0)
-                       offset = 0;
-               prefix = COLONS + offset;
+               /* As many colons as there are parents */
+               for (i = 0; i < num_parent; i++)
+                       putchar(':');
 
                /* Show the modes */
-               for (i = 0; i < num_parent; i++) {
-                       printf("%s%06o", prefix, p->parent[i].mode);
-                       prefix = " ";
-               }
-               printf("%s%06o", prefix, p->mode);
+               for (i = 0; i < num_parent; i++)
+                       printf("%06o ", p->parent[i].mode);
+               printf("%06o", p->mode);
 
                /* Show sha1's */
                for (i = 0; i < num_parent; i++)
@@ -1127,6 +1120,7 @@ void diff_tree_combined(const unsigned char *sha1,
        int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
 
        diffopts = *opt;
+       diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts);
        diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
        DIFF_OPT_SET(&diffopts, RECURSIVE);
        DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
@@ -1194,6 +1188,8 @@ void diff_tree_combined(const unsigned char *sha1,
                paths = paths->next;
                free(tmp);
        }
+
+       diff_tree_release_paths(&diffopts);
 }
 
 void diff_tree_combined_merge(const struct commit *commit, int dense,