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

Re: Interdiff between amended commits

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 14, 2011, 07:08 UTC
Message-ID
<4DA69D7F.5050304@drmicha.warpmail.net>
In-Reply-To
<1jzlxb0.12qxbsl1na9qhzM%lists@haller-berlin.de>
Stefan Haller venit, vidit, dixit 13.04.2011 13:54:
Show 7 quoted lines
> I'd like to show an interdiff between two commits, e.g. when a commit
> was amended.
> 
> I'm aware of the "intercommit" alias in the git wiki:
> 
>   $ git show commit1 > .git/commit1 && git show commit2 > .git/commit2 && interdiff .git/commit[12]
> 

This basically computes the diff between two patches, using a tool which groks the patch format.

> It only works for simple cases though, and I'd also like to avoid the
> dependency to an external tool if possible.

You could use git diff --no-index instead, so that would work in really simple cases only, probably.

Show 6 quoted lines
> 
> So one thing I came up with is this:
> 
>   git checkout commit1^
>   git cherry-pick --no-commit commit2
>   git diff --cached

That does something completely different. It compares the tree of commit1^ with the tree of (commit1^ with commit2's patch applied). I don't see how commit1's patch plays any role here.

Depending on what your actual use case, you may be happier with "git diff commit1 commit2". Alternatively, you may produce a fake merge with parents commit1 and commit2 and tree commit1^ and look at "show -R -c" for that. Sounds weird, I know ;)

Michael
Previous: Stefan HallerNext: Stefan Haller
Message 2 of 4 in “Interdiff between amended commits”
  1. Stefan HallerApr 13, 2011
  2. Michael J GruberApr 14, 2011
  3. Stefan HallerApr 14, 2011
  4. Michael J GruberApr 14, 2011

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.