git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] xdiff: print post-image for common records instead of pre-image

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 10, 2012, 22:58 UTC
Message-ID
<7vy5tf88rh.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4F072B9C.1030005@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 10 quoted lines
> Normally it doesn't matter if we show the pre-image or th post-image
> for the common parts of a diff because they are the same.  If
> white-space changes are ignored they can differ, though.  The
> new text after applying the diff is more interesting in that case,
> so show that instead of the old contents.
>
> Note: GNU diff shows the pre-image.
>
> Suggested-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>

I was looking at this one again, and I think one possible downside of showing post-image for the context lines is that the resulting patch would not apply to the pre-image tree anymore. Probably GNU folks thought that it is a big enough issue. Or perhaps they didn't simply care either way ;-)

In any case, showing pre-image lines as the context at least makes the patch easier to apply, but the result would be different from the intended post-image and would appear as if indentation fixes in the patch are reverted, so you would need manual fix-up after applying such a patch generated with (gnu) "diff -w".

I tried to generate an output from "show -w", with this change, on a commit that is largely indentation fix. The resulting patch seems to apply cleanly with "apply --ignore-space-change" to the parent of the commit "show -w" was taken from; of course the result needs some manual fix-ups for the indentation changes, but that is not a news anyway. So I suspect it won't be a huge downside and I think the benefit of being able to see the post-image in the context when the user is more interested in how the file looks like after the change outweighs it.

Thanks again.
Previous: Junio C Hamano
Message 4 of 4 in “[Wish] use postimage when showing common context in "diff -w"?”
  1. Junio C HamanoDec 27, 2011
  2. xdiff: print post-image for common records instead of pre-imageRené Scharfe, Jan 6, 2012
  3. Junio C HamanoJan 6, 2012
  4. Junio C HamanoJan 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.