Re: [PATCH] xdiff: print post-image for common records instead of pre-image
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:46
René Scharfe [off-list ref] writes:
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 <redacted> Signed-off-by: Rene Scharfe <redacted>
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.