aboutsummaryrefslogtreecommitdiff
path: root/t/t8001-annotate.sh
blob: 172908a5b082805f62d8c570a1f2ee77064a3697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh

test_description='git-annotate'
. ./test-lib.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' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'

test_expect_success \
    'Two lines blamed on B' \
    '[ $(git annotate 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' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'

test_expect_success \
    'Two lines blamed on B' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 2 ]'

test_expect_success \
    'Two lines blamed on B1' \
    '[ $(git annotate 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' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'

test_expect_success \
    'One line blamed on B' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'

test_expect_success \
    'One line blamed on B2' \
    '[ $(git annotate 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' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'

test_expect_success \
    'One line blamed on B' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'

test_expect_success \
    'Two lines blamed on B1' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'

test_expect_success \
    'One line blamed on B2' \
    '[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'

test_done