{"thread":{"id":"25439","subject":"Best way to get number of insertions and deletions from a diff?","startedAt":"2010-10-13T19:21:27Z","lastAt":"2010-10-13T19:37:50Z","messageCount":2,"participants":["Pat Notz","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"153428","messageId":"AANLkTinJuuxOZ2DvCSc2Nb0DAjwmJEyJXeGLHsLkyM1B@mail.gmail.com","threadId":"25439","inReplyTo":null,"subject":"Best way to get number of insertions and deletions from a diff?","fromName":"Pat Notz","fromEmail":"patnotz@gmail.com","sentAt":"2010-10-13T19:21:27Z","receivedAt":"2010-10-13T19:21:27Z","isPatch":false,"sender":{"key":"patnotz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45364?v=4"},"body":"I'd like to probe various commits to see how many lines were added or\nremoved.  For example,\n\n$ git diff --shortstat HEAD HEAD^1\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\nThat's great but I'd like to do this from a script and parse out those\nnumbers.  Is there a more plumbing-level way to do this that would be\nmore robust?  Or, should I just parse this output?\n\nThanks ~ Pat\n"},{"id":"153439","messageId":"20101013193750.GC13155@sigill.intra.peff.net","threadId":"25439","inReplyTo":"AANLkTinJuuxOZ2DvCSc2Nb0DAjwmJEyJXeGLHsLkyM1B@mail.gmail.com","subject":"Re: Best way to get number of insertions and deletions from a diff?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-10-13T19:37:50Z","receivedAt":"2010-10-13T19:37:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 13, 2010 at 01:21:27PM -0600, Pat Notz wrote:\n\n> I'd like to probe various commits to see how many lines were added or\n> removed.  For example,\n> \n> $ git diff --shortstat HEAD HEAD^1\n>  3 files changed, 5 insertions(+), 5 deletions(-)\n> \n> That's great but I'd like to do this from a script and parse out those\n> numbers.  Is there a more plumbing-level way to do this that would be\n> more robust?  Or, should I just parse this output?\n\nThe official plumbing way is --numstat, but you will have to sum the\ntotals for file yourself. You should also use \"git diff-tree\" over \"git\ndiff\". If you have a lot of commits, the simplest thing is something\nlike:\n\n  git diff-tree --stdin --numstat <commits\n\nwhich will automatically check each commit against its parent (though I\nthink diff-tree will not resolve refs for you, so you may need massage\nthe input).\n\n-Peff\n"}]}