]> git.ipfire.org Git - thirdparty/git.git/blobdiff - range-diff.c
Merge branch 'pk/rebase-in-c-5-test'
[thirdparty/git.git] / range-diff.c
index 3e9b9844012dac7fb4a0e80451e0d459da9a820e..bd8083f2d10cea9a464ebfd1490295d13267421a 100644 (file)
@@ -343,7 +343,7 @@ static void output_pair_header(struct diff_options *diffopt,
        }
        strbuf_addf(buf, "%s\n", color_reset);
 
-       fwrite(buf->buf, buf->len, 1, stdout);
+       fwrite(buf->buf, buf->len, 1, diffopt->file);
 }
 
 static struct userdiff_driver no_func_name = {
@@ -354,7 +354,7 @@ static struct diff_filespec *get_filespec(const char *name, const char *p)
 {
        struct diff_filespec *spec = alloc_filespec(name);
 
-       fill_filespec(spec, &null_oid, 0, 0644);
+       fill_filespec(spec, &null_oid, 0, 0100644);
        spec->data = (char *)p;
        spec->size = strlen(p);
        spec->should_munmap = 0;
@@ -429,8 +429,14 @@ static void output(struct string_list *a, struct string_list *b,
        strbuf_release(&dashes);
 }
 
+static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data)
+{
+       return data;
+}
+
 int show_range_diff(const char *range1, const char *range2,
-                   int creation_factor, struct diff_options *diffopt)
+                   int creation_factor, int dual_color,
+                   struct diff_options *diffopt)
 {
        int res = 0;
 
@@ -443,9 +449,23 @@ int show_range_diff(const char *range1, const char *range2,
                res = error(_("could not parse log for '%s'"), range2);
 
        if (!res) {
+               struct diff_options opts;
+               struct strbuf indent = STRBUF_INIT;
+
+               memcpy(&opts, diffopt, sizeof(opts));
+               opts.output_format = DIFF_FORMAT_PATCH;
+               opts.flags.suppress_diff_headers = 1;
+               opts.flags.dual_color_diffed_diffs = dual_color;
+               opts.output_prefix = output_prefix_cb;
+               strbuf_addstr(&indent, "    ");
+               opts.output_prefix_data = &indent;
+               diff_setup_done(&opts);
+
                find_exact_matches(&branch1, &branch2);
                get_correspondences(&branch1, &branch2, creation_factor);
-               output(&branch1, &branch2, diffopt);
+               output(&branch1, &branch2, &opts);
+
+               strbuf_release(&indent);
        }
 
        string_list_clear(&branch1, 1);