From: Junio C Hamano <gitster@pobox.com>
To: Alexander Pepper <pepper@inf.fu-berlin.de>
Cc: git@vger.kernel.org, Tay Ray Chuan <rctay89@gmail.com>
Subject: Re: Bug: git log --numstat counts wrong
Date: Thu, 22 Sep 2011 10:51:30 -0700 [thread overview]
Message-ID: <7vobycxy71.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vobyd1vmo.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 21 Sep 2011 13:35:43 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Alexander Pepper <pepper@inf.fu-berlin.de> writes:
>
>> Am 21.09.2011 um 14:24 schrieb Junio C Hamano:
>>>> $ git log --numstat 48a07e7e533f507228e8d1c99d4d48e175e14260
>>>> [...]
>>>> 11 10 src/java/voldemort/server/storage/StorageService.java
>>>
>>> Didn't we update it this already? I seem to get 10/9 here not 11/10.
>>
>> Current 'maint' (cd2b8ae9), 'master' (4b5eac7f)...
>
> That's a tad old master you seem to have.
>
> Strangely, bisection points at 27af01d5523, which was supposed to be only
> about performance and never about correctness. There is something fishy
> going on....
In any case, I think the real issue is that depending on how much context
you ask, the resulting diff is different (and both are valid diffs). If
you ask "log -p" (or "diff" or "show") to produce a patch, then we use the
default 3-line context. And then you feed that to an external diffstat to
count the number of deleted and added lines to get one set of numbers.
The --numstat (and --diffstat) code seems to be running the internal diff
machinery with 0-line context and counting the resulting diff internally.
And of course the results between the above two would be different because
diff can match lines differently when given different number of context
lines to include in the result.
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
and see how they compare (make sure to use the same version of git for
these experiments). The first one uses the default 3-lines context, the
second one forces 0-line context, and the last two uses 0-line context
hardwired in the code.
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);
}
next prev parent reply other threads:[~2011-09-22 17:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-21 9:03 Bug: git log --numstat counts wrong Alexander Pepper
2011-09-21 12:24 ` Junio C Hamano
2011-09-21 13:40 ` Alexander Pepper
2011-09-21 14:23 ` Alexander Pepper
2011-09-21 20:35 ` Junio C Hamano
2011-09-22 13:19 ` Alexander Pepper
2011-09-22 17:32 ` Junio C Hamano
2011-09-22 16:15 ` René Scharfe
2011-09-23 6:30 ` Tay Ray Chuan
2011-09-25 13:39 ` [PATCH] Revert removal of multi-match discard heuristic in 27af01 Tay Ray Chuan
2011-09-25 17:53 ` René Scharfe
2011-09-22 17:51 ` Junio C Hamano [this message]
2011-09-23 9:18 ` Bug: git log --numstat counts wrong Tay Ray Chuan
2011-09-23 16:38 ` Tay Ray Chuan
2011-09-23 19:23 ` Junio C Hamano
2011-09-23 10:30 ` Alexander Pepper
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vobycxy71.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pepper@inf.fu-berlin.de \
--cc=rctay89@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.
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 NNTP newsgroup(s).