Skip to contentSkip to conversation

git-blame: Use the same tests for git-blame as for git-annotate

PATCH In review Fredrik Kuivinen 7 participants 19 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-blame: Use the same tests for git-blame as for git-annotate

---

 t/annotate-tests.sh |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++
 t/t8001-annotate.sh |   85 +-------------------------------------------------
 t/t8002-blame.sh    |    9 +++++
 3 files changed, 97 insertions(+), 83 deletions(-)
 create mode 100644 t/annotate-tests.sh
 create mode 100755 t/t8002-blame.sh

06b0e500a5202899dcfd037cf78ee4a982da46b4

t/annotate-tests.sh new file +86 -0
new file mode 100644
index 0000000..54a4dfb
@@ -0,0 +1,86 @@
+# This file isn't used as a test script directly, instead it is
+# sourced from t8001-annotate.sh and t8001-blame.sh.
+
+test_expect_success \
+    'prepare reference tree' \
+    'echo "1A quick brown fox jumps over the" >file &&
+     echo "lazy dog" >>file &&
+     git add file
+     GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
+
+test_expect_success \
+    'check all lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
+
+test_expect_success \
+    'Setup new lines blamed on B' \
+    'echo "2A quick brown fox jumps over the" >>file &&
+     echo "lazy dog" >> file &&
+     GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "A") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "B") == 2 ]'
+
+test_expect_success \
+    'merge-setup part 1' \
+    'git checkout -b branch1 master &&
+     echo "3A slow green fox jumps into the" >> file &&
+     echo "well." >> file &&
+     GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 2 ]'
+
+test_expect_success \
+    'Two lines blamed on B1' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+
+test_expect_success \
+    'merge-setup part 2' \
+    'git checkout -b branch2 master &&
+     sed -e "s/2A quick brown/4A quick brown lazy dog/" < file > file.new &&
+     mv file.new file &&
+     GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
+
+test_expect_success \
+    'One line blamed on B2' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
+
+
+test_expect_success \
+    'merge-setup part 3' \
+    'git pull . branch1'
+
+test_expect_success \
+    'Two lines blamed on A' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
+
+test_expect_success \
+    'Two lines blamed on B1' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+
+test_expect_success \
+    'One line blamed on B2' \
+    '[ $($PROG file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
t/t8001-annotate.sh +2 -83

90 lines not on this page · raw message

t/t8002-blame.sh new file +9 -0
new file mode 100755
index 0000000..1036c54
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+test_description='git-blame'
+. ./test-lib.sh
+
+PROG='git blame -c'
+source ../annotate-tests.sh
+
+test_done
Signature · 1 line
1.2.4.g4644-dirty
#1 lore raw

Along these lines, if anyone can pin down the complicated cases that annotate and blame get differently, adding them as a test would be *exceedingly* appreciated, even if it makes annotate (or blame) fail for a bit, it gives us something to work against.

I've been trying to find some time this weekend to dig into why annotate gets things wrong, but I've been distracted, unfortunately.

Signature · 2 lines
Ryan Anderson
  sometimes Pug Majere
#2 lore raw
Quoted 4 lines · Ryan Anderson

Along these lines, if anyone can pin down the complicated cases that annotate and blame get differently, adding them as a test would be *exceedingly* appreciated, even if it makes annotate (or blame) fail for a bit, it gives us something to work against.

It would be great if they both worked properly with paths that existed in the past. Right now, I can't git-annotate or git-blame a file I know was there in a past revision. I think I had taught Johannes' annotate to deal with this, or at least intended to. As things stand, git-annotate/git-blame need a checkout, which is really silly.

Tools like gitweb and cvsserver should be able to do:

GIT_DIR=/somebarerepo/git.git git-(annotate|blame) -h headname Makefile

and not worry about creating a temporary index *and* checking out Makefile so that things work. That's what cvsserver does now, anyway. Ugly :-(

cheers,

m

#3 lore raw

PATCH 1/1 annotate: Support annotation of files on other revisions.

This is a bug fix, and cleans up one or two other things spotted during the course of tracking down the main bug here.

Also, the test-suite is updated to reflect this case.

---

 git-annotate.perl   |    7 +++++--
 t/t8001-annotate.sh |    6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
Quoted 11 lines · Martin Langhoff
Quoted 4 lines · Ryan Anderson

Along these lines, if anyone can pin down the complicated cases that annotate and blame get differently, adding them as a test would be *exceedingly* appreciated, even if it makes annotate (or blame) fail for a bit, it gives us something to work against.

It would be great if they both worked properly with paths that existed in the past. Right now, I can't git-annotate or git-blame a file I know was there in a past revision. I think I had taught Johannes' annotate to deal with this, or at least intended to. As things stand, git-annotate/git-blame need a checkout, which is really silly.

annotate was *trying* to handle that cleanly, but failed due to a silly bug. This is the same bug that Junio pointed out:

	cd t
	./t8001-annotate.sh
	cd trash
	../../git-annotate file master

This is fixed by the patch at the end of this email.

Quoted 7 lines

Tools like gitweb and cvsserver should be able to do:

GIT_DIR=/somebarerepo/git.git git-(annotate|blame) -h headname Makefile

and not worry about creating a temporary index *and* checking out Makefile so that things work. That's what cvsserver does now, anyway. Ugly :-(

For annotate, the syntax I was using was:
git annotate Makefile headname

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

cdd80fd28d300dd2400bf75ff64ae2bf1a8b92aa

git-annotate.perl +5 -2
index d93ee19..5953ac6 100755
@@ -10,6 +10,7 @@ use warnings;
 use strict;
 use Getopt::Long;
 use POSIX qw(strftime gmtime);
+use Data::Dumper;
 
 sub usage() {
 	print STDERR 'Usage: ${\basename $0} [-s] [-S revs-file] file [ revision ]
@@ -99,7 +100,7 @@ while (my $bound = pop @stack) {
 	}
 }
 push @revqueue, $head;
-init_claim( defined $starting_rev ? $starting_rev : 'dirty');
+init_claim( defined $starting_rev ? $head : 'dirty');
 unless (defined $starting_rev) {
 	my $diff = open_pipe("git","diff","-R", "HEAD", "--",$filename)
 		or die "Failed to call git diff to check for dirty state: $!";
@@ -345,6 +346,7 @@ sub git_cat_file {
 	return () unless defined $rev && defined $filename;
 
 	my $blob = git_ls_tree($rev, $filename);
+	die "Failed to find a blob for $filename in rev $rev\n" if !defined $blob;
 
 	my $catfile = open_pipe("git","cat-file", "blob", $blob)
 		or die "Failed to git-cat-file blob $blob (rev $rev, file $filename): " . $!;
@@ -367,12 +369,13 @@ sub git_ls_tree {
 
 	my ($mode, $type, $blob, $tfilename);
 	while(<$lstree>) {
+		chomp;
 		($mode, $type, $blob, $tfilename) = split(/\s+/, $_, 4);
 		last if ($tfilename eq $filename);
 	}
 	close($lstree);
 
-	return $blob if $filename eq $filename;
+	return $blob if ($tfilename eq $filename);
 	die "git-ls-tree failed to find blob for $filename";
 
 }
t/t8001-annotate.sh +6 -0
index 172908a..761d0bc 100755
@@ -87,4 +87,10 @@ test_expect_success \
     'One line blamed on B2' \
     '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
 
+test_expect_success \
+    'Annotating an old revision works' \
+    '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") == 2 ] && \
+     [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") == 2 ]'
+
+
 test_done
Signature · 8 lines
1.2.4.g9201-dirty



-- 

Ryan Anderson
  sometimes Pug Majere
#4 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Ryan Anderson wrote:
...

Quoted 7 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

Wouldn't
git annotate <headname> <filename(s?)>
be more consistent with other git commands?

#5 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 7 lines · A Large Angry SCM

Ryan Anderson wrote:
...

Quoted 4 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

Quoted 8 lines
Quoted 3 lines

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

Wouldn't
git annotate <headname> <filename(s?)>
be more consistent with other git commands?

Yes, but <headname> (really, a commitish) needs to be optional.

I should probably switch to:
git annotate [-c|--commit <committish>] <filename>
but that's partly why I'm asking for feedback.

Signature · 2 lines
Ryan Anderson
  sometimes Pug Majere
#6 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 17 lines · Ryan Anderson
Quoted 7 lines · A Large Angry SCM

Ryan Anderson wrote:
...

Quoted 4 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

Quoted 8 lines
Quoted 3 lines

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

Wouldn't
git annotate <headname> <filename(s?)>
be more consistent with other git commands?

Quoted 5 lines

Yes, but <headname> (really, a commitish) needs to be optional.

I should probably switch to:
git annotate [-c|--commit <committish>] <filename>
but that's partly why I'm asking for feedback.

Yes but doesn't git-diff accept:

git-diff Makefile
git-diff HEAD Makefile

? (Which is rather ugly as what if you have a tracked file actually called HEAD and you want the first form when the commit-ish is omitted.) So accepting an optional commit-ish before the filename would be in line with what git-diff accepts today.

But maybe breaking convention from git-diff now is a good thing, with a future change to cleanup git-diff.

Signature · 1 line
Shawn.
#7 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 16 lines · Shawn Pearce
Quoted 15 lines · Ryan Anderson
Quoted 13 lines · A Large Angry SCM

Ryan Anderson wrote:
...

Quoted 6 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

Wouldn't
git annotate <headname> <filename(s?)>
be more consistent with other git commands?

Quoted 5 lines
Quoted 5 lines

Yes, but <headname> (really, a commitish) needs to be optional.

I should probably switch to:
git annotate [-c|--commit <committish>] <filename>
but that's partly why I'm asking for feedback.

That works.

Or maybe:

	git-annotate [<committish> --] <filename(s?)>
or:
	git-annotate [<committish>] -- <filename(s?)>
Quoted 6 lines

Yes but doesn't git-diff accept:

git-diff Makefile
git-diff HEAD Makefile

Quoted 8 lines

? (Which is rather ugly as what if you have a tracked file actually called HEAD and you want the first form when the commit-ish is omitted.) So accepting an optional commit-ish before the filename would be in line with what git-diff accepts today.

But maybe breaking convention from git-diff now is a good thing, with a future change to cleanup git-diff.

Looking at the documentation, it looks like all of the commands that take paths do so as the last arguments. With any commit/tree arguments being, either, required or flagged.

Is there any reason that git-{annotate,blame} can't take more than one filename, ever?

#8 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 2 lines

Is there any reason that git-{annotate,blame} can't take more than one filename, ever?

I do not see it would be much useful -- the output does not have a sign to show file boundary.

#9 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Hi,

Quoted 5 lines · Junio C Hamano
Quoted 2 lines

Is there any reason that git-{annotate,blame} can't take more than one filename, ever?

I do not see it would be much useful -- the output does not have a sign to show file boundary.

CVS does it. Why shouldn't git, too?

Ciao,
Dscho

P.S.: The output for more than one file is separated by something like

	Annotations for <filename.txt>
	***************
#10 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

In reply to Shawn Pearce
Quoted 7 lines · Shawn Pearce

git-diff Makefile
git-diff HEAD Makefile

? (Which is rather ugly as what if you have a tracked file actually called HEAD and you want the first form when the commit-ish is omitted.) So accepting an optional commit-ish before the filename would be in line with what git-diff accepts today.

The use of "start of filelist" marker "--" is optional when unambiguous, and that is why "git-diff Makefile" works. To view the change you still haven't update-index'ed to the path called "HEAD", you would naturally say "git-diff -- HEAD"

#11 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Shawn Pearce

git-diff Makefile
git-diff HEAD Makefile

? (Which is rather ugly as what if you have a tracked file actually called HEAD and you want the first form when the commit-ish is omitted.) So accepting an optional commit-ish before the filename would be in line with what git-diff accepts today.

Quoted 4 lines

The use of "start of filelist" marker "--" is optional when unambiguous, and that is why "git-diff Makefile" works. To view the change you still haven't update-index'ed to the path called "HEAD", you would naturally say "git-diff -- HEAD"

Naturally. :-)

After getting along fine with git-diff foo for months I would natually not be surprised when git-diff foo didn't work because I performed a git-checkout -b foo pu one day.

Signature · 1 line
Shawn.
#12 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

In reply to Ryan Anderson
Quoted 1 line · Ryan Anderson

annotate was *trying* to handle that cleanly, but failed due to a silly

Great stuff, thanks! I'll let it hit master and then I'll drop the messy part of req_annotate() in cvsserver.

Quoted 5 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

That's _perfect_. I was just making the syntax up.

cheers,

martin

#13 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 6 lines · Martin Langhoff
Quoted 1 line · Ryan Anderson

annotate was *trying* to handle that cleanly, but failed due to a silly

Great stuff, thanks! I'll let it hit master and then I'll drop the messy part of req_annotate() in cvsserver.

Quoted 8 lines
Quoted 5 lines

For annotate, the syntax I was using was:
git annotate Makefile headname

I'm not married to it, so please, send a patch to change it if you want (Please fix up the test case I'm sending in this patch, as well.)

That's _perfect_. I was just making the syntax up.

That syntax should work with git-blame too. If it doesn't, it's a bug.

- Fredrik

#14 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

In reply to Ryan Anderson

Hi,

Quoted 1 line · Ryan Anderson

+use Data::Dumper;

You really need this?

Ciao,
Dscho

P.S.: Not to be left behind, I also weigh in into the other discussion:
I'd like "git-{annotate,blame} [HEAD [--]] [filenames...]".

#15 lore raw

Re: [PATCH] annotate: Support annotation of files on other revisions.

Quoted 6 lines · Johannes Schindelin

Hi,

On Sun, 5 Mar 2006, Ryan Anderson wrote:

Quoted 7 lines
Quoted 3 lines

+use Data::Dumper;

You really need this?

I keep adding it back in when debugging things, and then promptly forget to remove it when I cull the debugging back out.

It's a core module, so it shouldn't be a significant issue for any porting

Signature · 2 lines
Ryan Anderson
  sometimes Pug Majere
#16 lore raw
In reply to Ryan Anderson
Quoted 4 lines · Ryan Anderson

Along these lines, if anyone can pin down the complicated cases that annotate and blame get differently, adding them as a test would be *exceedingly* appreciated, even if it makes annotate (or blame) fail for a bit, it gives us something to work against.

In the t/trash repository, "git-annotate file master" and "git-annotate file master^" behaves funkily.

OTOH "git-blame file master" assigns everything to that commit while only the last two lines are attributable to it. Needs a bit more work on both sides ;-).

#17 lore raw
In reply to Fredrik Kuivinen
Quoted 24 lines · Fredrik Kuivinen

---

t/annotate-tests.sh |   86 +++++++++++++++++++++++++++++++++++++++++++++++++++
t/t8001-annotate.sh |   85 +-------------------------------------------------
t/t8002-blame.sh    |    9 +++++
3 files changed, 97 insertions(+), 83 deletions(-)

create mode 100644 t/annotate-tests.sh
create mode 100755 t/t8002-blame.sh

06b0e500a5202899dcfd037cf78ee4a982da46b4

t/annotate-tests.sh new file +3 -0
new file mode 100644
index 0000000..54a4dfb
@@ -0,0 +1,86 @@
+# This file isn't used as a test script directly, instead it is
+# sourced from t8001-annotate.sh and t8001-blame.sh.
+

t/annotate-tests.sh line 13

Quoted 10 lines
t/annotate-tests.sh new file +10 -0
+test_expect_success \
+    'prepare reference tree' \
+    'echo "1A quick brown fox jumps over the" >file &&
+     echo "lazy dog" >>file &&
+     git add file
+     GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
+
+test_expect_success \
+    'check all lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'

This should be $PROG as well, I suspect.

Also, we need to agree on a syntax for working on non-HEAD revisions.

"git annotate $file $commitish" is what I had been using, but it's really not something I feel strongly about.

Signature · 2 lines
Ryan Anderson
  sometimes Pug Majere
#18 lore raw

PATCH 1/1 annotate/blame tests updates.

Quoted 6 lines · Ryan Anderson

Review

Quoted 5 lines
(quoted diff) +3 -0
+test_expect_success \
+    'check all lines blamed on A' \
+    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'

This should be $PROG as well, I suspect.

True. Also I am suspecting this awk being a but unsafe. The default author is "A U Thor <[email protected]>", and without FS specified awk would split at whitespaces.

I haven't pushed out the test-case sharing by Fredrik yet, but I have already taken it. This patch is on top of it.

-- >8 --
This rewrites the result check code a bit. The earlier one using awk was splitting columns at any whitespace, which confused lines attributed incorrectly to the merge made by the default author "A U Thor <[email protected]>" with lines attributed to author "A".

The latest test by Ryan to add the "starting from older commit" test is also included, with another older commit test.

---

 t/annotate-tests.sh |   81 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 37 deletions(-)

92a903acfd0904e6dd6d18112428429938783d19

t/annotate-tests.sh +44 -37
index 54a4dfb..d25a7a1 100644
@@ -1,6 +1,37 @@
 # This file isn't used as a test script directly, instead it is
 # sourced from t8001-annotate.sh and t8001-blame.sh.
 
+check_count () {
+	head=
+	case "$1" in -h) head="$2"; shift; shift ;; esac
+	$PROG file $head | perl -e '
+		my %expect = (@ARGV);
+		my %count = ();
+		while (<STDIN>) {
+			if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
+				my $author = $1;
+				for ($author) { s/^\s*//; s/\s*$//; }
+				if (exists $expect{$author}) {
+					$count{$author}++;
+				}
+			}
+		}
+		my $bad = 0;
+		while (my ($author, $count) = each %count) {
+			my $ok;
+			if ($expect{$author} != $count) {
+				$bad = 1;
+				$ok = "bad";
+			}
+			else {
+				$ok = "good";
+			}
+			print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
+		}
+		exit($bad);
+	' "$@"
+}
+
 test_expect_success \
     'prepare reference tree' \
     'echo "1A quick brown fox jumps over the" >file &&
@@ -10,7 +41,7 @@ test_expect_success \
 
 test_expect_success \
     'check all lines blamed on A' \
-    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
+    'check_count A 2'
 
 test_expect_success \
     'Setup new lines blamed on B' \
@@ -19,12 +50,8 @@ test_expect_success \
      GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
 
 test_expect_success \
-    'Two lines blamed on A' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "A") == 2 ]'
-
-test_expect_success \
-    'Two lines blamed on B' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "B") == 2 ]'
+    'Two lines blamed on A, two on B' \
+    'check_count A 2 B 2'
 
 test_expect_success \
     'merge-setup part 1' \
@@ -34,16 +61,8 @@ test_expect_success \
      GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
 
 test_expect_success \
-    'Two lines blamed on A' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
-
-test_expect_success \
-    'Two lines blamed on B' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 2 ]'
-
-test_expect_success \
-    'Two lines blamed on B1' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+    'Two lines blamed on A, two on B, two on B1' \
+    'check_count A 2 B 2 B1 2'
 
 test_expect_success \
     'merge-setup part 2' \
@@ -53,34 +72,22 @@ test_expect_success \
      GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
 
 test_expect_success \
-    'Two lines blamed on A' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
-
-test_expect_success \
-    'One line blamed on B' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
-
-test_expect_success \
-    'One line blamed on B2' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
-
+    'Two lines blamed on A, one on B, one on B2' \
+    'check_count A 2 B 1 B2 1'
 
 test_expect_success \
     'merge-setup part 3' \
     'git pull . branch1'
 
 test_expect_success \
-    'Two lines blamed on A' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
+    'Two lines blamed on A, one on B, two on B1, one on B2' \
+    'check_count A 2 B 1 B1 2 B2 1'
 
 test_expect_success \
-    'One line blamed on B' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
+    'Annotating an old revision works' \
+    'check_count -h master A 2 B 2'
 
 test_expect_success \
-    'Two lines blamed on B1' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
+    'Annotating an old revision works' \
+    'check_count -h master^ A 2'
 
-test_expect_success \
-    'One line blamed on B2' \
-    '[ $($PROG file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
Signature · 1 line
1.2.4.g4668