]>
Commit | Line | Data |
---|---|---|
3fed15f5 JH |
1 | #!/bin/sh |
2 | ||
3 | test_description='blob conversion via gitattributes' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
aa4ed402 | 7 | cat <<\EOF >rot13.sh |
7339eb08 JK |
8 | tr \ |
9 | 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \ | |
10 | 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM' | |
aa4ed402 JH |
11 | EOF |
12 | chmod +x rot13.sh | |
13 | ||
3fed15f5 | 14 | test_expect_success setup ' |
aa4ed402 JH |
15 | git config filter.rot13.smudge ./rot13.sh && |
16 | git config filter.rot13.clean ./rot13.sh && | |
17 | ||
3fed15f5 | 18 | { |
aa4ed402 | 19 | echo "*.t filter=rot13" |
3fed15f5 JH |
20 | echo "*.i ident" |
21 | } >.gitattributes && | |
22 | ||
23 | { | |
24 | echo a b c d e f g h i j k l m | |
25 | echo n o p q r s t u v w x y z | |
af9b54bb | 26 | echo '\''$Id$'\'' |
3fed15f5 JH |
27 | } >test && |
28 | cat test >test.t && | |
29 | cat test >test.o && | |
30 | cat test >test.i && | |
31 | git add test test.t test.i && | |
32 | rm -f test test.t test.i && | |
33 | git checkout -- test test.t test.i | |
34 | ' | |
35 | ||
af9b54bb | 36 | script='s/^\$Id: \([0-9a-f]*\) \$/\1/p' |
3fed15f5 JH |
37 | |
38 | test_expect_success check ' | |
39 | ||
40 | cmp test.o test && | |
41 | cmp test.o test.t && | |
42 | ||
43 | # ident should be stripped in the repository | |
44 | git diff --raw --exit-code :test :test.i && | |
45 | id=$(git rev-parse --verify :test) && | |
46 | embedded=$(sed -ne "$script" test.i) && | |
a0ae35ae JS |
47 | test "z$id" = "z$embedded" && |
48 | ||
49 | git cat-file blob :test.t > test.r && | |
50 | ||
51 | ./rot13.sh < test.o > test.t && | |
52 | cmp test.r test.t | |
3fed15f5 JH |
53 | ' |
54 | ||
dfab71cb AP |
55 | # If an expanded ident ever gets into the repository, we want to make sure that |
56 | # it is collapsed before being expanded again on checkout | |
57 | test_expect_success expanded_in_repo ' | |
58 | { | |
59 | echo "File with expanded keywords" | |
60 | echo "\$Id\$" | |
61 | echo "\$Id:\$" | |
62 | echo "\$Id: 0000000000000000000000000000000000000000 \$" | |
63 | echo "\$Id: NoSpaceAtEnd\$" | |
64 | echo "\$Id:NoSpaceAtFront \$" | |
65 | echo "\$Id:NoSpaceAtEitherEnd\$" | |
66 | echo "\$Id: NoTerminatingSymbol" | |
67 | } > expanded-keywords && | |
68 | ||
69 | { | |
70 | echo "File with expanded keywords" | |
71 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
72 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
73 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
74 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
75 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
76 | echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$" | |
77 | echo "\$Id: NoTerminatingSymbol" | |
78 | } > expected-output && | |
79 | ||
80 | git add expanded-keywords && | |
81 | git commit -m "File with keywords expanded" && | |
82 | ||
83 | echo "expanded-keywords ident" >> .gitattributes && | |
84 | ||
85 | rm -f expanded-keywords && | |
86 | git checkout -- expanded-keywords && | |
87 | cat expanded-keywords && | |
88 | cmp expanded-keywords expected-output | |
89 | ' | |
90 | ||
3fed15f5 | 91 | test_done |