[Wish] use postimage when showing common context in "diff -w"?
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 27, 2011, 22:16 UTC
- Message-ID
- <7vlipx4q3r.fsf@alter.siamese.dyndns.org>
Joey's "write first for-merge ref to FETCH_HEAD first" ($gmane/187699) wraps an existing large for(;;) loop inside another new loop, making the existing code indented deeper. After queuing the patch, "git show -w" displays a hunk like this [*1*]:
+ /*
+ * The first pass writes objects to be merged and then the
+ * second pass writes the rest, in order to allow using
+ * FETCH_HEAD as a refname to refer to the ref to be merged.
+ */
+ for (want_merge = 1; 0 <= want_merge; want_merge--) {
for (rm = ref_map; rm; rm = rm->next) {
struct ref *ref = NULL;
+ commit = lookup_commit_reference_gently(rm->old_sha1, 1);
+ if (!commit)
+ rm->merge = 0;
+
+ if (rm->merge != want_merge)
+ continue;
+
if (rm->peer_ref) {
ref = xcalloc(1, sizeof(*ref) + strlen(rm->peer_ref->name) + 1);
strcpy(ref->name, rm->peer_ref->name);The context lines we can see in the above hunk are shown with incorrect indentation level; I think we are showing the lines from the preimage.
It would be a really nice holiday gift to us, if somebody can fix this to show lines from the postimage. It would make reviewing the change much more pleasant. I obviously cannot throw this into my Amazon wishlist, so instead I am posting it here ;-)
[Footnote]
*1* The text has my style fix-ups in it and does not match what was posted. The patch lacked a sign-off and needs to be amended anyway. Also it needs to adjust some existing tests (at least 5515 seems to break for obvious reasons).