1 # This file isn't used as a test script directly, instead it is
2 # sourced from t8001-annotate.sh and t8001-blame.sh.
6 case "$1" in -h) head="$2"; shift; shift ;; esac
7 $PROG file $head >.result || return 1
8 cat .result | perl -e '
12 if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
14 for ($author) { s/^\s*//; s/\s*$//; }
15 if (exists $expect{$author}) {
21 while (my ($author, $count) = each %count) {
23 if ($expect{$author} != $count) {
30 print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
37 'prepare reference tree' \
38 'echo "1A quick brown fox jumps over the" >file &&
39 echo "lazy dog" >>file &&
41 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
44 'check all lines blamed on A' \
48 'Setup new lines blamed on B' \
49 'echo "2A quick brown fox jumps over the" >>file &&
50 echo "lazy dog" >> file &&
51 GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
54 'Two lines blamed on A, two on B' \
58 'merge-setup part 1' \
59 'git checkout -b branch1 master &&
60 echo "3A slow green fox jumps into the" >> file &&
61 echo "well." >> file &&
62 GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
65 'Two lines blamed on A, two on B, two on B1' \
66 'check_count A 2 B 2 B1 2'
69 'merge-setup part 2' \
70 'git checkout -b branch2 master &&
71 sed -e "s/2A quick brown/4A quick brown lazy dog/" < file > file.new &&
73 GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
76 'Two lines blamed on A, one on B, one on B2' \
77 'check_count A 2 B 1 B2 1'
80 'merge-setup part 3' \
84 'Two lines blamed on A, one on B, two on B1, one on B2' \
85 'check_count A 2 B 1 B1 2 B2 1'
88 'Annotating an old revision works' \
89 'check_count -h master A 2 B 2'
92 'Annotating an old revision works' \
93 'check_count -h master^ A 2'
96 'merge-setup part 4' \
97 'echo "evil merge." >>file &&
98 git commit -a --amend'
100 test_expect_success \
101 'Two lines blamed on A, one on B, two on B1, one on B2, one on A U Thor' \
102 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1'
104 test_expect_success \
105 'an incomplete line added' \
106 'echo "incomplete" | tr -d "\\012" >>file &&
107 GIT_AUTHOR_NAME="C" git commit -a -m "Incomplete"'
109 test_expect_success \
110 'With incomplete lines.' \
111 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1 C 1'
113 test_expect_success \
115 'perl -p -i.orig -e "s/^1A.*\n$//; s/^3A/99/" file &&
116 GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
118 test_expect_success \
120 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1'