git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl()
@ 2010-08-17  1:59 Christian Couder
  2010-08-17  3:44 ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2010-08-17  1:59 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Nguyen Thai Ngoc Duy

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl()
  2010-08-17  1:59 [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl() Christian Couder
@ 2010-08-17  3:44 ` Nguyen Thai Ngoc Duy
  2010-08-17  6:16   ` Christian Couder
  0 siblings, 1 reply; 3+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2010-08-17  3:44 UTC (permalink / raw)
  To: Christian Couder; +Cc: Junio C Hamano, git

On Tue, Aug 17, 2010 at 11:59 AM, Christian Couder
<chriscool@tuxfamily.org> wrote:
> 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))

This is the hard way. There are another ~40 parse_commit() calls
elsewhere. Most of them are in git commands, so we can check one by
one. There are some calls in revision.c, sha1_name.c, tree.c,
upload-pack.c and walker.c, which may be used in many places. Checking
them would be harder.
-- 
Duy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl()
  2010-08-17  3:44 ` Nguyen Thai Ngoc Duy
@ 2010-08-17  6:16   ` Christian Couder
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Couder @ 2010-08-17  6:16 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: Junio C Hamano, git

On Tuesday 17 August 2010 05:44:11 Nguyen Thai Ngoc Duy wrote:
> On Tue, Aug 17, 2010 at 11:59 AM, Christian Couder
> 
> <chriscool@tuxfamily.org> wrote:
> > 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))
> 
> This is the hard way. There are another ~40 parse_commit() calls
> elsewhere. Most of them are in git commands, so we can check one by
> one. There are some calls in revision.c, sha1_name.c, tree.c,
> upload-pack.c and walker.c, which may be used in many places. Checking
> them would be harder.

Yeah, I will try to provide test cases but it may not be possible in some 
cases.

Best regards,
Christian.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-17  6:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-17  1:59 [RFC/PATCH 2/2] blame: fix output in case of replacement by using parse_commit_repl() Christian Couder
2010-08-17  3:44 ` Nguyen Thai Ngoc Duy
2010-08-17  6:16   ` Christian Couder

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).