range-diff: offer to dual-color the diffs

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.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Aug 13, 2018 at 04:33 UTC 31cf61a08008eb152247b16ee96811220f019fbd
1 file changed +8
builtin/range-diff.c
+8
@@ -20,9 +20,12 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
20 {
21 int creation_factor = 60;
22 struct diff_options diffopt = { NULL };
23 + int dual_color = 0;
24 struct option options[] = {
25 OPT_INTEGER(0, "creation-factor", &creation_factor,
26 N_("Percentage by which creation is weighted")),
27 + OPT_BOOL(0, "dual-color", &dual_color,
28 + N_("color both diff and diff-between-diffs")),
29 OPT_END()
30 };
31 int i, j, res = 0;
@@ -60,6 +63,11 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
63 options + ARRAY_SIZE(options) - 1, /* OPT_END */
64 builtin_range_diff_usage, 0);
65
66 + if (dual_color) {
67 + diffopt.use_color = 1;
68 + diffopt.flags.dual_color_diffed_diffs = 1;
69 + }
70 +
71 if (argc == 2) {
72 if (!strstr(argv[0], ".."))
73 die(_("no .. in range: '%s'"), argv[0]);