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 | perl
-e '
11 if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
13 for ($author) { s/^\s*//; s/\s*$//; }
14 if (exists $expect{$author}) {
20 while (my ($author, $count) = each %count) {
22 if ($expect{$author} != $count) {
29 print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
36 'prepare reference tree' \
37 'echo "1A quick brown fox jumps over the" >file &&
38 echo "lazy dog" >>file &&
40 GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
43 'check all lines blamed on A' \
47 'Setup new lines blamed on B' \
48 'echo "2A quick brown fox jumps over the" >>file &&
49 echo "lazy dog" >> file &&
50 GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
53 'Two lines blamed on A, two on B' \
57 'merge-setup part 1' \
58 'git checkout -b branch1 master &&
59 echo "3A slow green fox jumps into the" >> file &&
60 echo "well." >> file &&
61 GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
64 'Two lines blamed on A, two on B, two on B1' \
65 'check_count A 2 B 2 B1 2'
68 'merge-setup part 2' \
69 'git checkout -b branch2 master &&
70 sed -e "s/2A quick brown/4A quick brown lazy dog/" < file > file.new &&
72 GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
75 'Two lines blamed on A, one on B, one on B2' \
76 'check_count A 2 B 1 B2 1'
79 'merge-setup part 3' \
83 'Two lines blamed on A, one on B, two on B1, one on B2' \
84 'check_count A 2 B 1 B1 2 B2 1'
87 'Annotating an old revision works' \
88 'check_count -h master A 2 B 2'
91 'Annotating an old revision works' \
92 'check_count -h master^ A 2'
95 'merge-setup part 4' \
96 'echo "evil merge." >>file &&
97 EDITOR=: VISUAL=: git commit -a --amend'
100 'Two lines blamed on A, one on B, two on B1, one on B2, one on A U Thor' \
101 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1'
103 test_expect_success \
104 'an incomplete line added' \
105 'echo "incomplete" | tr -d "\\012" >>file &&
106 GIT_AUTHOR_NAME="C" git commit -a -m "Incomplete"'
108 test_expect_success \
109 'With incomplete lines.' \
110 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1 C 1'
112 test_expect_success \
114 'perl -p -i.orig -e "s/^1A.*\n$//; s/^3A/99/" file &&
115 GIT_AUTHOR_NAME="D" git commit -a -m "edit"'
117 test_expect_success \
119 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1'