* Interdiff between amended commits
@ 2011-04-13 11:54 Stefan Haller
2011-04-14 7:08 ` Michael J Gruber
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Haller @ 2011-04-13 11:54 UTC (permalink / raw
To: git
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]
It only works for simple cases though, and I'd also like to avoid the
dependency to an external tool if possible.
So one thing I came up with is this:
git checkout commit1^
git cherry-pick --no-commit commit2
git diff --cached
Two problems:
1) It requires a non-bare clone. At the place where I need it (on a
server that sends commit emails) I only have a bare clone, so ideally
I'd like something that doesn't need a working directory at all.
2) I'm not sure what to do if the cherry-pick doesn't apply cleanly.
(The interdiff command has the same problem, of course).
I don't even know what information I want to see in that case;
anybody have an idea?
Any other thoughts about this are appreciated.
--
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Interdiff between amended commits
2011-04-13 11:54 Interdiff between amended commits Stefan Haller
@ 2011-04-14 7:08 ` Michael J Gruber
2011-04-14 8:09 ` Stefan Haller
0 siblings, 1 reply; 4+ messages in thread
From: Michael J Gruber @ 2011-04-14 7:08 UTC (permalink / raw
To: Stefan Haller; +Cc: git
Stefan Haller venit, vidit, dixit 13.04.2011 13:54:
> 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.
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Interdiff between amended commits
2011-04-14 7:08 ` Michael J Gruber
@ 2011-04-14 8:09 ` Stefan Haller
2011-04-14 8:47 ` Michael J Gruber
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Haller @ 2011-04-14 8:09 UTC (permalink / raw
To: Michael J Gruber; +Cc: git
Michael J Gruber <git@drmicha.warpmail.net> wrote:
> > 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.
Sorry, that was just a typo. I meant
git diff --cached commit1
as the last line, of course.
Alternatively, I could do it the other way round, by saying
git checkout commit2^
git cherry-pick --no-commit commit1
git diff --cached -R commit2
That should produce the same result (except maybe for the line numbers
in the hunk headers), as long as the cherry-pick didn't have conflicts.
> Depending on what your actual use case, you may be happier with "git
> diff commit1 commit2"
No, that's not what I want (except when commit1 and commit2 have the
same parent). This would also show the differences between the parents
of commit1 and commit2; I don't want to include those.
My actual use case is that I have a central repository that sends out
commit emails; when someone does an interactive rebase and amends a
commit in the middle of a branch, I want to match up corresponding
commits based on their subject line, and then send an email showing how
the diff for that commit changed.
--
Stefan Haller
Berlin, Germany
http://www.haller-berlin.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Interdiff between amended commits
2011-04-14 8:09 ` Stefan Haller
@ 2011-04-14 8:47 ` Michael J Gruber
0 siblings, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2011-04-14 8:47 UTC (permalink / raw
To: Stefan Haller; +Cc: git
Stefan Haller venit, vidit, dixit 14.04.2011 10:09:
> Michael J Gruber <git@drmicha.warpmail.net> wrote:
>
>>> 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.
>
> Sorry, that was just a typo. I meant
>
> git diff --cached commit1
>
> as the last line, of course.
>
> Alternatively, I could do it the other way round, by saying
>
> git checkout commit2^
> git cherry-pick --no-commit commit1
> git diff --cached -R commit2
>
> That should produce the same result (except maybe for the line numbers
> in the hunk headers), as long as the cherry-pick didn't have conflicts.
>
>> Depending on what your actual use case, you may be happier with "git
>> diff commit1 commit2"
>
> No, that's not what I want (except when commit1 and commit2 have the
> same parent). This would also show the differences between the parents
> of commit1 and commit2; I don't want to include those.
>
> My actual use case is that I have a central repository that sends out
> commit emails; when someone does an interactive rebase and amends a
> commit in the middle of a branch, I want to match up corresponding
> commits based on their subject line, and then send an email showing how
> the diff for that commit changed.
In that case, "git diff --no-index" on the two patches (i.e. the alias
you found with "interdiff" replaced) may be worth a try. We should be
able to teach our diff machinery about our diffs :) I mean, see userdiff
and funcname.
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-04-14 8:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 11:54 Interdiff between amended commits Stefan Haller
2011-04-14 7:08 ` Michael J Gruber
2011-04-14 8:09 ` Stefan Haller
2011-04-14 8:47 ` Michael J Gruber
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).