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

Re: Bug: git log --numstat counts wrong

From
APAlexander Pepper <pepper@inf.fu-berlin.de>
Date
Sep 23, 2011, 10:30 UTC
Message-ID
<8AEDF5F8-19B5-4502-BB53-EC6CEE0E5CB2@inf.fu-berlin.de>
In-Reply-To
<7vobycxy71.fsf@alter.siamese.dyndns.org>
Am 22.09.2011 um 19:51 schrieb Junio C Hamano:
Show 7 quoted lines
> So perhaps a good sanity-check for you to try (note: not checking your
> sanity, but checking the sanity of the above analysis) would be to do:
> 
>  $ git show 48a07e7e53 -- $that_path | diffstat
>  $ git show -U0 48a07e7e53 -- $that_path | diffstat
>  $ git show --numstat 48a07e7e53 -- $that_path
>  $ git show --stat 48a07e7e53 -- $that_path
[...]
Show 20 quoted lines
> Applying the following patch should make the last two use the default
> context or -U$num given from the command line to be consistent with the
> codepath where we generate textual patches.
> 
> diff.c |    2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/diff.c b/diff.c
> index 9038f19..302ef33 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -2251,6 +2251,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
> 		memset(&xpp, 0, sizeof(xpp));
> 		memset(&xecfg, 0, sizeof(xecfg));
> 		xpp.flags = o->xdl_opts;
> +		xecfg.ctxlen = o->context;
> +		xecfg.interhunkctxlen = o->interhunkcontext;
> 		xdi_diff_outf(&mf1, &mf2, diffstat_consume, diffstat,
> 			      &xpp, &xecfg);
> 	}
First of all: thank you for your extended feedback, your respectful e-mails and your patch!
I did some benachmarking. I compared git version 1.7.6.3 with 1.7.7.rc2 and 1.7.7.rc2 with the above patch.

My test setup: git version 1.7.6.3: 740a8fc2 git version 1.7.7.rc2: 167a5800 git version 1.7.7.rc2': 167a5800 with the above patch applied. Tuple (15,07) shows 15 lines added and 7 lines removed

$ git show $rev -- $that_path | diffstat $ git show -U0 $rev -- $that_path | diffstat $ git log --numstat -n1 --oneline $rev $ git show --stat --oneline -n1 $rev -- $that_path

Test 1: repo='https://github.com/voldemort/voldemort.git' rev='48a07e7e' that_path='src/java/voldemort/server/storage/StorageService.java' Results: 1.7.6.3 1.7.7.rc2 1.7.7.rc2' (10,09) (10,09) (10,09) (11,10) (10,09) (10,09) (11,10) (10,09) (10,09) (11,10) (10,09) (10,09)

Test 2: repo='https://github.com/voldemort/voldemort.git' rev='c21ad764' that_path='contrib/hadoop-store-builder/src/java/voldemort/store/readonly/mr/HadoopStoreBuilderReducer.java' Results: 1.7.6.3 1.7.7.rc2 1.7.7.rc2' (30,27) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22) (25,22)

Test 3: repo='private repo' rev='bd61f26e' that_path='[...]JmeterTest/loadtests/JMeterLoadTest.jmx' Results: 1.7.6.3 1.7.7.rc2 1.7.7.rc2' (450,3544) (450,3544) (450,3544) (401,3495) (401,3495) (401,3495) (401,3495) (401,3495) (450,3544) (401,3495) (401,3495) (450,3544)

In Test 1 the patch seems to be different formatted from 1.7.7.rc2, so the context doesn't matter with the newer version. In Test 2 the patch seems to be different formatted from 1.7.7.rc2, so the context doesn't matter with the newer version. In Test 3 (which is a private repo) where a lot of different lines where changes, some single lines, some multiple lines long makes the biggest difference. With the different contexts different output is observed. I'm sorry that I can not find an open source example for that, but your patch seems to fix this.

So it seems that the patch output in general changed between 1.7.6.3 and 1.7.7.rc2. If I had the right to vote for your patch, I would give it a +1 :-)

Greetings from Berlin Alex

PS: Will this patch be in the final version of 1.7.7?
Previous: Junio C Hamano
Message 16 of 16 in “Bug: git log --numstat counts wrong”
  1. Alexander PepperSep 21, 2011
  2. Junio C HamanoSep 21, 2011
  3. Alexander PepperSep 21, 2011
  4. Alexander PepperSep 21, 2011
  5. Junio C HamanoSep 21, 2011
  6. Alexander PepperSep 22, 2011
  7. Junio C HamanoSep 22, 2011
  8. René ScharfeSep 22, 2011
  9. Tay Ray ChuanSep 23, 2011
  10. Revert removal of multi-match discard heuristic in 27af01Tay Ray Chuan, Sep 25, 2011
  11. René ScharfeSep 25, 2011
  12. Junio C HamanoSep 22, 2011
  13. Tay Ray ChuanSep 23, 2011
  14. Tay Ray ChuanSep 23, 2011
  15. Junio C HamanoSep 23, 2011
  16. Alexander PepperSep 23, 2011

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.