[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Zebras in Git
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Zebras in Git |
Date: |
Tue, 24 Apr 2018 22:48:25 +0200 |
On Tue, 24 Apr 2018 18:04:29 +0000 Greg Chicares <address@hidden> wrote:
GC> I'm still not satisfied: I want git-diff to tell me that the cyan and
GC> fuchsia blocks are identical. Or maybe that's actually what "color-moved"
GC> is supposed to indicate?
Yes, this is the entire point of this option. The changed lines are still
shown with the removed/added colours instead of the zebra colours
(red/green by default). E.g. if I apply the following patch:
---------------------------------- >8 --------------------------------------
diff --git a/wx_table_generator.cpp b/wx_table_generator.cpp
index a38d0c481..458f6a96f 100644
--- a/wx_table_generator.cpp
+++ b/wx_table_generator.cpp
@@ -43,28 +43,6 @@ void increase_to_if_smaller(T& first, T second)
} // Unnamed namespace.
-wx_table_generator::wx_table_generator
- (wxDC& dc
- ,int left_margin
- ,int total_width
- )
- :dc_(dc)
- ,left_margin_(left_margin)
- ,total_width_(total_width)
- ,char_height_(dc_.GetCharHeight())
- ,row_height_((4 * char_height_ + 2) / 3) // Arbitrarily use 1.333 line
spacing.
- ,column_margin_(dc_.GetTextExtent("M").x)
- ,column_widths_already_computed_(false)
- ,max_header_lines_(1)
-{
- // Set a pen with 0 width to get the thin lines and butt cap style for the
- // different segments drawn in do_output_values() to seamlessly combine
- // into a single line.
- wxPen pen(*wxBLACK, 0);
- pen.SetCap(wxCAP_ROUND);
- dc_.SetPen(pen);
-}
-
void wx_table_generator::use_condensed_style()
{
row_height_ = char_height_;
@@ -662,3 +640,25 @@ void wx_table_generator::do_compute_column_widths()
output_vert_separator(column, y);
}
+
+wx_table_generator::wx_table_generator
+ (wxDC& dc
+ ,int left_margin
+ ,int total_width
+ )
+ :dc_(dc)
+ ,left_margin_(left_margin)
+ ,total_width_(total_width)
+ ,char_height_(dc_.GetCharHeight())
+ ,row_height_((4 * char_height_ + 2) / 3) // Arbitrarily use 1.333 line
spacing.
+ ,column_margin_(dc_.GetTextExtent("M").x)
+ ,column_widths_already_computed_(false)
+ ,max_header_lines_(1)
+{
+ // Set a pen with 0 width to get the thin lines and butt cap style for the
+ // different segments drawn in do_output_values() to seamlessly combine
+ // into a single line.
+ wxPen pen(*wxBLACK, 0);
+ pen.SetCap(wxCAP_BUTT);
+ dc_.SetPen(pen);
+}
---------------------------------- >8 --------------------------------------
Then "git diff --color-moved" shows the last 3 lines in green (because I
surreptitiously changed the cap style), the corresponding lines starting
with "-" in red (removed), and the rest of the "-" and "+" lines (except
the new line before the ctor, which is also added, and hence green) is
shown in color.diff.{old,new}Moved colours.
BTW, with code which is just moved, I couldn't see any utility for
--color-moved=plain, but with the patch above, it's actually useful as it's
more precise and highlights only the pen.SetCap() line itself differently,
while zebra apparently has some minimal block size.
GC> But...why wasn't "dimmed_zebra" dimmed?
I'm not sure why did they call it "dimmed", but OTOH I can't think of a
better name anyhow... AFAICS it just doesn't highlight the "-" moved lines
at all and highlights the "+" moved lines in reverse video. It might be
less confusing/more readable than "plain" or "zebra" when there are many
moved blocks, I guess.
GC> Now I'm all confused. And sleepy. Please tell me--if one '+' block is
GC> cerulean and there's a lilac '-' block of the same size, and those are
GC> the only two blocks in unusual colors...then am I entitled to assume
GC> that git has verified that they're identical?
Yes.
GC> BTW, did you also notice the '--anchored=' option?
I was vaguely aware of its existence, I think, but I don't remember having
ever used it in anger.
GC> In the past, I used such an option with an ancient GUI diff program for
GC> reviewing changes of this nature. First force the moved parts to line
GC> up, and make sure there's no change in them (which would be
GC> highlighted); then un-anchor the moved parts, and make sure there's no
GC> change anywhere else. To me, the lack of such "anchoring" is the
GC> biggest drawback of 'meld', so I was excited to see that it's been
GC> added to git-diff. Or excited to discover that it's always been there
GC> but I hadn't noticed it. Anyway, it was pretty exciting.
Sorry, I can't get excited because I still don't see how/why/when would I
use it. Can you produce some useful output using it with the diff above? Or
does it need a different kind of change to really show its usefulness?
Anyhow, I've got enough excitement with the discovery of zebras in Git for
one day, so I'm not complaining.
VZ
- [lmi] Zebras in Git (was: [lmi-commits] master 2f7c850 1/8: Transplant implementation of a nested class), Vadim Zeitlin, 2018/04/24
- Re: [lmi] Zebras in Git, Greg Chicares, 2018/04/24
- [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type> [Was: Zebras in Git], Greg Chicares, 2018/04/24
- Re: [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type>, Vadim Zeitlin, 2018/04/24
- Re: [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type>, Greg Chicares, 2018/04/24
- Re: [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type>, Vadim Zeitlin, 2018/04/25
- Re: [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type>, Greg Chicares, 2018/04/25
- Re: [lmi] libstdc++ in gcc-7.3.0: std::vector<incomplete_type>, Vadim Zeitlin, 2018/04/25
Re: [lmi] Zebras in Git,
Vadim Zeitlin <=