git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Best way to get number of insertions and deletions from a diff?
@ 2010-10-13 19:21 Pat Notz
  2010-10-13 19:37 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Pat Notz @ 2010-10-13 19:21 UTC (permalink / raw)
  To: Git

I'd like to probe various commits to see how many lines were added or
removed.  For example,

$ git diff --shortstat HEAD HEAD^1
 3 files changed, 5 insertions(+), 5 deletions(-)

That's great but I'd like to do this from a script and parse out those
numbers.  Is there a more plumbing-level way to do this that would be
more robust?  Or, should I just parse this output?

Thanks ~ Pat

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Best way to get number of insertions and deletions from a diff?
  2010-10-13 19:21 Best way to get number of insertions and deletions from a diff? Pat Notz
@ 2010-10-13 19:37 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2010-10-13 19:37 UTC (permalink / raw)
  To: Pat Notz; +Cc: Git

On Wed, Oct 13, 2010 at 01:21:27PM -0600, Pat Notz wrote:

> I'd like to probe various commits to see how many lines were added or
> removed.  For example,
> 
> $ git diff --shortstat HEAD HEAD^1
>  3 files changed, 5 insertions(+), 5 deletions(-)
> 
> That's great but I'd like to do this from a script and parse out those
> numbers.  Is there a more plumbing-level way to do this that would be
> more robust?  Or, should I just parse this output?

The official plumbing way is --numstat, but you will have to sum the
totals for file yourself. You should also use "git diff-tree" over "git
diff". If you have a lot of commits, the simplest thing is something
like:

  git diff-tree --stdin --numstat <commits

which will automatically check each commit against its parent (though I
think diff-tree will not resolve refs for you, so you may need massage
the input).

-Peff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-13 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 19:21 Best way to get number of insertions and deletions from a diff? Pat Notz
2010-10-13 19:37 ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).