Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: Bug: git log --numstat counts wrong

From: Tay Ray Chuan <hidden>
Date: 2016-06-15 22:52:06
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

On Fri, Sep 23, 2011 at 5:18 PM, Tay Ray Chuan [off-list ref] wrote:
On Fri, Sep 23, 2011 at 1:51 AM, Junio C Hamano [off-list ref] wrote:
quoted
[snip]
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);
       }
Thanks Junio.

But wait, where does this patch go? Before or after 27af01d? If I'm
understanding the situation correctly, this patch won't change the
reporting 10/9 for --numstat, no?
I think I can answer this - on to v1.7.6, which is before 27af01d was merged in.
Anyway, this patch looks right.
On further thought, I think the patch merely side-steps the problem -
ie. that -U0 generates "incorrect" diffs.

Further digging reveals a xdiff-interface.c::trim_common_tail();
commenting its one and only call (patch below) gives back 10/9. Note
that it only has effect when -U0.

I think this function is incorrect. xdl_cleanup_records() and
xdl_clean_mmatch() may potentially look into common tail lines, so it
may not be "safe" to drop all common tail lines.

-- >8 --
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 0e2c169..da4fab6 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -131,7 +131,7 @@
        mmfile_t a = *mf1;
        mmfile_t b = *mf2;

-       trim_common_tail(&a, &b, xecfg->ctxlen);
+/*     trim_common_tail(&a, &b, xecfg->ctxlen);  */

        return xdl_diff(&a, &b, xpp, xecfg, xecb);
 }
-- >8 --
-- 
Cheers,
Ray Chuan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help