diff --whitespace: fix blank lines at end
[tgit.git] / t / t8003-blame.sh
blob966bb0a61a89ed63dec085338d3c45f766a7f777
1 #!/bin/sh
3 test_description='git blame corner cases'
4 . ./test-lib.sh
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 &&
13 echo ABC >mouse &&
14 git add one two tres mouse &&
15 test_tick &&
16 GIT_AUTHOR_NAME=Initial git commit -m Initial &&
18 cat one >uno &&
19 mv two dos &&
20 cat one >>tres &&
21 echo DEF >>mouse
22 git add uno dos tres mouse &&
23 test_tick &&
24 GIT_AUTHOR_NAME=Second git commit -a -m Second &&
26 echo GHIJK >>mouse &&
27 git add mouse &&
28 test_tick &&
29 GIT_AUTHOR_NAME=Third git commit -m Third &&
31 cat mouse >cow &&
32 git add cow &&
33 test_tick &&
34 GIT_AUTHOR_NAME=Fourth git commit -m Fourth &&
37 echo ABC
38 echo DEF
39 echo XXXX
40 echo GHIJK
41 } >cow &&
42 git add cow &&
43 test_tick &&
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 &&
111 echo mouse-Initial
112 echo mouse-Second
113 echo mouse-Third
114 } >expected &&
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 &&
123 echo mouse-Initial
124 echo mouse-Second
125 echo cow-Fifth
126 echo mouse-Third
127 } >expected &&
128 test_cmp expected current
132 test_done