Re: git log --numstat disagrees with git apply --numstat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 11, 2008 at 03:53:37PM -0800, Shawn O. Pearce wrote:

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

"git apply" doesn't actually do the diff; it just calculates based on
what it sees in the patch. So the real issue is "git log -p" and "git
log --numstat" produce different patches. And you can see it by
instrumenting like this:

diff --git a/diff.c b/diff.c
index af822c1..fce93db 100644
--- a/diff.c
+++ b/diff.c
@@ -726,6 +726,8 @@ static void diffstat_consume(void *priv, char *line, unsigned long len)
 	struct diffstat_t *diffstat = priv;
 	struct diffstat_file *x = diffstat->files[diffstat->nr - 1];
 
+	fwrite(line, 1, len, stderr);
+
 	if (line[0] == '+')
 		x->added++;
 	else if (line[0] == '-')

and then comparing what diffstat_consume gets versus the patch,
something like:

    what="9bda5ece org.spearce.jgit/src/org/spearce/jgit/revwalk/RevWalk.java"
    git log -p -1 --pretty=format: $what | grep '^[-+@]' >a
    git log --numstat -1 --pretty=format: $what 2>b >/dev/null
    diff -u a b

It looks like it is just a place where two different valid diffs can be
constructed:

    +-
    +-              for (final RevCommit p : c.parents) {
    +-                      if ((p.flags & SEEN) != 0)
     +              for (;;) {
     +                      final RevCommit c = pending.pop();
     +                      if (c == null)
    @@ -67,19 +68,20 @@
     +                              p.flags |= SEEN;
     +                              pending.add(p);
     +                      }
    --              for (final RevCommit p : c.parents) {
    --                      if ((p.flags & SEEN) != 0)
    ++

which is probably just due to different xdi settings being used between
the two codepaths. I haven't looked closely to see which different
options we are feeding to xdiff.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux