3 test_description
='git blame'
7 .
"$TEST_DIRECTORY"/annotate-tests.sh
9 test_expect_success
'blame untracked file in empty repo' '
11 test_must_fail git blame untracked
14 PROG
='git blame -c -e'
15 test_expect_success
'blame --show-email' '
21 "<author@example.com>" 1 \
24 "<E at test dot git>" 1
27 test_expect_success
'setup showEmail tests' '
28 echo "bin: test number 1" >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
36 cat >expected_e <<-\EOF
37 (<email1@test.git> 2010-01-01 01:00:00 +0000 1) bin: test number 1
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_expect_success
'set up abbrev tests' '
91 sha1=$(git rev-parse --verify HEAD) &&
94 echo $sha1 | cut -c 1-$expect >expect &&
95 git blame "$@" abbrev.t >actual &&
96 perl -lne "/[0-9a-f]+/ and print \$&" <actual >actual.sha &&
97 test_cmp expect actual.sha
101 test_expect_success
'blame --abbrev=<n> works' '
102 # non-boundary commits get +1 for alignment
103 check_abbrev 31 --abbrev=30 HEAD &&
104 check_abbrev 30 --abbrev=30 ^HEAD
107 test_expect_success
'blame -l aligns regular and boundary commits' '
108 check_abbrev 40 -l HEAD &&
109 check_abbrev 39 -l ^HEAD
112 test_expect_success
'blame --abbrev=40 behaves like -l' '
113 check_abbrev 40 --abbrev=40 HEAD &&
114 check_abbrev 39 --abbrev=40 ^HEAD
117 test_expect_success
'--no-abbrev works like --abbrev=40' '
118 check_abbrev 40 --no-abbrev