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