{"thread":{"id":"27085","subject":"Interdiff between amended commits","startedAt":"2011-04-13T11:54:38Z","lastAt":"2011-04-14T08:47:42Z","messageCount":4,"participants":["Stefan Haller","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"165740","messageId":"1jzlxb0.12qxbsl1na9qhzM%lists@haller-berlin.de","threadId":"27085","inReplyTo":null,"subject":"Interdiff between amended commits","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2011-04-13T11:54:38Z","receivedAt":"2011-04-13T11:54:38Z","isPatch":false,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"I'd like to show an interdiff between two commits, e.g. when a commit\nwas amended.\n\nI'm aware of the \"intercommit\" alias in the git wiki:\n\n  $ git show commit1 > .git/commit1 && git show commit2 > .git/commit2 && interdiff .git/commit[12]\n\nIt only works for simple cases though, and I'd also like to avoid the\ndependency to an external tool if possible.\n\nSo one thing I came up with is this:\n\n  git checkout commit1^\n  git cherry-pick --no-commit commit2\n  git diff --cached\n\nTwo problems:\n\n1) It requires a non-bare clone. At the place where I need it (on a\n   server that sends commit emails) I only have a bare clone, so ideally\n   I'd like something that doesn't need a working directory at all.\n\n2) I'm not sure what to do if the cherry-pick doesn't apply cleanly.\n   (The interdiff command has the same problem, of course).\n   I don't even know what information I want to see in that case;\n   anybody have an idea?\n\nAny other thoughts about this are appreciated.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"165798","messageId":"4DA69D7F.5050304@drmicha.warpmail.net","threadId":"27085","inReplyTo":"1jzlxb0.12qxbsl1na9qhzM%lists@haller-berlin.de","subject":"Re: Interdiff between amended commits","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-04-14T07:08:47Z","receivedAt":"2011-04-14T07:08:47Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Stefan Haller venit, vidit, dixit 13.04.2011 13:54:\n> I'd like to show an interdiff between two commits, e.g. when a commit\n> was amended.\n> \n> I'm aware of the \"intercommit\" alias in the git wiki:\n> \n>   $ git show commit1 > .git/commit1 && git show commit2 > .git/commit2 && interdiff .git/commit[12]\n> \n\nThis basically computes the diff between two patches, using a tool which\ngroks the patch format.\n\n> It only works for simple cases though, and I'd also like to avoid the\n> dependency to an external tool if possible.\n\nYou could use git diff --no-index instead, so that would work in really\nsimple cases only, probably.\n\n> \n> So one thing I came up with is this:\n> \n>   git checkout commit1^\n>   git cherry-pick --no-commit commit2\n>   git diff --cached\n\nThat does something completely different. It compares the tree of\ncommit1^ with the tree of (commit1^ with commit2's patch applied). I\ndon't see how commit1's patch plays any role here.\n\nDepending on what your actual use case, you may be happier with \"git\ndiff commit1 commit2\". Alternatively, you may produce a fake merge with\nparents commit1 and commit2 and tree commit1^ and look at \"show -R -c\"\nfor that. Sounds weird, I know ;)\n\nMichael\n"},{"id":"165800","messageId":"1jzpkig.1g2zjmtgv7a68M%lists@haller-berlin.de","threadId":"27085","inReplyTo":"4DA69D7F.5050304@drmicha.warpmail.net","subject":"Re: Interdiff between amended commits","fromName":"Stefan Haller","fromEmail":"lists@haller-berlin.de","sentAt":"2011-04-14T08:09:06Z","receivedAt":"2011-04-14T08:09:06Z","isPatch":false,"sender":{"key":"lists@haller-berlin.de","avatar":null},"body":"Michael J Gruber <git@drmicha.warpmail.net> wrote:\n\n> > So one thing I came up with is this:\n> > \n> >   git checkout commit1^\n> >   git cherry-pick --no-commit commit2\n> >   git diff --cached\n> \n> That does something completely different. It compares the tree of\n> commit1^ with the tree of (commit1^ with commit2's patch applied). I\n> don't see how commit1's patch plays any role here.\n\nSorry, that was just a typo.  I meant\n\n  git diff --cached commit1\n\nas the last line, of course.\n\nAlternatively, I could do it the other way round, by saying\n\n  git checkout commit2^\n  git cherry-pick --no-commit commit1\n  git diff --cached -R commit2\n\nThat should produce the same result (except maybe for the line numbers\nin the hunk headers), as long as the cherry-pick didn't have conflicts.\n\n> Depending on what your actual use case, you may be happier with \"git\n> diff commit1 commit2\"\n\nNo, that's not what I want (except when commit1 and commit2 have the\nsame parent).  This would also show the differences between the parents\nof commit1 and commit2; I don't want to include those.\n\nMy actual use case is that I have a central repository that sends out\ncommit emails; when someone does an interactive rebase and amends a\ncommit in the middle of a branch, I want to match up corresponding\ncommits based on their subject line, and then send an email showing how\nthe diff for that commit changed.\n\n\n-- \nStefan Haller\nBerlin, Germany\nhttp://www.haller-berlin.de/\n"},{"id":"165801","messageId":"4DA6B4AE.1090701@drmicha.warpmail.net","threadId":"27085","inReplyTo":"1jzpkig.1g2zjmtgv7a68M%lists@haller-berlin.de","subject":"Re: Interdiff between amended commits","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-04-14T08:47:42Z","receivedAt":"2011-04-14T08:47:42Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Stefan Haller venit, vidit, dixit 14.04.2011 10:09:\n> Michael J Gruber <git@drmicha.warpmail.net> wrote:\n> \n>>> So one thing I came up with is this:\n>>>\n>>>   git checkout commit1^\n>>>   git cherry-pick --no-commit commit2\n>>>   git diff --cached\n>>\n>> That does something completely different. It compares the tree of\n>> commit1^ with the tree of (commit1^ with commit2's patch applied). I\n>> don't see how commit1's patch plays any role here.\n> \n> Sorry, that was just a typo.  I meant\n> \n>   git diff --cached commit1\n> \n> as the last line, of course.\n> \n> Alternatively, I could do it the other way round, by saying\n> \n>   git checkout commit2^\n>   git cherry-pick --no-commit commit1\n>   git diff --cached -R commit2\n> \n> That should produce the same result (except maybe for the line numbers\n> in the hunk headers), as long as the cherry-pick didn't have conflicts.\n> \n>> Depending on what your actual use case, you may be happier with \"git\n>> diff commit1 commit2\"\n> \n> No, that's not what I want (except when commit1 and commit2 have the\n> same parent).  This would also show the differences between the parents\n> of commit1 and commit2; I don't want to include those.\n> \n> My actual use case is that I have a central repository that sends out\n> commit emails; when someone does an interactive rebase and amends a\n> commit in the middle of a branch, I want to match up corresponding\n> commits based on their subject line, and then send an email showing how\n> the diff for that commit changed.\n\nIn that case, \"git diff --no-index\" on the two patches (i.e. the alias\nyou found with \"interdiff\" replaced) may be worth a try. We should be\nable to teach our diff machinery about our diffs :) I mean, see userdiff\nand funcname.\n\nMichael\n"}]}