Code

Merge branch 'maint'
[git.git] / t / t0021-conversion.sh
index bab9ecc34e0304e855e7f4aa131f89c0300bc3e2..8fc39d77cec6168dae930beef785597dace24aa3 100755 (executable)
@@ -5,7 +5,9 @@ test_description='blob conversion via gitattributes'
 . ./test-lib.sh
 
 cat <<\EOF >rot13.sh
-tr '[a-zA-Z]' '[n-za-mN-ZA-M]'
+tr \
+  'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
+  'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
 EOF
 chmod +x rot13.sh
 
@@ -21,7 +23,7 @@ test_expect_success setup '
        {
            echo a b c d e f g h i j k l m
            echo n o p q r s t u v w x y z
-           echo '\''$ident$'\''
+           echo '\''$Id$'\''
        } >test &&
        cat test >test.t &&
        cat test >test.o &&
@@ -31,7 +33,7 @@ test_expect_success setup '
        git checkout -- test test.t test.i
 '
 
-script='s/^\$ident: \([0-9a-f]*\) \$/\1/p'
+script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
 
 test_expect_success check '
 
@@ -42,7 +44,48 @@ test_expect_success check '
        git diff --raw --exit-code :test :test.i &&
        id=$(git rev-parse --verify :test) &&
        embedded=$(sed -ne "$script" test.i) &&
-       test "z$id" = "z$embedded"
+       test "z$id" = "z$embedded" &&
+
+       git cat-file blob :test.t > test.r &&
+
+       ./rot13.sh < test.o > test.t &&
+       cmp test.r test.t
+'
+
+# If an expanded ident ever gets into the repository, we want to make sure that
+# it is collapsed before being expanded again on checkout
+test_expect_success expanded_in_repo '
+       {
+               echo "File with expanded keywords"
+               echo "\$Id\$"
+               echo "\$Id:\$"
+               echo "\$Id: 0000000000000000000000000000000000000000 \$"
+               echo "\$Id: NoSpaceAtEnd\$"
+               echo "\$Id:NoSpaceAtFront \$"
+               echo "\$Id:NoSpaceAtEitherEnd\$"
+               echo "\$Id: NoTerminatingSymbol"
+       } > expanded-keywords &&
+
+       {
+               echo "File with expanded keywords"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: 4f21723e7b15065df7de95bd46c8ba6fb1818f4c \$"
+               echo "\$Id: NoTerminatingSymbol"
+       } > expected-output &&
+
+       git add expanded-keywords &&
+       git commit -m "File with keywords expanded" &&
+
+       echo "expanded-keywords ident" >> .gitattributes &&
+
+       rm -f expanded-keywords &&
+       git checkout -- expanded-keywords &&
+       cat expanded-keywords &&
+       cmp expanded-keywords expected-output
 '
 
 test_done