#!/bin/sh # # Copyright (c) 2005 Junio C Hamano # global test_description := ''git checkout-index --prefix test. This test makes sure that --prefix option works as advertised, and also verifies that such leading path may contain symlinks, unlike the GIT controlled paths. '' source ./test-lib.sh test_expect_success 'setup' ' mkdir path1 && echo frotz >path0 && echo rezrov >path1/file1 && git update-index --add path0 path1/file1 ' test_expect_success SYMLINKS 'have symlink in place where dir is expected.' ' rm -fr path0 path1 && mkdir path2 && ln -s path2 path1 && git checkout-index -f -a && test ! -h path1 && test -d path1 && test -f path1/file1 && test ! -f path2/file1 ' test_expect_success 'use --prefix=path2/' ' rm -fr path0 path1 path2 && mkdir path2 && git checkout-index --prefix=path2/ -f -a && test -f path2/path0 && test -f path2/path1/file1 && test ! -f path0 && test ! -f path1/file1 ' test_expect_success 'use --prefix=tmp-' ' rm -fr path0 path1 path2 tmp* && git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test -f tmp-path1/file1 && test ! -f path0 && test ! -f path1/file1 ' test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' ' rm -fr path0 path1 path2 tmp* && echo nitfol >tmp-path1 && mkdir tmp-path0 && git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test -f tmp-path1/file1 && test ! -f path0 && test ! -f path1/file1 ' test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' ' rm -fr path0 path1 path2 tmp* && mkdir tmp1 tmp1/orary && ln -s tmp1 tmp && git checkout-index --prefix=tmp/orary/ -f -a && test -d tmp1/orary && test -f tmp1/orary/path0 && test -f tmp1/orary/path1/file1 && test -h tmp ' test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' ' rm -fr path0 path1 path2 tmp* && mkdir tmp1 && ln -s tmp1 tmp && git checkout-index --prefix=tmp/orary- -f -a && test -f tmp1/orary-path0 && test -f tmp1/orary-path1/file1 && test -h tmp ' test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' ' rm -fr path0 path1 path2 tmp* && mkdir tmp1 && ln -s tmp1 tmp-path1 && git checkout-index --prefix=tmp- -f -a && test -f tmp-path0 && test ! -h tmp-path1 && test -d tmp-path1 && test -f tmp-path1/file1 ' test_expect_success 'apply filter from working tree .gitattributes with --prefix' ' rm -fr path0 path1 path2 tmp* && mkdir path1 && mkdir tmp && git config filter.replace-all.smudge "sed -e s/./,/g" && git config filter.replace-all.clean cat && git config filter.replace-all.required true && echo "file1 filter=replace-all" >path1/.gitattributes && git checkout-index --prefix=tmp/ -f -a && echo frotz >expected && test_cmp expected tmp/path0 && echo ,,,,,, >expected && test_cmp expected tmp/path1/file1 ' test_expect_success 'apply CRLF filter from working tree .gitattributes with --prefix' ' rm -fr path0 path1 path2 tmp* && mkdir path1 && mkdir tmp && echo "file1 eol=crlf" >path1/.gitattributes && git checkout-index --prefix=tmp/ -f -a && echo rezrovQ >expected && tr \\015 Q actual && test_cmp expected actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git checkout-index --prefix test.\n"> <"\n"> <"This test makes sure that --prefix option works as advertised, and\n"> <"also verifies that such leading path may contain symlinks, unlike\n"> <"the GIT controlled paths.\n"> ) } spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\tmkdir path1 &&\n"> <"\techo frotz >path0 &&\n"> <"\techo rezrov >path1/file1 &&\n"> <"\tgit update-index --add path0 path1/file1\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"have symlink in place where dir is expected.">)} { (SQ <"\n"> <"\trm -fr path0 path1 &&\n"> <"\tmkdir path2 &&\n"> <"\tln -s path2 path1 &&\n"> <"\tgit checkout-index -f -a &&\n"> <"\ttest ! -h path1 && test -d path1 &&\n"> <"\ttest -f path1/file1 && test ! -f path2/file1\n"> ) } ) (C {(test_expect_success)} {(SQ <"use --prefix=path2/">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 &&\n"> <"\tmkdir path2 &&\n"> <"\tgit checkout-index --prefix=path2/ -f -a &&\n"> <"\ttest -f path2/path0 &&\n"> <"\ttest -f path2/path1/file1 &&\n"> <"\ttest ! -f path0 &&\n"> <"\ttest ! -f path1/file1\n"> ) } ) (C {(test_expect_success)} {(SQ <"use --prefix=tmp-">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tgit checkout-index --prefix=tmp- -f -a &&\n"> <"\ttest -f tmp-path0 &&\n"> <"\ttest -f tmp-path1/file1 &&\n"> <"\ttest ! -f path0 &&\n"> <"\ttest ! -f path1/file1\n"> ) } ) (C {(test_expect_success)} {(SQ <"use --prefix=tmp- but with a conflicting file and dir">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\techo nitfol >tmp-path1 &&\n"> <"\tmkdir tmp-path0 &&\n"> <"\tgit checkout-index --prefix=tmp- -f -a &&\n"> <"\ttest -f tmp-path0 &&\n"> <"\ttest -f tmp-path1/file1 &&\n"> <"\ttest ! -f path0 &&\n"> <"\ttest ! -f path1/file1\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"use --prefix=tmp/orary/ where tmp is a symlink">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tmkdir tmp1 tmp1/orary &&\n"> <"\tln -s tmp1 tmp &&\n"> <"\tgit checkout-index --prefix=tmp/orary/ -f -a &&\n"> <"\ttest -d tmp1/orary &&\n"> <"\ttest -f tmp1/orary/path0 &&\n"> <"\ttest -f tmp1/orary/path1/file1 &&\n"> <"\ttest -h tmp\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"use --prefix=tmp/orary- where tmp is a symlink">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tmkdir tmp1 &&\n"> <"\tln -s tmp1 tmp &&\n"> <"\tgit checkout-index --prefix=tmp/orary- -f -a &&\n"> <"\ttest -f tmp1/orary-path0 &&\n"> <"\ttest -f tmp1/orary-path1/file1 &&\n"> <"\ttest -h tmp\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"use --prefix=tmp- where tmp-path1 is a symlink">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tmkdir tmp1 &&\n"> <"\tln -s tmp1 tmp-path1 &&\n"> <"\tgit checkout-index --prefix=tmp- -f -a &&\n"> <"\ttest -f tmp-path0 &&\n"> <"\ttest ! -h tmp-path1 &&\n"> <"\ttest -d tmp-path1 &&\n"> <"\ttest -f tmp-path1/file1\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply filter from working tree .gitattributes with --prefix">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tmkdir path1 &&\n"> <"\tmkdir tmp &&\n"> <"\tgit config filter.replace-all.smudge \"sed -e s/./,/g\" &&\n"> <"\tgit config filter.replace-all.clean cat &&\n"> <"\tgit config filter.replace-all.required true &&\n"> <"\techo \"file1 filter=replace-all\" >path1/.gitattributes &&\n"> <"\tgit checkout-index --prefix=tmp/ -f -a &&\n"> <"\techo frotz >expected &&\n"> <"\ttest_cmp expected tmp/path0 &&\n"> <"\techo ,,,,,, >expected &&\n"> <"\ttest_cmp expected tmp/path1/file1\n"> ) } ) (C {(test_expect_success)} {(SQ <"apply CRLF filter from working tree .gitattributes with --prefix">)} { (SQ <"\n"> <"\trm -fr path0 path1 path2 tmp* &&\n"> <"\tmkdir path1 &&\n"> <"\tmkdir tmp &&\n"> <"\techo \"file1 eol=crlf\" >path1/.gitattributes &&\n"> <"\tgit checkout-index --prefix=tmp/ -f -a &&\n"> <"\techo rezrovQ >expected &&\n"> <"\ttr \\\\015 Q actual &&\n"> <"\ttest_cmp expected actual\n"> ) } ) (C {(test_done)}) ] )