3 test_description
='git blame corner cases'
6 pick_fc
='s/^[0-9a-f^]* *\([^ ]*\) *(\([^ ]*\) .*/\1-\2/'
8 test_expect_success setup
'
10 echo A A A A A >one &&
11 echo B B B B B >two &&
12 echo C C C C C >tres &&
14 git add one two tres mouse &&
16 GIT_AUTHOR_NAME=Initial git commit -m Initial &&
22 git add uno dos tres mouse &&
24 GIT_AUTHOR_NAME=Second git commit -a -m Second &&
29 GIT_AUTHOR_NAME=Third git commit -m Third &&
34 GIT_AUTHOR_NAME=Fourth git commit -m Fourth &&
44 GIT_AUTHOR_NAME=Fifth git commit -m Fifth
47 test_expect_success
'straight copy without -C' '
49 git blame uno | grep Second
53 test_expect_success
'straight move without -C' '
55 git blame dos | grep Initial
59 test_expect_success
'straight copy with -C' '
61 git blame -C1 uno | grep Second
65 test_expect_success
'straight move with -C' '
67 git blame -C1 dos | grep Initial
71 test_expect_success
'straight copy with -C -C' '
73 git blame -C -C1 uno | grep Initial
77 test_expect_success
'straight move with -C -C' '
79 git blame -C -C1 dos | grep Initial
83 test_expect_success
'append without -C' '
85 git blame -L2 tres | grep Second
89 test_expect_success
'append with -C' '
91 git blame -L2 -C1 tres | grep Second
95 test_expect_success
'append with -C -C' '
97 git blame -L2 -C -C1 tres | grep Second
101 test_expect_success
'append with -C -C -C' '
103 git blame -L2 -C -C -C1 tres | grep Initial
107 test_expect_success
'blame wholesale copy' '
109 git blame -f -C -C1 HEAD^ -- cow | sed -e "$pick_fc" >current &&
115 test_cmp expected current
119 test_expect_success
'blame wholesale copy and more' '
121 git blame -f -C -C1 HEAD -- cow | sed -e "$pick_fc" >current &&
128 test_cmp expected current
132 test_expect_success
'blame path that used to be a directory' '
134 echo A A A A A >path/file &&
135 echo B B B B B >path/elif &&
138 git commit -m "path was a directory" &&
140 echo A A A A A >path &&
143 git commit -m "path is a regular file" &&
144 git blame HEAD^.. -- path
147 test_expect_success
'blame to a commit with no author name' '
148 TREE=`git rev-parse HEAD:`
151 author <noname> 1234567890 +0000
152 committer David Reiss <dreiss@facebook.com> 1234567890 +0000
156 COMMIT=`git hash-object -t commit -w badcommit`
157 git --no-pager blame $COMMIT -- uno >/dev/null