{"thread":{"id":"30836","subject":"Blaming differences","startedAt":"2012-06-18T22:56:55Z","lastAt":"2012-06-20T02:45:46Z","messageCount":4,"participants":["Phil Hord","Thomas Rast","Chris Packham"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193817","messageId":"CABURp0omoLoNaOhD3Vx734aVtm5sbk0E7_2uaZJWrWs=_g84iA@mail.gmail.com","threadId":"30836","inReplyTo":null,"subject":"Blaming differences","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2012-06-18T22:56:55Z","receivedAt":"2012-06-18T22:56:55Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"I want something like a product of diff and blame.  I want to see some\nkind of \"blame\" output for each line of \"diff -U0\".\n\nI tried something like this:\n   git blame $changed_files\n\nIs there such a command already?\n\nI'd also like to do something of the inverse operation:  I want to\nfind commits within a range whose changes are NOT in some other\ncommit.   So, say I have these four commits\n   A---B---C---D\n\nWhere D was created by 'git revert B'.\nI'd like to find out somehow that this is equivalent to\n   A--C\n\nSo that if I remove B and D completely, the with just A and C will get\nme to the same end result.\n\nSomething like 'git list-contributors HEAD' which would show me A and\nC, since these are the only commits that appear in any 'git blame\n$any_file'.\n\nDo these tools exist?  Is it too expensive?\n\nPhil\n"},{"id":"193819","messageId":"87hau76aqr.fsf@thomas.inf.ethz.ch","threadId":"30836","inReplyTo":"CABURp0omoLoNaOhD3Vx734aVtm5sbk0E7_2uaZJWrWs=_g84iA@mail.gmail.com","subject":"Re: Blaming differences","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-06-19T07:07:08Z","receivedAt":"2012-06-19T07:07:08Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n> I want something like a product of diff and blame.  I want to see some\n> kind of \"blame\" output for each line of \"diff -U0\".\n>\n> I tried something like this:\n>    git blame $changed_files\n>\n> Is there such a command already?\n\nPerhaps the WIP 'log -L' feature can help:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/199385\n\n> I'd also like to do something of the inverse operation:  I want to\n> find commits within a range whose changes are NOT in some other\n> commit.   So, say I have these four commits\n>    A---B---C---D\n>\n> Where D was created by 'git revert B'.\n> I'd like to find out somehow that this is equivalent to\n>    A--C\n>\n> So that if I remove B and D completely, the with just A and C will get\n> me to the same end result.\n>\n> Something like 'git list-contributors HEAD' which would show me A and\n> C, since these are the only commits that appear in any 'git blame\n> $any_file'.\n\nI wonder if these are really equivalent.  The first one is perhaps not\nfeasible: If it can only detect exact reverts, that's not incredibly\nhelpful; the commit message will probably tell you that it's a revert\nanyway.  I suspect that distinguishing conflicted reverts from true\nchanges is AI-complete.  You're free to go and try, though :-)\n\nThe second one, \"find all commits which appear in blame output\", is\ndifferent: it would only list commits which have surviving lines.  For\nexample,\n\n  $ git blame --incremental commit.h | grep -E -o '^[0-9a-f]{40}' | sort -u | wc -l\n  77\n  $ git rev-list --no-merges HEAD -- commit.h | wc -l\n  110\n\ntells me that there are 33 commits changing commit.h without any\nsurviving lines.  However there were no reverts:\n\n  $ git log --grep=Revert -- commit.h\n\ncomes up empty.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"193914","messageId":"CAFOYHZAyRUwnguvbkk_SDqiSJ=Z3mOdtDLZ+yQMep91cgK+Bww@mail.gmail.com","threadId":"30836","inReplyTo":"CABURp0omoLoNaOhD3Vx734aVtm5sbk0E7_2uaZJWrWs=_g84iA@mail.gmail.com","subject":"Re: Blaming differences","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2012-06-20T00:35:33Z","receivedAt":"2012-06-20T00:35:33Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Tue, Jun 19, 2012 at 10:56 AM, Phil Hord <phil.hord@gmail.com> wrote:\n> I want something like a product of diff and blame.  I want to see some\n> kind of \"blame\" output for each line of \"diff -U0\".\n>\n> I tried something like this:\n>   git blame $changed_files\n>\n> Is there such a command already?\n>\n> I'd also like to do something of the inverse operation:  I want to\n> find commits within a range whose changes are NOT in some other\n> commit.   So, say I have these four commits\n>   A---B---C---D\n>\n> Where D was created by 'git revert B'.\n> I'd like to find out somehow that this is equivalent to\n>   A--C\n>\n> So that if I remove B and D completely, the with just A and C will get\n> me to the same end result.\n>\n> Something like 'git list-contributors HEAD' which would show me A and\n> C, since these are the only commits that appear in any 'git blame\n> $any_file'.\n>\n> Do these tools exist?  Is it too expensive?\n>\n> Phil\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nI've just run into a situation at $dayjob where something like this\nwould be useful for me so I thought I'd throw my use-case into the mix\nif anyone decides to pick this idea up.\n\nI'm doing a peer review of a modest project that's been developed off\nin a branch of it's own before it will be merged back to master. Our\ncurrent policy is to let these project merges reflect reality warts an\nall (e.g. leave in commits and their reverts even if the net result is\n0 lines changed). I don't want to waist too much time reviewing commit\nby commit, especially when one commit might heavily refactor code from\nan earlier one. However looking at the full 'git diff project\n^origin/master' is a bit more code that I can keep in my brain at one\ntime. What I'd find useful is the output of 'git diff project\n^origin/master' marked up with the sha1s which I could then use as a\nleaping off point.\n\nSomething like this could get me part way there\n\n  for x in $(git diff --name-only project ^origin/master)\n  do\n    echo git blame project ^origin/master -- $x >$x.ann\n  done\n\nBut I'd still have to figure out how to reduce the annotated files\ndown to something useful. The git blame -L option might help if I\ncould specify it multiple times and parse the diff output,\nalternatively since it's not a huge number of revs I multiple\ninvocations of git blame would work for me. I'll have a go at hacking\nsomething up after lunch.\n"},{"id":"193917","messageId":"CAFOYHZD9+P1Gkdu4QE01A+ytJsWdAs4f2f2-=QqHt7-ur092xA@mail.gmail.com","threadId":"30836","inReplyTo":"CAFOYHZAyRUwnguvbkk_SDqiSJ=Z3mOdtDLZ+yQMep91cgK+Bww@mail.gmail.com","subject":"Re: Blaming differences","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2012-06-20T02:45:46Z","receivedAt":"2012-06-20T02:45:46Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Wed, Jun 20, 2012 at 12:35 PM, Chris Packham <judge.packham@gmail.com> wrote:\n> On Tue, Jun 19, 2012 at 10:56 AM, Phil Hord <phil.hord@gmail.com> wrote:\n>> I want something like a product of diff and blame.  I want to see some\n>> kind of \"blame\" output for each line of \"diff -U0\".\n>>\n>> I tried something like this:\n>>   git blame $changed_files\n>>\n>> Is there such a command already?\n>>\n>> I'd also like to do something of the inverse operation:  I want to\n>> find commits within a range whose changes are NOT in some other\n>> commit.   So, say I have these four commits\n>>   A---B---C---D\n>>\n>> Where D was created by 'git revert B'.\n>> I'd like to find out somehow that this is equivalent to\n>>   A--C\n>>\n>> So that if I remove B and D completely, the with just A and C will get\n>> me to the same end result.\n>>\n>> Something like 'git list-contributors HEAD' which would show me A and\n>> C, since these are the only commits that appear in any 'git blame\n>> $any_file'.\n>>\n>> Do these tools exist?  Is it too expensive?\n>>\n>> Phil\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n> I've just run into a situation at $dayjob where something like this\n> would be useful for me so I thought I'd throw my use-case into the mix\n> if anyone decides to pick this idea up.\n>\n> I'm doing a peer review of a modest project that's been developed off\n> in a branch of it's own before it will be merged back to master. Our\n> current policy is to let these project merges reflect reality warts an\n> all (e.g. leave in commits and their reverts even if the net result is\n> 0 lines changed). I don't want to waist too much time reviewing commit\n> by commit, especially when one commit might heavily refactor code from\n> an earlier one. However looking at the full 'git diff project\n> ^origin/master' is a bit more code that I can keep in my brain at one\n> time. What I'd find useful is the output of 'git diff project\n> ^origin/master' marked up with the sha1s which I could then use as a\n> leaping off point.\n>\n> Something like this could get me part way there\n>\n>  for x in $(git diff --name-only project ^origin/master)\n>  do\n>    echo git blame project ^origin/master -- $x >$x.ann\n>  done\n>\n> But I'd still have to figure out how to reduce the annotated files\n> down to something useful. The git blame -L option might help if I\n> could specify it multiple times and parse the diff output,\n> alternatively since it's not a huge number of revs I multiple\n> invocations of git blame would work for me. I'll have a go at hacking\n> something up after lunch.\n\nSo here's my initial attempt. Definitely a long way to go but I think\nit illustrates the concept. It actually throws away the diff output\nand produces blame output for the lines modified as a result it\ndoesn't cover annotating lines that have been removed. Ideally the\nwhole diff would be marked up and we'd see annotations for lines that\nare added or removed as well as for context lines (if present).\n"}]}