Skip to content

Commit

Permalink
range-diff: make --dual-color the default mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Jun 30, 2018
1 parent 1443630 commit 4a68b95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 8 additions & 5 deletions Documentation/git-range-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ all of their ancestors have been shown.

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

--creation-factor=<percent>::
Set the creation/deletion cost fudge factor to `<percent>`.
Expand Down
10 changes: 6 additions & 4 deletions builtin/range-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
{
int creation_factor = 60;
struct diff_options diffopt = { NULL };
int dual_color = 0;
int simple_color = -1;
struct option options[] = {
OPT_INTEGER(0, "creation-factor", &creation_factor,
N_("Percentage by which creation is weighted")),
OPT_BOOL(0, "dual-color", &dual_color,
OPT_BOOL(0, "no-dual-color", &simple_color,
N_("color both diff and diff-between-diffs")),
OPT_END()
};
Expand Down Expand Up @@ -53,8 +53,10 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
argc = j;
diff_setup_done(&diffopt);

if (dual_color) {
diffopt.use_color = 1;
if (simple_color < 1) {
if (!simple_color)
/* force color when --dual-color was used */
diffopt.use_color = 1;
diffopt.flags.dual_color_diffed_diffs = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ _git_range_diff ()
case "$cur" in
--*)
__gitcomp "
--creation-factor= --dual-color
--creation-factor= --no-dual-color
$__git_diff_common_options
"
return
Expand Down

0 comments on commit 4a68b95

Please sign in to comment.