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

Re: git show -m with a parent number

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2016, 19:31 UTC
Message-ID
<xmqqoa9yxuuv.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160328191608.GA22602@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 9 quoted lines
> On Sun, Mar 27, 2016 at 08:46:02PM +0000, Anatoly Borodin wrote:
>
>> is there a good reason for `git show -m` to not accept the number of a
>> parent of a merge commit? I can run `git show --first-parent COMMIT`,
>> but need to write `git diff COMMIT^2 COMMIT` every time I want to diff
>> with the second parent!
>
> I think it could, but nobody has yet found it useful enough to
> implement.

For "git show" that does not traverse the history, there may be occasions where showing a diff with the second parent might make sense (e.g. the user merged two histories in a wrong direction in the past and it is too late to rewrite).

I think there are two reasons behind the current state. Because it does not make any sense for "git log -m 2" to show diff with its second parent while traversing many commits, the "git log" codepath is not prepared to show diff with only nth parent. Because "git show" started its life merely as a thin wrapper around "git log", "git show" does not use such an underlying machinery to show diff with only nth parent that does not exist.

Previous: Jeff KingNext: Anatoly Borodin
Message 3 of 5 in “git show -m with a parent number”
  1. Anatoly BorodinMar 27, 2016
  2. Jeff KingMar 28, 2016
  3. Junio C HamanoMar 28, 2016
  4. Anatoly BorodinMar 30, 2016
  5. Andreas SchwabMar 30, 2016

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.