Skip to content

Commit 02e13c0

Browse files
committed
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]>
1 parent 6be4baf commit 02e13c0

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;
@@ -50,6 +53,11 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
5053
argc = j;
5154
diff_setup_done(&diffopt);
5255

56+
if (dual_color) {
57+
diffopt.use_color = 1;
58+
diffopt.flags.dual_color_diffed_diffs = 1;
59+
}
60+
5361
if (argc == 2) {
5462
if (!strstr(argv[0], ".."))
5563
warning(_("no .. in range: '%s'"), argv[0]);

0 commit comments

Comments
 (0)