git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Subject: [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl()
Date: Tue, 17 Aug 2010 03:59:00 +0200	[thread overview]
Message-ID: <20100817015901.5592.419.chriscool@tuxfamily.org> (raw)

git blame was not showing the sha1 of the replacement commit while
it was properly showing other information from the replacement commit,
because parse_commit() is buggy regarding replacement.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/blame.c    |    4 ++--
 t/t6050-replace.sh |    8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/builtin/blame.c b/builtin/blame.c
index 8f9e7b0..c469e09 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1226,7 +1226,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
 
 			if (sg_origin[i])
 				continue;
-			if (parse_commit(p))
+			if (parse_commit_repl(&p))
 				continue;
 			porigin = find(sb, p, origin);
 			if (!porigin)
@@ -1558,7 +1558,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
 		origin_incref(suspect);
 		commit = suspect->commit;
 		if (!commit->object.parsed)
-			parse_commit(commit);
+			parse_commit_repl(&commit);
 		if (reverse ||
 		    (!(commit->object.flags & UNINTERESTING) &&
 		     !(revs->max_age != -1 && commit->date < revs->max_age)))
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 4185b7c..881a2e8 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -225,6 +225,14 @@ test_expect_success 'index-pack and replacements' '
 	git index-pack test-*.pack
 '
 
+test_expect_success 'blame and replacements' '
+	git blame hello > blame.txt &&
+	grep "$(git rev-parse --short $S)" blame.txt > lines.txt &&
+	grep "O Thor" lines.txt &&
+	grep "line 9" lines.txt &&
+	grep "line 10" lines.txt
+'
+
 #
 #
 test_done
-- 
1.7.2.1.351.g275bf

             reply	other threads:[~2010-08-17  2:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-17  1:59 Christian Couder [this message]
2010-08-17  3:44 ` [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl() Nguyen Thai Ngoc Duy
2010-08-17  6:16   ` Christian Couder

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=20100817015901.5592.419.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@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).