Merge branch 'gc/http-with-non-ascii-username-url' into next
[git/srabbelier.git] / t / t8006-blame-textconv.sh
blobdbf623bce5598860800fa463c26ec8145d6e2400
1 #!/bin/sh
3 test_description='git blame textconv support'
4 . ./test-lib.sh
6 find_blame() {
7 sed -e 's/^[^(]*//'
10 cat >helper <<'EOF'
11 #!/bin/sh
12 grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
13 sed 's/^bin: /converted: /' "$1"
14 EOF
15 chmod +x helper
17 test_expect_success 'setup ' '
18 echo "bin: test 1" >one.bin &&
19 echo "bin: test number 2" >two.bin &&
20 if test_have_prereq SYMLINKS; then
21 ln -s one.bin symlink.bin
22 fi &&
23 git add . &&
24 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
25 echo "bin: test 1 version 2" >one.bin &&
26 echo "bin: test number 2 version 2" >>two.bin &&
27 if test_have_prereq SYMLINKS; then
28 ln -sf two.bin symlink.bin
29 fi &&
30 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
33 cat >expected <<EOF
34 (Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
35 EOF
37 test_expect_success 'no filter specified' '
38 git blame one.bin >blame &&
39 find_blame Number2 <blame >result &&
40 test_cmp expected result
43 test_expect_success 'setup textconv filters' '
44 echo "*.bin diff=test" >.gitattributes &&
45 git config diff.test.textconv ./helper &&
46 git config diff.test.cachetextconv false
49 test_expect_success 'blame with --no-textconv' '
50 git blame --no-textconv one.bin >blame &&
51 find_blame <blame> result &&
52 test_cmp expected result
55 cat >expected <<EOF
56 (Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
57 EOF
59 test_expect_success 'basic blame on last commit' '
60 git blame one.bin >blame &&
61 find_blame <blame >result &&
62 test_cmp expected result
65 cat >expected <<EOF
66 (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
67 (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
68 EOF
70 test_expect_success 'blame --textconv going through revisions' '
71 git blame --textconv two.bin >blame &&
72 find_blame <blame >result &&
73 test_cmp expected result
76 test_expect_success 'make a new commit' '
77 echo "bin: test number 2 version 3" >>two.bin &&
78 GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
81 test_expect_success 'blame from previous revision' '
82 git blame HEAD^ two.bin >blame &&
83 find_blame <blame >result &&
84 test_cmp expected result
87 cat >expected <<EOF
88 (Number2 2010-01-01 20:00:00 +0000 1) two.bin
89 EOF
91 test_expect_success SYMLINKS 'blame with --no-textconv (on symlink)' '
92 git blame --no-textconv symlink.bin >blame &&
93 find_blame <blame >result &&
94 test_cmp expected result
97 test_expect_success SYMLINKS 'blame --textconv (on symlink)' '
98 git blame --textconv symlink.bin >blame &&
99 find_blame <blame >result &&
100 test_cmp expected result
103 # cp two.bin three.bin and make small tweak
104 # (this will direct blame -C -C three.bin to consider two.bin and symlink.bin)
105 test_expect_success SYMLINKS 'make another new commit' '
106 cat >three.bin <<\EOF &&
107 bin: test number 2
108 bin: test number 2 version 2
109 bin: test number 2 version 3
110 bin: test number 3
112 git add three.bin &&
113 GIT_AUTHOR_NAME=Number4 git commit -a -m Fourth --date="2010-01-01 23:00:00"
116 test_expect_success SYMLINKS 'blame on last commit (-C -C, symlink)' '
117 git blame -C -C three.bin >blame &&
118 find_blame <blame >result &&
119 cat >expected <<\EOF &&
120 (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
121 (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
122 (Number3 2010-01-01 22:00:00 +0000 3) converted: test number 2 version 3
123 (Number4 2010-01-01 23:00:00 +0000 4) converted: test number 3
125 test_cmp expected result
128 test_done