Re: make git diff output easier to read - use better diff heuristics
- From
Jeff King <peff@peff.net>
- Date
- Feb 13, 2018, 16:08 UTC
- Message-ID
- <20180213160824.GA5203@sigill.intra.peff.net>
- In-Reply-To
- <CAOmC-AncOZfAwowXLjwDbL9Bdx1+=RbXsrd72LzEBd2W-=LAQg@mail.gmail.com>
On Tue, Feb 13, 2018 at 05:06:15PM +0200, Σπύρος Βαζαίος wrote:
Show 11 quoted lines
> Hi, I've came across an issue when using the git diff command. In > particular the diff is different to what the svn diff produces. While > both being correct the output of the svn diff is easier to understand > than the git diff one. See the following issue on github where I > initially reported the issue: > > https://github.com/git-for-windows/git/issues/1494 > > I have Included a picture to better illustrate the problem. What do > you think? Is it possible to make git diff output similar to svn diff > regarding this issue?
Try "git diff --no-indent-heuristic", which makes your example look better. Here's a quick reproduction:
-- >8 --
cat >foo.c <<\EOF
static struct foo bar[] = {
#ifdef SOMETHING
{ "stats.info", MNU_GBX_FSTAINF, etc },
{ "expired.info", MNU_GBX_FSTAINF, etc },
{ "info.log", MNU_GBX_INFOLOG, etc },
#endif
{ NULL, 0, 0 },
};
EOFsed '6a\
#ifdef WITH_EMU\
{ "SoftCam.Key", MNU_CFG_FSOFTCAMKEY, etc },\
#endif
' <foo.c >bar.c
-- 8< --Now this looks ugly:
git diff --no-index foo.c bar.c
but this does not:
git diff --no-index --no-indent-heuristic foo.c bar.c
That heuristic is described in 433860f3d0 (diff: improve positioning of add/delete blocks in diffs, 2016-09-05). I'm not sure exactly why it does the wrong thing here, or if it would be possible to tweak the weighting factors to make it work.
-Peff