From 1cdde296a5d3b0fd17a3fcd7a0869550b064fdce Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 13 Aug 2018 04:33:11 -0700 Subject: range-diff: suppress the diff headers When showing the diff between corresponding patches of the two branch versions, we have to make up a fake filename to run the diff machinery. That filename does not carry any meaningful information, hence tbdiff suppresses it. So we should, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff.h | 1 + 1 file changed, 1 insertion(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index a14895bb82..d88ceb3570 100644 --- a/diff.h +++ b/diff.h @@ -94,6 +94,7 @@ struct diff_flags { unsigned funccontext:1; unsigned default_follow_renames:1; unsigned stat_with_summary:1; + unsigned suppress_diff_headers:1; }; static inline void diff_flags_or(struct diff_flags *a, -- cgit v1.2.3 From f7c3b4e2d8c16890c40c7e10e16cabb910f6b3ae Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 13 Aug 2018 04:33:20 -0700 Subject: diff: add an internal option to dual-color diffs of diffs When diffing diffs, it can be quite daunting to figure out what the heck is going on, as there are nested +/- signs. Let's make this easier by adding a flag in diff_options that allows color-coding the outer diff sign with inverted colors, so that the preimage and postimage is colored like the diff it is. Of course, this really only makes sense when the preimage and postimage *are* diffs. So let's not expose this flag via a command-line option for now. This is a feature that was invented by git-tbdiff, and it will be used by `git range-diff` in the next commit, by offering it via a new option: `--dual-color`. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff.h | 1 + 1 file changed, 1 insertion(+) (limited to 'diff.h') diff --git a/diff.h b/diff.h index d88ceb3570..cca4f9d6c9 100644 --- a/diff.h +++ b/diff.h @@ -95,6 +95,7 @@ struct diff_flags { unsigned default_follow_renames:1; unsigned stat_with_summary:1; unsigned suppress_diff_headers:1; + unsigned dual_color_diffed_diffs:1; }; static inline void diff_flags_or(struct diff_flags *a, -- cgit v1.2.3 From a7be92acd96007bcb4c1fd4e8602eeb5115312c2 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 13 Aug 2018 04:33:32 -0700 Subject: range-diff: use dim/bold cues to improve dual color mode It *is* a confusing thing to look at a diff of diffs. All too easy is it to mix up whether the -/+ markers refer to the "inner" or the "outer" diff, i.e. whether a `+` indicates that a line was added by either the old or the new diff (or both), or whether the new diff does something different than the old diff. To make things easier to process for normal developers, we introduced the dual color mode which colors the lines according to the commit diff, i.e. lines that are added by a commit (whether old, new, or both) are colored in green. In non-dual color mode, the lines would be colored according to the outer diff: if the old commit added a line, it would be colored red (because that line addition is only present in the first commit range that was specified on the command-line, i.e. the "old" commit, but not in the second commit range, i.e. the "new" commit). However, this dual color mode is still not making things clear enough, as we are looking at two levels of diffs, and we still only pick a color according to *one* of them (the outer diff marker is colored differently, of course, but in particular with deep indentation, it is easy to lose track of that outer diff marker's background color). Therefore, let's add another dimension to the mix. Still use green/red/normal according to the commit diffs, but now also dim the lines that were only in the old commit, and use bold face for the lines that are only in the new commit. That way, it is much easier not to lose track of, say, when we are looking at a line that was added in the previous iteration of a patch series but the new iteration adds a slightly different version: the obsolete change will be dimmed, the current version of the patch will be bold. At least this developer has a much easier time reading the range-diffs that way. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'diff.h') diff --git a/diff.h b/diff.h index cca4f9d6c9..e1e54256c1 100644 --- a/diff.h +++ b/diff.h @@ -248,7 +248,13 @@ enum color_diff { DIFF_FILE_NEW_MOVED = 13, DIFF_FILE_NEW_MOVED_ALT = 14, DIFF_FILE_NEW_MOVED_DIM = 15, - DIFF_FILE_NEW_MOVED_ALT_DIM = 16 + DIFF_FILE_NEW_MOVED_ALT_DIM = 16, + DIFF_CONTEXT_DIM = 17, + DIFF_FILE_OLD_DIM = 18, + DIFF_FILE_NEW_DIM = 19, + DIFF_CONTEXT_BOLD = 20, + DIFF_FILE_OLD_BOLD = 21, + DIFF_FILE_NEW_BOLD = 22, }; const char *diff_get_color(int diff_use_color, enum color_diff ix); #define diff_get_color_opt(o, ix) \ -- cgit v1.2.3