3619f8a4d26d65809377f91b1f4b58934e9240fb
1 #!/bin/sh
3 test_description='git blame textconv support'
4 . ./test-lib.sh
6 find_blame() {
7 sed -e 's/^[^(]*//'
8 }
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 git add . &&
21 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
22 echo "bin: test 1 version 2" >one.bin &&
23 echo "bin: test number 2 version 2" >>two.bin &&
24 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
25 '
27 cat >expected <<EOF
28 (Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
29 EOF
31 test_expect_success 'no filter specified' '
32 git blame one.bin >blame &&
33 find_blame Number2 <blame >result &&
34 test_cmp expected result
35 '
37 test_expect_success 'setup textconv filters' '
38 echo "*.bin diff=test" >.gitattributes &&
39 git config diff.test.textconv ./helper &&
40 git config diff.test.cachetextconv false
41 '
43 test_expect_success 'blame with --no-textconv' '
44 git blame --no-textconv one.bin >blame &&
45 find_blame <blame> result &&
46 test_cmp expected result
47 '
49 cat >expected <<EOF
50 (Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
51 EOF
53 test_expect_success 'basic blame on last commit' '
54 git blame one.bin >blame &&
55 find_blame <blame >result &&
56 test_cmp expected result
57 '
59 cat >expected <<EOF
60 (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
61 (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
62 EOF
64 test_expect_success 'blame --textconv going through revisions' '
65 git blame --textconv two.bin >blame &&
66 find_blame <blame >result &&
67 test_cmp expected result
68 '
70 test_expect_success 'make a new commit' '
71 echo "bin: test number 2 version 3" >>two.bin &&
72 GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
73 '
75 test_expect_success 'blame from previous revision' '
76 git blame HEAD^ two.bin >blame &&
77 find_blame <blame >result &&
78 test_cmp expected result
79 '
81 test_done