When showing what changed between old and new commits, we show a diff of
the patches. This diff is a diff between diffs, therefore there are
nested +/- signs, and it can be relatively hard to understand what is
going on.

With the --dual-color option, the preimage and the postimage are colored
like the diffs they are, and the *outer* +/- sign is inverted for
clarity.

Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
---
 builtin/branch-diff.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/builtin/branch-diff.c b/builtin/branch-diff.c
index 04efd30f0f6..8a16352e3a1 100644
--- a/builtin/branch-diff.c
+++ b/builtin/branch-diff.c
@@ -435,8 +435,11 @@ int cmd_branch_diff(int argc, const char **argv, const 
char *prefix)
 {
        struct diff_options diffopt = { NULL };
        struct strbuf four_spaces = STRBUF_INIT;
+       int dual_color = 0;
        double creation_weight = 0.6;
        struct option options[] = {
+               OPT_BOOL(0, "dual-color", &dual_color,
+                           N_("color both diff and diff-between-diffs")),
                OPT_SET_INT(0, "no-patches", &diffopt.output_format,
                            N_("short format (no diffs)"),
                            DIFF_FORMAT_NO_OUTPUT),
@@ -472,6 +475,11 @@ int cmd_branch_diff(int argc, const char **argv, const 
char *prefix)
        argc = j;
        diff_setup_done(&diffopt);
 
+       if (dual_color) {
+               diffopt.use_color = 1;
+               diffopt.flags.dual_color_diffed_diffs = 1;
+       }
+
        if (argc == 2) {
                if (!strstr(argv[0], ".."))
                        warning(_("no .. in range: '%s'"), argv[0]);
-- 
2.17.0.409.g71698f11835


Reply via email to