3 test_description='git blame textconv support'
12 grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
13 sed 's/^bin: /converted: /' "$1"
17 test_expect_success 'setup ' '
18 echo "bin: test number 0" >zero.bin &&
19 echo "bin: test 1" >one.bin &&
20 echo "bin: test number 2" >two.bin &&
21 if test_have_prereq SYMLINKS; then
22 ln -s one.bin symlink.bin
25 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
26 echo "bin: test 1 version 2" >one.bin &&
27 echo "bin: test number 2 version 2" >>two.bin &&
28 if test_have_prereq SYMLINKS; then
29 ln -sf two.bin symlink.bin
31 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
35 (Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
38 test_expect_success 'no filter specified' '
39 git blame one.bin >blame &&
40 find_blame Number2 <blame >result &&
41 test_cmp expected result
44 test_expect_success 'setup textconv filters' '
45 echo "*.bin diff=test" >.gitattributes &&
46 echo "zero.bin eol=crlf" >>.gitattributes &&
47 git config diff.test.textconv ./helper &&
48 git config diff.test.cachetextconv false
51 test_expect_success 'blame with --no-textconv' '
52 git blame --no-textconv one.bin >blame &&
53 find_blame <blame> result &&
54 test_cmp expected result
58 (Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
61 test_expect_success 'basic blame on last commit' '
62 git blame one.bin >blame &&
63 find_blame <blame >result &&
64 test_cmp expected result
68 (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
69 (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
72 test_expect_success 'blame --textconv going through revisions' '
73 git blame --textconv two.bin >blame &&
74 find_blame <blame >result &&
75 test_cmp expected result
78 test_expect_success 'blame --textconv with local changes' '
79 test_when_finished "git checkout zero.bin" &&
80 printf "bin: updated number 0\015" >zero.bin &&
81 git blame --textconv zero.bin >blame &&
82 expect="(Not Committed Yet ....-..-.. ..:..:.. +0000 1)" &&
83 expect="$expect converted: updated number 0" &&
84 expr "$(find_blame <blame)" : "^$expect"
87 test_expect_success 'make a new commit' '
88 echo "bin: test number 2 version 3" >>two.bin &&
89 GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
92 test_expect_success 'blame from previous revision' '
93 git blame HEAD^ two.bin >blame &&
94 find_blame <blame >result &&
95 test_cmp expected result
99 (Number2 2010-01-01 20:00:00 +0000 1) two.bin
102 test_expect_success SYMLINKS 'blame with --no-textconv (on symlink)' '
103 git blame --no-textconv symlink.bin >blame &&
104 find_blame <blame >result &&
105 test_cmp expected result
108 test_expect_success SYMLINKS 'blame --textconv (on symlink)' '
109 git blame --textconv symlink.bin >blame &&
110 find_blame <blame >result &&
111 test_cmp expected result
114 # cp two.bin three.bin and make small tweak
115 # (this will direct blame -C -C three.bin to consider two.bin and symlink.bin)
116 test_expect_success SYMLINKS 'make another new commit' '
117 cat >three.bin <<\EOF &&
119 bin: test number 2 version 2
120 bin: test number 2 version 3
124 GIT_AUTHOR_NAME=Number4 git commit -a -m Fourth --date="2010-01-01 23:00:00"
127 test_expect_success SYMLINKS 'blame on last commit (-C -C, symlink)' '
128 git blame -C -C three.bin >blame &&
129 find_blame <blame >result &&
130 cat >expected <<\EOF &&
131 (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
132 (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
133 (Number3 2010-01-01 22:00:00 +0000 3) converted: test number 2 version 3
134 (Number4 2010-01-01 23:00:00 +0000 4) converted: test number 3
136 test_cmp expected result