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

[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).

Next: René Scharfe
Message 1 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.