{"thread":{"id":"3328","subject":"diffstat wierdness with 'git format-patch' output","startedAt":"2006-02-14T05:54:25Z","lastAt":"2006-02-18T00:34:03Z","messageCount":11,"participants":["Greg KH","Junio C Hamano","Fredrik Kuivinen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"16089","messageId":"20060214055425.GA32261@kroah.com","threadId":"3328","inReplyTo":null,"subject":"diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T05:54:25Z","receivedAt":"2006-02-14T05:54:25Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"I was trying to use the built-in git tools to send patches off, instead\nof my horribly hacked up scripts that use the git low-level stuff, when\nI noticed that git format-patch's output confuses diffstat a bit, and\ncauses it to add another line to it's count.\n\nThis isn't good when I do a 'diffstat -p1 *.txt' of the output and add\nit to an email to send off for someone to pull from, as the result will\nbe off from what is really there.\n\nHere's what I get:\n\n $ git format-patch -n origin..HEAD\n 0001-USB-fix-up-the-usb-early-handoff-logic-for-EHCI.txt\n 0002-USB-add-new-device-ids-to-ldusb.txt\n 0003-USB-change-ldusb-s-experimental-state.txt\n 0004-USB-PL2303-Leadtek-9531-GPS-Mouse.txt\n 0005-USB-sl811_cs-needs-platform_device-conversion-too.txt\n 0006-usb-storage-new-unusual_devs-entry.txt\n 0007-usb-storage-unusual_devs-entry.txt\n 0008-USB-unusual_devs.h-entry-TrekStor-i.Beat.txt\n 0009-USB-unusual_devs.h-entry-iAUDIO-M5.txt\n 0010-USB-unusual-devs-bugfix.txt\n\n $ git log | head -n 1\n commit 16f05be7be0bf121491d83bd97337fe179b3b323\n\n $ git show 16f05be7be0bf121491d83bd97337fe179b3b323 | diffstat -p1\n  drivers/usb/storage/unusual_devs.h |   25 ++++++++++++++++++-------\n  1 file changed, 18 insertions(+), 7 deletions(-)\n\n $ diffstat -p1 0010-USB-unusual-devs-bugfix.txt\n  drivers/usb/storage/unusual_devs.h |   26 ++++++++++++++++++--------\n  1 file changed, 18 insertions(+), 8 deletions(-)\n\nAny thoughts?\n\nthanks,\n\ngreg k-h\n"},{"id":"16090","messageId":"20060214055648.GA592@kroah.com","threadId":"3328","inReplyTo":"20060214055425.GA32261@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T05:56:48Z","receivedAt":"2006-02-14T05:56:48Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 09:54:25PM -0800, Greg KH wrote:\n> I was trying to use the built-in git tools to send patches off, instead\n> of my horribly hacked up scripts that use the git low-level stuff, when\n> I noticed that git format-patch's output confuses diffstat a bit, and\n> causes it to add another line to it's count.\n> \n> This isn't good when I do a 'diffstat -p1 *.txt' of the output and add\n> it to an email to send off for someone to pull from, as the result will\n> be off from what is really there.\n> \n> Here's what I get:\n> \n>  $ git format-patch -n origin..HEAD\n>  0001-USB-fix-up-the-usb-early-handoff-logic-for-EHCI.txt\n>  0002-USB-add-new-device-ids-to-ldusb.txt\n>  0003-USB-change-ldusb-s-experimental-state.txt\n>  0004-USB-PL2303-Leadtek-9531-GPS-Mouse.txt\n>  0005-USB-sl811_cs-needs-platform_device-conversion-too.txt\n>  0006-usb-storage-new-unusual_devs-entry.txt\n>  0007-usb-storage-unusual_devs-entry.txt\n>  0008-USB-unusual_devs.h-entry-TrekStor-i.Beat.txt\n>  0009-USB-unusual_devs.h-entry-iAUDIO-M5.txt\n>  0010-USB-unusual-devs-bugfix.txt\n> \n>  $ git log | head -n 1\n>  commit 16f05be7be0bf121491d83bd97337fe179b3b323\n> \n>  $ git show 16f05be7be0bf121491d83bd97337fe179b3b323 | diffstat -p1\n>   drivers/usb/storage/unusual_devs.h |   25 ++++++++++++++++++-------\n>   1 file changed, 18 insertions(+), 7 deletions(-)\n> \n>  $ diffstat -p1 0010-USB-unusual-devs-bugfix.txt\n>   drivers/usb/storage/unusual_devs.h |   26 ++++++++++++++++++--------\n>   1 file changed, 18 insertions(+), 8 deletions(-)\n> \n> Any thoughts?\n\nHm, in looking at it closer, it's probably the last two lines of the\nfile, the signature that git format-patch adds to the message:\n\t-- \n\t1.2.0\n\nAny way to suppress these?\n\nthanks,\n\ngreg k-h\n\n> \n> thanks,\n> \n> greg k-h\n"},{"id":"16091","messageId":"7vveviv5d1.fsf@assigned-by-dhcp.cox.net","threadId":"3328","inReplyTo":"20060214055648.GA592@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-14T06:09:30Z","receivedAt":"2006-02-14T06:09:30Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Greg KH <greg@kroah.com> writes:\n\n> Hm, in looking at it closer, it's probably the last two lines of the\n> file, the signature that git format-patch adds to the message:\n> \t-- \n> \t1.2.0\n\nIf that is the case, it's unfortunate that diffstat is broken\nand is not properly counting lines to tell which lines are part\nof the patch and which lines are not.\n\nHave you tried \"git apply --stat\" instead?\n\n> Any way to suppress these?\n\nSorry, there is no option to disable that, but the stuff is\nGPLv2 so you can do whatever ;-).\n\nThe string \"-- \\n\" is an established convention to mark the\nbeginning of the signature (or whatever inmaterial stuff that\nfollow the message contents), so changing the marker is\npointless -- if we want the option it should be to delete those\ntwo lines altogether.\n\nI personally find it useful to see the trend of version of tools\npeople use on the public mailing list, and that was the primary\nreason it is there.\n\nHave you tried \"git apply --stat --summary\" instead?\n"},{"id":"16095","messageId":"20060214063420.GA11851@kroah.com","threadId":"3328","inReplyTo":"7vveviv5d1.fsf@assigned-by-dhcp.cox.net","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T06:34:20Z","receivedAt":"2006-02-14T06:34:20Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 10:09:30PM -0800, Junio C Hamano wrote:\n> Greg KH <greg@kroah.com> writes:\n> \n> > Hm, in looking at it closer, it's probably the last two lines of the\n> > file, the signature that git format-patch adds to the message:\n> > \t-- \n> > \t1.2.0\n> \n> If that is the case, it's unfortunate that diffstat is broken\n> and is not properly counting lines to tell which lines are part\n> of the patch and which lines are not.\n> \n> Have you tried \"git apply --stat\" instead?\n\nHow would that work after I've allready applied the patches to a branch?\n\n> > Any way to suppress these?\n> \n> Sorry, there is no option to disable that, but the stuff is\n> GPLv2 so you can do whatever ;-).\n\nBah, make me go create a patch :)\n\n> The string \"-- \\n\" is an established convention to mark the\n> beginning of the signature (or whatever inmaterial stuff that\n> follow the message contents), so changing the marker is\n> pointless -- if we want the option it should be to delete those\n> two lines altogether.\n\nOh I understand what it is and it does follow the proper convention.\nMaybe we just need an extra line of padding in there before the\nsignature or something... I'll go play with it.\n\n> I personally find it useful to see the trend of version of tools\n> people use on the public mailing list, and that was the primary\n> reason it is there.\n\nWhy not just add a \"X-Git-Version: 1.2.0\" flag to the message instead?\n\nthanks,\n\ngreg k-h\n"},{"id":"16096","messageId":"7vlkwev41k.fsf@assigned-by-dhcp.cox.net","threadId":"3328","inReplyTo":"20060214063420.GA11851@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-14T06:37:59Z","receivedAt":"2006-02-14T06:37:59Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Greg KH <greg@kroah.com> writes:\n\n>> Have you tried \"git apply --stat\" instead?\n>\n> How would that work after I've allready applied the patches to a branch?\n\nSorry I was unclear.  By \"instead\", I meant \"instead of running\ndiffstat -p1\".\n"},{"id":"16097","messageId":"20060214064256.GA19667@kroah.com","threadId":"3328","inReplyTo":"20060214063420.GA11851@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T06:42:56Z","receivedAt":"2006-02-14T06:42:56Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 10:34:20PM -0800, Greg KH wrote:\n> > I personally find it useful to see the trend of version of tools\n> > people use on the public mailing list, and that was the primary\n> > reason it is there.\n> \n> Why not just add a \"X-Git-Version: 1.2.0\" flag to the message instead?\n\nAnd here's a patch that does just that.\n\n-----------------\n\nSubject: change git-format-patch to put the git version in the mail header\n\nThis is more like other tools that create mail messages, and fixes an\nissue of the diffstat program thinking that an extra line was removed\nfrom the patch.\n\nSigned-off-by: Greg Kroah-Hartman <gregkh@suse.de>\n\ndiff --git a/git-format-patch.sh b/git-format-patch.sh\nindex e54c9e4..5f6a921 100755\n--- a/git-format-patch.sh\n+++ b/git-format-patch.sh\n@@ -216,6 +216,7 @@ while (<FH>) {\n \n \t    print \"From: $author_ident\\n\";\n \t    print \"Date: $author_date\\n\";\n+\t    print \"X-Git-Version: @@GIT_VERSION@@\\n\";\n \t}\n \tnext;\n     }\n@@ -250,8 +251,6 @@ close FH or die \"close $commsg pipe\";\n \tgit-diff-tree -p $diff_opts \"$commit\" | git-apply --stat --summary\n \techo\n \tgit-diff-tree -p $diff_opts \"$commit\"\n-\techo \"-- \"\n-\techo \"@@GIT_VERSION@@\"\n \n \techo\n }\n"},{"id":"16098","messageId":"20060214064435.GA19831@kroah.com","threadId":"3328","inReplyTo":"7vlkwev41k.fsf@assigned-by-dhcp.cox.net","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T06:44:35Z","receivedAt":"2006-02-14T06:44:35Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 10:37:59PM -0800, Junio C Hamano wrote:\n> Greg KH <greg@kroah.com> writes:\n> \n> >> Have you tried \"git apply --stat\" instead?\n> >\n> > How would that work after I've allready applied the patches to a branch?\n> \n> Sorry I was unclear.  By \"instead\", I meant \"instead of running\n> diffstat -p1\".\n\nThat doesn't give me a summary of all of the changes I made to the tree:\n\n$ git apply --stat *.txt\n drivers/hwmon/vt8231.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n drivers/hwmon/w83781d.c |   43 +++++++++++++++++++++++++------------------\n 1 files changed, 25 insertions(+), 18 deletions(-)\n Documentation/hwmon/w83627hf |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n drivers/hwmon/it87.c         |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n drivers/i2c/busses/i2c-isa.c |   12 ------------\n 1 files changed, 0 insertions(+), 12 deletions(-)\n\n\nInstead of:\n\n Documentation/hwmon/w83627hf |    4 ++++\n drivers/hwmon/it87.c         |    3 ++-\n drivers/hwmon/vt8231.c       |    8 ++++----\n drivers/hwmon/w83781d.c      |   43 +++++++++++++++++++++++++------------------\n drivers/i2c/busses/i2c-isa.c |   12 ------------\n 5 files changed, 35 insertions(+), 35 deletions(-)\n\nWhich is what I need to put into a \"please pull from this tree\" email\nmessage.\n\nthanks,\n\ngreg k-h\n"},{"id":"16099","messageId":"20060214065224.GA20541@kroah.com","threadId":"3328","inReplyTo":"20060214064256.GA19667@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-14T06:52:24Z","receivedAt":"2006-02-14T06:52:24Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 10:42:56PM -0800, Greg KH wrote:\n> On Mon, Feb 13, 2006 at 10:34:20PM -0800, Greg KH wrote:\n> > > I personally find it useful to see the trend of version of tools\n> > > people use on the public mailing list, and that was the primary\n> > > reason it is there.\n> > \n> > Why not just add a \"X-Git-Version: 1.2.0\" flag to the message instead?\n> \n> And here's a patch that does just that.\n> \n> -----------------\n> \n> Subject: change git-format-patch to put the git version in the mail header\n> \n> This is more like other tools that create mail messages, and fixes an\n> issue of the diffstat program thinking that an extra line was removed\n> from the patch.\n> \n> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>\n> \n> diff --git a/git-format-patch.sh b/git-format-patch.sh\n> index e54c9e4..5f6a921 100755\n> --- a/git-format-patch.sh\n> +++ b/git-format-patch.sh\n> @@ -216,6 +216,7 @@ while (<FH>) {\n>  \n>  \t    print \"From: $author_ident\\n\";\n>  \t    print \"Date: $author_date\\n\";\n> +\t    print \"X-Git-Version: @@GIT_VERSION@@\\n\";\n\nHm, git-send-email doesn't see this, so it doesn't get sent out if you\nuse that tool.\n\nI can fix that to just put the version number in the message too, like\nit adds the \"X-Mailer\" field, if people think this is really worth it...\n\nthanks,\n\ngreg k-h\n"},{"id":"16101","messageId":"7vhd72v2jp.fsf@assigned-by-dhcp.cox.net","threadId":"3328","inReplyTo":"20060214065224.GA20541@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-14T07:10:18Z","receivedAt":"2006-02-14T07:10:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Greg KH <greg@kroah.com> writes:\n\n> Hm, git-send-email doesn't see this, so it doesn't get sent out if you\n> use that tool.\n\nAnd people are very likely to remove it by hand.\n\nAnother possibility would be to use \"git apply --numstat\" and\nadd numbers up in your script, but that would not give you a\nnice graph output either X-<.\n\nI'd say if you really care we should just remove those two\nlines, and remember I am _very_ receptive from such suggestion\nfrom prominent kernel people.\n"},{"id":"16162","messageId":"20060214223005.GA12652@c165.ib.student.liu.se","threadId":"3328","inReplyTo":"20060214055425.GA32261@kroah.com","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Fredrik Kuivinen","fromEmail":"freku045@student.liu.se","sentAt":"2006-02-14T22:30:05Z","receivedAt":"2006-02-14T22:30:05Z","isPatch":false,"sender":{"key":"frekui@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13770967?v=4"},"body":"On Mon, Feb 13, 2006 at 09:54:25PM -0800, Greg KH wrote:\n> I was trying to use the built-in git tools to send patches off, instead\n> of my horribly hacked up scripts that use the git low-level stuff, when\n> I noticed that git format-patch's output confuses diffstat a bit, and\n> causes it to add another line to it's count.\n> \n> This isn't good when I do a 'diffstat -p1 *.txt' of the output and add\n> it to an email to send off for someone to pull from, as the result will\n> be off from what is really there.\n> \n> Here's what I get:\n> \n>  $ git format-patch -n origin..HEAD\n>  0001-USB-fix-up-the-usb-early-handoff-logic-for-EHCI.txt\n>  0002-USB-add-new-device-ids-to-ldusb.txt\n>  0003-USB-change-ldusb-s-experimental-state.txt\n>  0004-USB-PL2303-Leadtek-9531-GPS-Mouse.txt\n>  0005-USB-sl811_cs-needs-platform_device-conversion-too.txt\n>  0006-usb-storage-new-unusual_devs-entry.txt\n>  0007-usb-storage-unusual_devs-entry.txt\n>  0008-USB-unusual_devs.h-entry-TrekStor-i.Beat.txt\n>  0009-USB-unusual_devs.h-entry-iAUDIO-M5.txt\n>  0010-USB-unusual-devs-bugfix.txt\n> \n>  $ git log | head -n 1\n>  commit 16f05be7be0bf121491d83bd97337fe179b3b323\n> \n>  $ git show 16f05be7be0bf121491d83bd97337fe179b3b323 | diffstat -p1\n>   drivers/usb/storage/unusual_devs.h |   25 ++++++++++++++++++-------\n>   1 file changed, 18 insertions(+), 7 deletions(-)\n> \n>  $ diffstat -p1 0010-USB-unusual-devs-bugfix.txt\n>   drivers/usb/storage/unusual_devs.h |   26 ++++++++++++++++++--------\n>   1 file changed, 18 insertions(+), 8 deletions(-)\n> \n> Any thoughts?\n> \n\nIf you don't have to generate the diffstat from the individual patches\nthen\n\n    git-diff-tree -p origin HEAD | git-apply --stat\n\nshould give you what you want.\n\n\nBTW when I tried the above command on two random tags in the git tree\nI got:\n\n    $ git-diff-tree -p v1.2.0 v1.0.8 | diffstat -p1 | tail -1\n    165 files changed, 3913 insertions(+), 8092 deletions(-)\n\nand\n\n    $ git-diff-tree -p v1.2.0 v1.0.8 | git apply --stat | tail -1\n    160 files changed, 3925 insertions(+), 8092 deletions(-)\n\nThe difference seems to be caused by diffstat which seems to think\nthat all lines starting with '---' are diff headers. Hence, there are\nsome bogus files in the diffstat output such as:\n\n    [master]                                          |  177 ++\n    [master^2~4]                                      |    9 \n    [master^]                                         |   24 \n    [mybranch]                                        |   56 \n    [mybranch^]                                       |  616 +++++++\n\n- Fredrik\n"},{"id":"16350","messageId":"20060218003403.GA12278@kroah.com","threadId":"3328","inReplyTo":"7vhd72v2jp.fsf@assigned-by-dhcp.cox.net","subject":"Re: diffstat wierdness with 'git format-patch' output","fromName":"Greg KH","fromEmail":"greg@kroah.com","sentAt":"2006-02-18T00:34:03Z","receivedAt":"2006-02-18T00:34:03Z","isPatch":false,"sender":{"key":"greg@kroah.com","avatar":"https://gravatar.com/avatar/5bb5aa0cc2e01c00ec899d11130c07796bc186e465bae57bc34873b13b72c7c8?d=mp&s=160"},"body":"On Mon, Feb 13, 2006 at 11:10:18PM -0800, Junio C Hamano wrote:\n> Greg KH <greg@kroah.com> writes:\n> \n> > Hm, git-send-email doesn't see this, so it doesn't get sent out if you\n> > use that tool.\n> \n> And people are very likely to remove it by hand.\n> \n> Another possibility would be to use \"git apply --numstat\" and\n> add numbers up in your script, but that would not give you a\n> nice graph output either X-<.\n> \n> I'd say if you really care we should just remove those two\n> lines, and remember I am _very_ receptive from such suggestion\n> from prominent kernel people.\n\nHm, in thinking about this some more, I realized that it only requires\nme to change my script to generate the emails for Linus to pull from a\ntiny bit, making this whole thing not a bit deal at all.\n\nThanks a lot for being so receptive, if I have further problems with it,\nI'll let you know.\n\ngreg k-h\n"}]}