{"thread":{"id":"9878","subject":"Blaming diffs","startedAt":"2007-09-16T16:38:29Z","lastAt":"2007-09-17T05:41:08Z","messageCount":7,"participants":["Mike Hommey","Frank Lichtenheld","Christian Couder","Shawn O. Pearce","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"53194","messageId":"20070916163829.GA6679@glandium.org","threadId":"9878","inReplyTo":null,"subject":"Blaming diffs","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-09-16T16:38:29Z","receivedAt":"2007-09-16T16:38:29Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"Hi,\n\nIt seems to me there is no tool to \"blame diffs\", i.e. something to know\nwhat commit(s) is(are) responsible for a set of changes.\n\nFor example, the following script tries to get the set of commits\ninvolved in the changes between $A and $B. Note it only works for text\nadditions. \n\ngit diff --unified=0 $A $B | awk 'BEGIN { FS=\"(^(--- a/|+++ b/)|^@@ -[0-9,]+ \\\\+| @@)\" } /^---/ || ( /^+++ b\\/(.*)/ && file==\"\" ) { file = $2 } /^@@/ {split($2, a, /,/); a[2] = a[2] ? a[2] + a[1] - 1 : a[1]; print \"git blame -l -L \" a[1] \",\" a[2], \"'$A..$B'\", file }' | sh | cut -f 1 -d \" \" | sort -u\n\nHas anyone tried to work on something similar yet ?\n\nIf not, as git users, what kind of output would you expect from such a\ntool, and where do you think this should lie (extension to git diff, or\nseparate tool) ?\n\nCheers,\n\nMike\n"},{"id":"53206","messageId":"20070916170534.GU22865@planck.djpig.de","threadId":"9878","inReplyTo":"20070916163829.GA6679@glandium.org","subject":"Re: Blaming diffs","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-09-16T17:05:35Z","receivedAt":"2007-09-16T17:05:35Z","isPatch":false,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Sun, Sep 16, 2007 at 06:38:29PM +0200, Mike Hommey wrote:\n> It seems to me there is no tool to \"blame diffs\", i.e. something to know\n> what commit(s) is(are) responsible for a set of changes.\n> \n> For example, the following script tries to get the set of commits\n> involved in the changes between $A and $B. Note it only works for text\n> additions. \n> \n> git diff --unified=0 $A $B | awk 'BEGIN { FS=\"(^(--- a/|+++ b/)|^@@ -[0-9,]+ \\\\+| @@)\" } /^---/ || ( /^+++ b\\/(.*)/ && file==\"\" ) { file = $2 } /^@@/ {split($2, a, /,/); a[2] = a[2] ? a[2] + a[1] - 1 : a[1]; print \"git blame -l -L \" a[1] \",\" a[2], \"'$A..$B'\", file }' | sh | cut -f 1 -d \" \" | sort -u\n> \n> Has anyone tried to work on something similar yet ?\n> \n> If not, as git users, what kind of output would you expect from such a\n> tool, and where do you think this should lie (extension to git diff, or\n> separate tool) ?\n\nWhat do you use for $A and $B? commits? What is the difference between\nyour script and \"git log --pretty=format:%H $A..$B\"\nthen?\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"53196","messageId":"20070916171635.GA8868@glandium.org","threadId":"9878","inReplyTo":"20070916170534.GU22865@planck.djpig.de","subject":"Re: Blaming diffs","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2007-09-16T17:16:35Z","receivedAt":"2007-09-16T17:16:35Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Sun, Sep 16, 2007 at 07:05:35PM +0200, Frank Lichtenheld <frank@lichtenheld.de> wrote:\n> On Sun, Sep 16, 2007 at 06:38:29PM +0200, Mike Hommey wrote:\n> > It seems to me there is no tool to \"blame diffs\", i.e. something to know\n> > what commit(s) is(are) responsible for a set of changes.\n> > \n> > For example, the following script tries to get the set of commits\n> > involved in the changes between $A and $B. Note it only works for text\n> > additions. \n> > \n> > git diff --unified=0 $A $B | awk 'BEGIN { FS=\"(^(--- a/|+++ b/)|^@@ -[0-9,]+ \\\\+| @@)\" } /^---/ || ( /^+++ b\\/(.*)/ && file==\"\" ) { file = $2 } /^@@/ {split($2, a, /,/); a[2] = a[2] ? a[2] + a[1] - 1 : a[1]; print \"git blame -l -L \" a[1] \",\" a[2], \"'$A..$B'\", file }' | sh | cut -f 1 -d \" \" | sort -u\n> > \n> > Has anyone tried to work on something similar yet ?\n> > \n> > If not, as git users, what kind of output would you expect from such a\n> > tool, and where do you think this should lie (extension to git diff, or\n> > separate tool) ?\n> \n> What do you use for $A and $B? commits? What is the difference between\n> your script and \"git log --pretty=format:%H $A..$B\"\n> then?\n\nIn my typical usecase, $A is upstream and $B is HEAD. What happens is\nthat my work branch includes some changes that have been merged upstream\nand some others that are not yet, or won't because it's not appropriate.\nI obviously occasionally merge the upstream branch back, in which case\nmy changes that were committed upstream don't appear in a git diff $A $B\nanymore.\n\ngit log --pretty=format:%H $A..$B would give me the list of all commits\nthat occurred on my branch, while my script only gives the commits\ncontaining changes that are still not applied upstream.\n\nMike\n"},{"id":"53258","messageId":"20070917045704.GH3099@spearce.org","threadId":"9878","inReplyTo":"200709170659.15655.chriscool@tuxfamily.org","subject":"Re: Blaming diffs","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-17T04:57:04Z","receivedAt":"2007-09-17T04:57:04Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> wrote:\n> Le dimanche 16 septembre 2007, Mike Hommey a écrit :\n> >\n> > It seems to me there is no tool to \"blame diffs\", i.e. something to know\n> > what commit(s) is(are) responsible for a set of changes.\n> \n> I don't know if that's what you are looking for but perhaps you could \n> use \"git bisect run\". You just need to pass it a script that returns 1 when \n> it finds the changes and 0 otherwise. (See git-bisect man page.)\n\nThat's very inefficient to search for something...\n \n> Sometimes ago I sent a patch that would allow \"!\" after \"git bisect run\", \n> but it seems to have been forgotten. This patch makes it possible to use:\n> \n> git bisect run ! grep some_stuff file1 file2...\n> \n> This would give you the commit where some_stuff was introduced in file1 or \n> file2...\n\nIs `git log -Ssome_stuff -- file1 file2` somehow not working for you?\n\n-- \nShawn.\n"},{"id":"53257","messageId":"200709170659.15655.chriscool@tuxfamily.org","threadId":"9878","inReplyTo":"20070916163829.GA6679@glandium.org","subject":"Re: Blaming diffs","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-09-17T04:59:15Z","receivedAt":"2007-09-17T04:59:15Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le dimanche 16 septembre 2007, Mike Hommey a écrit :\n> Hi,\n>\n> It seems to me there is no tool to \"blame diffs\", i.e. something to know\n> what commit(s) is(are) responsible for a set of changes.\n\nI don't know if that's what you are looking for but perhaps you could \nuse \"git bisect run\". You just need to pass it a script that returns 1 when \nit finds the changes and 0 otherwise. (See git-bisect man page.)\n\nSometimes ago I sent a patch that would allow \"!\" after \"git bisect run\", \nbut it seems to have been forgotten. This patch makes it possible to use:\n\ngit bisect run ! grep some_stuff file1 file2...\n\nThis would give you the commit where some_stuff was introduced in file1 or \nfile2...\n\nRegards,\nChristian.\n"},{"id":"53259","messageId":"200709170740.00917.chriscool@tuxfamily.org","threadId":"9878","inReplyTo":"20070917045704.GH3099@spearce.org","subject":"Re: Blaming diffs","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-09-17T05:40:00Z","receivedAt":"2007-09-17T05:40:00Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le lundi 17 septembre 2007, Shawn O. Pearce a écrit :\n> Christian Couder <chriscool@tuxfamily.org> wrote:\n> > I don't know if that's what you are looking for but perhaps you could\n> > use \"git bisect run\". You just need to pass it a script that returns 1\n> > when it finds the changes and 0 otherwise. (See git-bisect man page.)\n>\n> That's very inefficient to search for something...\n\nPerhaps but you can search using whatever script or command you want/know. \nYou are not limited by those implemented in git.\n\nYou can also make it more efficient with \"git bisect {start,good,bad}\".\n\nRegards,\nChristian.\n"},{"id":"53260","messageId":"7vy7f53l3f.fsf@gitster.siamese.dyndns.org","threadId":"9878","inReplyTo":"200709170740.00917.chriscool@tuxfamily.org","subject":"Re: Blaming diffs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-17T05:41:08Z","receivedAt":"2007-09-17T05:41:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> Le lundi 17 septembre 2007, Shawn O. Pearce a écrit :\n>> Christian Couder <chriscool@tuxfamily.org> wrote:\n>> > I don't know if that's what you are looking for but perhaps you could\n>> > use \"git bisect run\". You just need to pass it a script that returns 1\n>> > when it finds the changes and 0 otherwise. (See git-bisect man page.)\n>>\n>> That's very inefficient to search for something...\n>\n> Perhaps but you can search using whatever script or command you want/know. \n> You are not limited by those implemented in git.\n>\n> You can also make it more efficient with \"git bisect {start,good,bad}\".\n\nI _think_ the inefficiency Shawn refers to is that \"git bisect\"\nwrapper inherently is based on checking out the revision.  It is\nsimilar to \"filter-branch --tree-filter\" being much more\ninefficient than \"filter-branch --index-filter\" (the latter only\nworks with index while the former does a full checkout).\n\nThe underlying \"git rev-list --bisect\" can be used to ask for\nsequence of commits to check if your check does not require a\nfull checkout, but there is no wrapper like \"git bisect\" that \nuses that mode of operation.\n"}]}