1 # This file isn't used as a test script directly, instead it is
2 # sourced from t8001-annotate.sh and t8002-blame.sh.
6 case "$1" in -h) head="$2"; shift; shift ;; esac &&
7 echo "$PROG file $head" >&4 &&
8 $PROG file $head >actual
&&
11 my %count = map { $_ => 0 } keys %expect;
13 if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
15 for ($author) { s/^\s*//; s/\s*$//; }
20 while (my ($author, $count) = each %count) {
23 $value = $expect{$author} if defined $expect{$author};
24 if ($value != $count) {
31 print STDERR "Author $author (expected $value, attributed $count) $ok\n";
37 test_expect_success
'setup A lines' '
38 echo "1A quick brown fox jumps over the" >file &&
39 echo "lazy dog" >>file &&
41 GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \
42 git commit -a -m "Initial."
45 test_expect_success
'blame 1 author' '
49 test_expect_success
'setup B lines' '
50 echo "2A quick brown fox jumps over the" >>file &&
51 echo "lazy dog" >>file &&
52 GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \
53 git commit -a -m "Second."
56 test_expect_success
'blame 2 authors' '
60 test_expect_success
'setup B1 lines (branch1)' '
61 git checkout -b branch1 master &&
62 echo "3A slow green fox jumps into the" >>file &&
63 echo "well." >>file &&
64 GIT_AUTHOR_NAME="B1" GIT_AUTHOR_EMAIL="B1@test.git" \
65 git commit -a -m "Branch1-1"
68 test_expect_success
'blame 2 authors + 1 branch1 author' '
69 check_count A 2 B 2 B1 2
72 test_expect_success
'setup B2 lines (branch2)' '
73 git checkout -b branch2 master &&
74 sed -e "s/2A quick brown/4A quick brown lazy dog/" <file >file.new &&
76 GIT_AUTHOR_NAME="B2" GIT_AUTHOR_EMAIL="B2@test.git" \
77 git commit -a -m "Branch2-1"
80 test_expect_success
'blame 2 authors + 1 branch2 author' '
81 check_count A 2 B 1 B2 1
84 test_expect_success
'merge branch1 & branch2' '
88 test_expect_success
'blame 2 authors + 2 merged-in authors' '
89 check_count A 2 B 1 B1 2 B2 1
92 test_expect_success
'blame ancestor' '
93 check_count -h master A 2 B 2
96 test_expect_success
'blame great-ancestor' '
97 check_count -h master^ A 2
100 test_expect_success
'setup evil merge' '
101 echo "evil merge." >>file &&
102 git commit -a --amend
105 test_expect_success
'blame evil merge' '
106 check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1
109 test_expect_success
'setup incomplete line' '
110 echo "incomplete" | tr -d "\\012" >>file &&
111 GIT_AUTHOR_NAME="C" GIT_AUTHOR_EMAIL="C@test.git" \
112 git commit -a -m "Incomplete"
115 test_expect_success
'blame incomplete line' '
116 check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1 C 1
119 test_expect_success
'setup edits' '
124 } | sed -e "s/^3A/99/" -e "/^1A/d" -e "/^incomplete/d" >file &&
125 echo "incomplete" | tr -d "\\012" >>file &&
126 GIT_AUTHOR_NAME="D" GIT_AUTHOR_EMAIL="D@test.git" \
127 git commit -a -m "edit"
130 test_expect_success
'blame edits' '
131 check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1
134 test_expect_success
'setup obfuscated email' '
135 echo "No robots allowed" >file.new &&
136 cat file >>file.new &&
138 GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" \
139 git commit -a -m "norobots"
142 test_expect_success
'blame obfuscated email' '
143 check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1