From: Jeff King <peff@peff.net>
To: Pat Notz <patnotz@gmail.com>
Cc: Git <git@vger.kernel.org>
Subject: Re: Best way to get number of insertions and deletions from a diff?
Date: Wed, 13 Oct 2010 15:37:50 -0400 [thread overview]
Message-ID: <20101013193750.GC13155@sigill.intra.peff.net> (raw)
In-Reply-To: <AANLkTinJuuxOZ2DvCSc2Nb0DAjwmJEyJXeGLHsLkyM1B@mail.gmail.com>
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
prev parent reply other threads:[~2010-10-13 19:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101013193750.GC13155@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=patnotz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).