Skip to content

Commit 31cf61a

Browse files
dschogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f7c3b4e commit 31cf61a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

builtin/range-diff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
2020
{
2121
int creation_factor = 60;
2222
struct diff_options diffopt = { NULL };
23+
int dual_color = 0;
2324
struct option options[] = {
2425
OPT_INTEGER(0, "creation-factor", &creation_factor,
2526
N_("Percentage by which creation is weighted")),
27+
OPT_BOOL(0, "dual-color", &dual_color,
28+
N_("color both diff and diff-between-diffs")),
2629
OPT_END()
2730
};
2831
int i, j, res = 0;
@@ -60,6 +63,11 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
6063
options + ARRAY_SIZE(options) - 1, /* OPT_END */
6164
builtin_range_diff_usage, 0);
6265

66+
if (dual_color) {
67+
diffopt.use_color = 1;
68+
diffopt.flags.dual_color_diffed_diffs = 1;
69+
}
70+
6371
if (argc == 2) {
6472
if (!strstr(argv[0], ".."))
6573
die(_("no .. in range: '%s'"), argv[0]);

0 commit comments

Comments
 (0)