]>
Commit | Line | Data |
---|---|---|
37d29e10 AB |
1 | #!/bin/sh |
2 | ||
3 | test_description='git blame textconv support' | |
4 | . ./test-lib.sh | |
5 | ||
6 | find_blame() { | |
7 | sed -e 's/^[^(]*//' | |
8 | } | |
9 | ||
10 | cat >helper <<'EOF' | |
11 | #!/bin/sh | |
12 | sed 's/^/converted: /' "$@" | |
13 | EOF | |
14 | chmod +x helper | |
15 | ||
16 | test_expect_success 'setup ' ' | |
17 | echo test 1 >one.bin && | |
18 | echo test number 2 >two.bin && | |
19 | git add . && | |
20 | GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" && | |
21 | echo test 1 version 2 >one.bin && | |
22 | echo test number 2 version 2 >>two.bin && | |
23 | GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00" | |
24 | ' | |
25 | ||
26 | cat >expected <<EOF | |
27 | (Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2 | |
28 | EOF | |
29 | ||
30 | test_expect_success 'no filter specified' ' | |
31 | git blame one.bin >blame && | |
32 | find_blame Number2 <blame >result && | |
33 | test_cmp expected result | |
34 | ' | |
35 | ||
36 | test_expect_success 'setup textconv filters' ' | |
37 | echo "*.bin diff=test" >.gitattributes && | |
38 | git config diff.test.textconv ./helper && | |
39 | git config diff.test.cachetextconv false | |
40 | ' | |
41 | ||
42 | test_expect_success 'blame with --no-textconv' ' | |
43 | git blame --no-textconv one.bin >blame && | |
44 | find_blame <blame> result && | |
45 | test_cmp expected result | |
46 | ' | |
47 | ||
48 | cat >expected <<EOF | |
49 | (Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2 | |
50 | EOF | |
51 | ||
52 | test_expect_success 'basic blame on last commit' ' | |
53 | git blame one.bin >blame && | |
54 | find_blame <blame >result && | |
55 | test_cmp expected result | |
56 | ' | |
57 | ||
58 | cat >expected <<EOF | |
59 | (Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2 | |
60 | (Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2 | |
61 | EOF | |
62 | ||
63 | test_expect_success 'blame --textconv going through revisions' ' | |
64 | git blame --textconv two.bin >blame && | |
65 | find_blame <blame >result && | |
66 | test_cmp expected result | |
67 | ' | |
68 | ||
69 | test_expect_success 'make a new commit' ' | |
70 | echo "test number 2 version 3" >>two.bin && | |
71 | GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00" | |
72 | ' | |
73 | ||
74 | test_expect_success 'blame from previous revision' ' | |
75 | git blame HEAD^ two.bin >blame && | |
76 | find_blame <blame >result && | |
77 | test_cmp expected result | |
78 | ' | |
79 | ||
80 | test_done |