name-rev: extend --refs to accept multiple patterns
[git/raj.git] / t / t8002-blame.sh
blobab79de95441f4f474525b48b14313f1d04172fce
1 #!/bin/sh
3 test_description='git blame'
4 . ./test-lib.sh
6 PROG='git blame -c'
7 . "$TEST_DIRECTORY"/annotate-tests.sh
9 test_expect_success 'blame untracked file in empty repo' '
10 >untracked &&
11 test_must_fail git blame untracked
14 PROG='git blame -c -e'
15 test_expect_success 'blame --show-email' '
16 check_count \
17 "<A@test.git>" 1 \
18 "<B@test.git>" 1 \
19 "<B1@test.git>" 1 \
20 "<B2@test.git>" 1 \
21 "<author@example.com>" 1 \
22 "<C@test.git>" 1 \
23 "<D@test.git>" 1 \
24 "<E at test dot git>" 1
27 test_expect_success 'setup showEmail tests' '
28 echo "bin: test number 1" >one &&
29 git add one &&
30 GIT_AUTHOR_NAME=name1 \
31 GIT_AUTHOR_EMAIL=email1@test.git \
32 git commit -m First --date="2010-01-01 01:00:00" &&
33 cat >expected_n <<-\EOF &&
34 (name1 2010-01-01 01:00:00 +0000 1) bin: test number 1
35 EOF
36 cat >expected_e <<-\EOF
37 (<email1@test.git> 2010-01-01 01:00:00 +0000 1) bin: test number 1
38 EOF
41 find_blame () {
42 sed -e 's/^[^(]*//'
45 test_expect_success 'blame with no options and no config' '
46 git blame one >blame &&
47 find_blame <blame >result &&
48 test_cmp expected_n result
51 test_expect_success 'blame with showemail options' '
52 git blame --show-email one >blame1 &&
53 find_blame <blame1 >result &&
54 test_cmp expected_e result &&
55 git blame -e one >blame2 &&
56 find_blame <blame2 >result &&
57 test_cmp expected_e result &&
58 git blame --no-show-email one >blame3 &&
59 find_blame <blame3 >result &&
60 test_cmp expected_n result
63 test_expect_success 'blame with showEmail config false' '
64 git config blame.showEmail false &&
65 git blame one >blame1 &&
66 find_blame <blame1 >result &&
67 test_cmp expected_n result &&
68 git blame --show-email one >blame2 &&
69 find_blame <blame2 >result &&
70 test_cmp expected_e result &&
71 git blame -e one >blame3 &&
72 find_blame <blame3 >result &&
73 test_cmp expected_e result &&
74 git blame --no-show-email one >blame4 &&
75 find_blame <blame4 >result &&
76 test_cmp expected_n result
79 test_expect_success 'blame with showEmail config true' '
80 git config blame.showEmail true &&
81 git blame one >blame1 &&
82 find_blame <blame1 >result &&
83 test_cmp expected_e result &&
84 git blame --no-show-email one >blame2 &&
85 find_blame <blame2 >result &&
86 test_cmp expected_n result
89 test_done