Re: Bug: git log --numstat counts wrong
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Sep 22, 2011, 16:15 UTC
- Message-ID
- <4E7B5F28.2020204@lsrfire.ath.cx>
- In-Reply-To
- <7vobyd1vmo.fsf@alter.siamese.dyndns.org>
Am 21.09.2011 22:35, schrieb Junio C Hamano:
Show 16 quoted lines
> 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....
The patch below reverts a part of 27af01d5523 that's not explained in its commit message and doesn't seem to contribute to the intended speedup. It seems to restore the original diff output. I don't know how it's actually doing that, though, as I haven't dug into the code at all.
Alexander, can you confirm that this patch restores the old behaviour of git diff and git show for your test cases?
Ray, are you able to write a commit message for this patch if it turns out to be useful?
René
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c index 5a33d1a..e419f4f 100644 --- a/xdiff/xprepare.c +++ b/xdiff/xprepare.c @@ -383,7 +383,7 @@ static int xdl_clean_mmatch(char const *dis, long i, long s, long e) { * might be potentially discarded if they happear in a run of discardable. */ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) { - long i, nm, nreff; + long i, nm, nreff, mlim; xrecord_t **recs; xdlclass_t *rcrec; char *dis, *dis1, *dis2; @@ -396,16 +396,20 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd dis1 = dis; dis2 = dis1 + xdf1->nrec + 1; + if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT) + mlim = XDL_MAX_EQLIMIT; for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len2 : 0; - dis1[i] = (nm == 0) ? 0: 1; + dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; } + if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT) + mlim = XDL_MAX_EQLIMIT; for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len1 : 0; - dis2[i] = (nm == 0) ? 0: 1; + dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; } for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart];