From: Jeff King <peff@peff.net>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: git log --numstat disagrees with git apply --numstat
Date: Thu, 11 Dec 2008 20:52:55 -0500 [thread overview]
Message-ID: <20081212015254.GA23128@sigill.intra.peff.net> (raw)
In-Reply-To: <20081211235337.GK32487@spearce.org>
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
next prev parent reply other threads:[~2008-12-12 1:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 23:53 git log --numstat disagrees with git apply --numstat Shawn O. Pearce
2008-12-12 1:52 ` Jeff King [this message]
2008-12-12 2:08 ` Jeff King
2008-12-12 2:21 ` Jeff King
2008-12-15 9:57 ` Junio C Hamano
2008-12-15 20:32 ` Jeff King
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=20081212015254.GA23128@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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).