1#!/bin/sh
23
test_description='git blame'
4. ./test-lib.sh
56
PROG='git blame -c'
7. "$TEST_DIRECTORY"/annotate-tests.sh
89
PROG='git blame -c -e'
10test_expect_success 'blame --show-email' '
11check_count \
12"<A@test.git>" 1 \
13"<B@test.git>" 1 \
14"<B1@test.git>" 1 \
15"<B2@test.git>" 1 \
16"<author@example.com>" 1 \
17"<C@test.git>" 1 \
18"<D@test.git>" 1 \
19"<E at test dot git>" 1
20'
2122
test_expect_success 'setup showEmail tests' '
23echo "bin: test number 1" >one &&
24git add one &&
25GIT_AUTHOR_NAME=name1 \
26GIT_AUTHOR_EMAIL=email1@test.git \
27git commit -m First --date="2010-01-01 01:00:00" &&
28cat >expected_n <<-\EOF &&
29(name1 2010-01-01 01:00:00 +0000 1) bin: test number 1
30EOF
31cat >expected_e <<-\EOF
32(<email1@test.git> 2010-01-01 01:00:00 +0000 1) bin: test number 1
33EOF
34'
3536
find_blame () {
37sed -e 's/^[^(]*//'
38}
3940
test_expect_success 'blame with no options and no config' '
41git blame one >blame &&
42find_blame <blame >result &&
43test_cmp expected_n result
44'
4546
test_expect_success 'blame with showemail options' '
47git blame --show-email one >blame1 &&
48find_blame <blame1 >result &&
49test_cmp expected_e result &&
50git blame -e one >blame2 &&
51find_blame <blame2 >result &&
52test_cmp expected_e result &&
53git blame --no-show-email one >blame3 &&
54find_blame <blame3 >result &&
55test_cmp expected_n result
56'
5758
test_expect_success 'blame with showEmail config false' '
59git config blame.showEmail false &&
60git blame one >blame1 &&
61find_blame <blame1 >result &&
62test_cmp expected_n result &&
63git blame --show-email one >blame2 &&
64find_blame <blame2 >result &&
65test_cmp expected_e result &&
66git blame -e one >blame3 &&
67find_blame <blame3 >result &&
68test_cmp expected_e result &&
69git blame --no-show-email one >blame4 &&
70find_blame <blame4 >result &&
71test_cmp expected_n result
72'
7374
test_expect_success 'blame with showEmail config true' '
75git config blame.showEmail true &&
76git blame one >blame1 &&
77find_blame <blame1 >result &&
78test_cmp expected_e result &&
79git blame --no-show-email one >blame2 &&
80find_blame <blame2 >result &&
81test_cmp expected_n result
82'
8384
test_done