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

git log --numstat disagrees with git apply --numstat

From
Shawn O. Pearce <spearce@spearce.org>
Date
Dec 11, 2008, 23:53 UTC
Message-ID
<20081211235337.GK32487@spearce.org>

I've found a case where git apply --numstat and git log --numstat produce different results for the same commit.

In egit (git://repo.or.cz/egit.git/):
  $ git log --numstat -1 --pretty=o 9bda5ece6806cd797416eaa47c
  9bda5ece6806cd797416eaa47c7b927cc6e9c3b2 Teach RevWalk about ...
  8       0       org.spearce.jgit/src/org/spearce/jgit/revwalk/DateRevQueue.java
  69      13      org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java
  $ git log -p -1 --pretty=o 9bda5ece6806cd797416eaa47c | git apply --numstat
  8       0       org.spearce.jgit/src/org/spearce/jgit/revwalk/DateRevQueue.java
  68      12      org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java

I found this because I was writing a unit test for JGit that ran through the JGit project history and compared the output of git log --numstat against the output of JGit's "git apply --numstat" implementation, after scraping the "git log -p" output.

I can't quite figure out why log --numstat is coming up with a +1 difference here for both added and removed, but it is. I haven't dug into the Git code yet to figure out why. FWIW, JGit produces the same result as "git apply --numstat" (the 68/12).

At this point JGit was able to successfully read and match 715 of 1211 commits before it found this difference, so its also somewhat rare to occur I think...

-- 
Shawn.
Next: Jeff King
Message 1 of 6 in “git log --numstat disagrees with git apply --numstat”
  1. Shawn O. PearceDec 11, 2008
  2. Jeff KingDec 12, 2008
  3. Jeff KingDec 12, 2008
  4. Jeff KingDec 12, 2008
  5. Junio C HamanoDec 15, 2008
  6. Jeff KingDec 15, 2008

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.