Skip to content

Commit 4a68b95

Browse files
committed
range-diff: make --dual-color the default mode
After using this command extensively for the last two months, this developer came to the conclusion that even if the dual color mode still leaves a lot of room for confusion what was actually changed, the non-dual color mode is substantially worse in that regard. Therefore, we really want to make the dual color mode the default. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 1443630 commit 4a68b95

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Documentation/git-range-diff.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ all of their ancestors have been shown.
3131

3232
OPTIONS
3333
-------
34-
--dual-color::
35-
When the commit diffs differ, recreate the original diffs'
36-
coloring, and add outer -/+ diff markers with the *background*
37-
being red/green to make it easier to see e.g. when there was a
38-
change in what exact lines were added.
34+
--no-dual-color::
35+
When the commit diffs differ, `git range-diff` recreates the
36+
original diffs' coloring, and add outer -/+ diff markers with
37+
the *background* being red/green to make it easier to see e.g.
38+
when there was a change in what exact lines were added. This is
39+
known to `range-diff` as "dual coloring". Use `--no-dual-color`
40+
to revert to color all lines according to the outer diff markers
41+
(and completely ignore the inner diff when it comes to color).
3942

4043
--creation-factor=<percent>::
4144
Set the creation/deletion cost fudge factor to `<percent>`.

builtin/range-diff.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ 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;
23+
int simple_color = -1;
2424
struct option options[] = {
2525
OPT_INTEGER(0, "creation-factor", &creation_factor,
2626
N_("Percentage by which creation is weighted")),
27-
OPT_BOOL(0, "dual-color", &dual_color,
27+
OPT_BOOL(0, "no-dual-color", &simple_color,
2828
N_("color both diff and diff-between-diffs")),
2929
OPT_END()
3030
};
@@ -53,8 +53,10 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
5353
argc = j;
5454
diff_setup_done(&diffopt);
5555

56-
if (dual_color) {
57-
diffopt.use_color = 1;
56+
if (simple_color < 1) {
57+
if (!simple_color)
58+
/* force color when --dual-color was used */
59+
diffopt.use_color = 1;
5860
diffopt.flags.dual_color_diffed_diffs = 1;
5961
}
6062

contrib/completion/git-completion.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -1981,7 +1981,7 @@ _git_range_diff ()
19811981
case "$cur" in
19821982
--*)
19831983
__gitcomp "
1984-
--creation-factor= --dual-color
1984+
--creation-factor= --no-dual-color
19851985
$__git_diff_common_options
19861986
"
19871987
return

0 commit comments

Comments
 (0)