git-p4: chdir now properly sets PWD environment variable in msysGit
[git/git-p4.git] / t / t0021-conversion.sh
blob8fc39d77cec6168dae930beef785597dace24aa3
1 #!/bin/sh
3 test_description='blob conversion via gitattributes'
5 . ./test-lib.sh
7 cat <<\EOF >rot13.sh
8 tr \
9 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
10 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
11 EOF
12 chmod +x rot13.sh
14 test_expect_success setup '
15 git config filter.rot13.smudge ./rot13.sh &&
16 git config filter.rot13.clean ./rot13.sh &&
19 echo "*.t filter=rot13"
20 echo "*.i ident"
21 } >.gitattributes &&
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
26 echo '\''$Id$'\''
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
36 script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
38 test_expect_success check '
40 cmp test.o test &&
41 cmp test.o test.t &&
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) &&
47 test "z$id" = "z$embedded" &&
49 git cat-file blob :test.t > test.r &&
51 ./rot13.sh < test.o > test.t &&
52 cmp test.r test.t
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 '
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 &&
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 &&
80 git add expanded-keywords &&
81 git commit -m "File with keywords expanded" &&
83 echo "expanded-keywords ident" >> .gitattributes &&
85 rm -f expanded-keywords &&
86 git checkout -- expanded-keywords &&
87 cat expanded-keywords &&
88 cmp expanded-keywords expected-output
91 test_done