git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Best way to get number of insertions and deletions from a diff?

From
Pat Notz <patnotz@gmail.com>
Date
Oct 13, 2010, 19:21 UTC
Message-ID
<AANLkTinJuuxOZ2DvCSc2Nb0DAjwmJEyJXeGLHsLkyM1B@mail.gmail.com>

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
Next: Jeff King
Message 1 of 2 in “Best way to get number of insertions and deletions from a diff?”
  1. Pat NotzOct 13, 2010
  2. Jeff KingOct 13, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.