diff options
Diffstat (limited to 't/t0021-conversion.sh')
-rwxr-xr-x | t/t0021-conversion.sh | 159 |
1 files changed, 89 insertions, 70 deletions
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index 33dfc9c..0b49970 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -8,8 +8,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh . "$TEST_DIRECTORY"/lib-terminal.sh -TEST_ROOT="$PWD" -PATH=$TEST_ROOT:$PATH +PATH=$PWD:$PATH +TEST_ROOT="$(pwd)" write_script <<\EOF "$TEST_ROOT/rot13.sh" tr \ @@ -17,9 +17,6 @@ tr \ 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM' EOF -write_script rot13-filter.pl "$PERL_PATH" \ - <"$TEST_DIRECTORY"/t0021/rot13-filter.pl - generate_random_characters () { LEN=$1 NAME=$2 @@ -76,13 +73,13 @@ test_expect_success setup ' git config filter.rot13.clean ./rot13.sh && { - echo "*.t filter=rot13" + echo "*.t filter=rot13" && echo "*.i ident" } >.gitattributes && { - 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 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 '\''$Id$'\'' } >test && cat test >test.t && @@ -118,17 +115,17 @@ test_expect_success check ' # 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" - echo "\$Id: Foreign Commit With Spaces \$" - } >expanded-keywords.0 && + cat >expanded-keywords.0 <<-\EOF && + File with expanded keywords + $Id$ + $Id:$ + $Id: 0000000000000000000000000000000000000000 $ + $Id: NoSpaceAtEnd$ + $Id:NoSpaceAtFront $ + $Id:NoSpaceAtEitherEnd$ + $Id: NoTerminatingSymbol + $Id: Foreign Commit With Spaces $ + EOF { cat expanded-keywords.0 && @@ -139,17 +136,17 @@ test_expect_success expanded_in_repo ' git commit -m "File with keywords expanded" && id=$(git rev-parse --verify :expanded-keywords) && - { - echo "File with expanded keywords" - echo "\$Id: $id \$" - echo "\$Id: $id \$" - echo "\$Id: $id \$" - echo "\$Id: $id \$" - echo "\$Id: $id \$" - echo "\$Id: $id \$" - echo "\$Id: NoTerminatingSymbol" - echo "\$Id: Foreign Commit With Spaces \$" - } >expected-output.0 && + cat >expected-output.0 <<-EOF && + File with expanded keywords + \$Id: $id \$ + \$Id: $id \$ + \$Id: $id \$ + \$Id: $id \$ + \$Id: $id \$ + \$Id: $id \$ + \$Id: NoTerminatingSymbol + \$Id: Foreign Commit With Spaces \$ + EOF { cat expected-output.0 && printf "\$Id: NoTerminatingSymbolAtEOF" @@ -159,7 +156,7 @@ test_expect_success expanded_in_repo ' printf "\$Id: NoTerminatingSymbolAtEOF" } >expected-output-crlf && { - echo "expanded-keywords ident" + echo "expanded-keywords ident" && echo "expanded-keywords-crlf ident text eol=crlf" } >>.gitattributes && @@ -266,7 +263,7 @@ test_expect_success 'required filter with absent clean field' ' echo test >test.ac && test_must_fail git add test.ac 2>stderr && - test_i18ngrep "fatal: test.ac: clean filter .absentclean. failed" stderr + test_grep "fatal: test.ac: clean filter .absentclean. failed" stderr ' test_expect_success 'required filter with absent smudge field' ' @@ -279,13 +276,13 @@ test_expect_success 'required filter with absent smudge field' ' git add test.as && rm -f test.as && test_must_fail git checkout -- test.as 2>stderr && - test_i18ngrep "fatal: test.as: smudge filter absentsmudge failed" stderr + test_grep "fatal: test.as: smudge filter absentsmudge failed" stderr ' test_expect_success 'filtering large input to small output should use little memory' ' test_config filter.devnull.clean "cat >/dev/null" && test_config filter.devnull.required true && - for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB && + for i in $(test_seq 1 30); do printf "%1048576d" 1 || return 1; done >30MB && echo "30MB filter=devnull" >.gitattributes && GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB ' @@ -303,7 +300,7 @@ test_expect_success 'filter that does not read is fine' ' test_expect_success EXPENSIVE 'filter large file' ' test_config filter.largefile.smudge cat && test_config filter.largefile.clean cat && - for i in $(test_seq 1 2048); do printf "%1048576d" 1; done >2GB && + for i in $(test_seq 1 2048); do printf "%1048576d" 1 || return 1; done >2GB && echo "2GB filter=largefile" >.gitattributes && git add 2GB 2>err && test_must_be_empty err && @@ -365,8 +362,8 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' ' test_line_count = 0 count ' -test_expect_success PERL 'required process filter should filter data' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'required process filter should filter data' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo && @@ -450,8 +447,8 @@ test_expect_success PERL 'required process filter should filter data' ' ) ' -test_expect_success PERL 'required process filter should filter data for various subcommands' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'required process filter should filter data for various subcommands' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true && ( cd repo && @@ -561,9 +558,9 @@ test_expect_success PERL 'required process filter should filter data for various ) ' -test_expect_success PERL 'required process filter takes precedence' ' +test_expect_success 'required process filter takes precedence' ' test_config_global filter.protocol.clean false && - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" && + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo && @@ -587,8 +584,8 @@ test_expect_success PERL 'required process filter takes precedence' ' ) ' -test_expect_success PERL 'required process filter should be used only for "clean" operation only' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" && +test_expect_success 'required process filter should be used only for "clean" operation only' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean" && rm -rf repo && mkdir repo && ( @@ -622,8 +619,8 @@ test_expect_success PERL 'required process filter should be used only for "clean ) ' -test_expect_success PERL 'required process filter should process multiple packets' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'required process filter should process multiple packets' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo && @@ -643,7 +640,7 @@ test_expect_success PERL 'required process filter should process multiple packet for FILE in "$TEST_ROOT"/*.file do cp "$FILE" . && - rot13.sh <"$FILE" >"$FILE.rot13" + rot13.sh <"$FILE" >"$FILE.rot13" || return 1 done && echo "*.file filter=protocol" >.gitattributes && @@ -682,13 +679,13 @@ test_expect_success PERL 'required process filter should process multiple packet for FILE in *.file do - test_cmp_committed_rot13 "$TEST_ROOT/$FILE" $FILE + test_cmp_committed_rot13 "$TEST_ROOT/$FILE" $FILE || return 1 done ) ' -test_expect_success PERL 'required process filter with clean error should fail' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'required process filter with clean error should fail' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo && @@ -706,8 +703,8 @@ test_expect_success PERL 'required process filter with clean error should fail' ) ' -test_expect_success PERL 'process filter should restart after unexpected write failure' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'process filter should restart after unexpected write failure' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && rm -rf repo && mkdir repo && ( @@ -735,8 +732,8 @@ test_expect_success PERL 'process filter should restart after unexpected write f rm -f debug.log && git checkout --quiet --no-progress . 2>git-stderr.log && - grep "smudge write error at" git-stderr.log && - test_i18ngrep "error: external filter" git-stderr.log && + grep "smudge write error" git-stderr.log && + test_grep "error: external filter" git-stderr.log && cat >expected.log <<-EOF && START @@ -761,8 +758,8 @@ test_expect_success PERL 'process filter should restart after unexpected write f ) ' -test_expect_success PERL 'process filter should not be restarted if it signals an error' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'process filter should not be restarted if it signals an error' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && rm -rf repo && mkdir repo && ( @@ -804,8 +801,8 @@ test_expect_success PERL 'process filter should not be restarted if it signals a ) ' -test_expect_success PERL 'process filter abort stops processing of all further files' ' - test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && +test_expect_success 'process filter abort stops processing of all further files' ' + test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && rm -rf repo && mkdir repo && ( @@ -861,10 +858,10 @@ test_expect_success PERL 'invalid process filter must fail (and not hang!)' ' ) ' -test_expect_success PERL 'delayed checkout in process filter' ' - test_config_global filter.a.process "rot13-filter.pl a.log clean smudge delay" && +test_expect_success 'delayed checkout in process filter' ' + test_config_global filter.a.process "test-tool rot13-filter --log=a.log clean smudge delay" && test_config_global filter.a.required true && - test_config_global filter.b.process "rot13-filter.pl b.log clean smudge delay" && + test_config_global filter.b.process "test-tool rot13-filter --log=b.log clean smudge delay" && test_config_global filter.b.required true && rm -rf repo && @@ -940,8 +937,8 @@ test_expect_success PERL 'delayed checkout in process filter' ' ) ' -test_expect_success PERL 'missing file in delayed checkout' ' - test_config_global filter.bug.process "rot13-filter.pl bug.log clean smudge delay" && +test_expect_success 'missing file in delayed checkout' ' + test_config_global filter.bug.process "test-tool rot13-filter --log=bug.log clean smudge delay" && test_config_global filter.bug.required true && rm -rf repo && @@ -960,8 +957,8 @@ test_expect_success PERL 'missing file in delayed checkout' ' grep "error: .missing-delay\.a. was not filtered properly" git-stderr.log ' -test_expect_success PERL 'invalid file in delayed checkout' ' - test_config_global filter.bug.process "rot13-filter.pl bug.log clean smudge delay" && +test_expect_success 'invalid file in delayed checkout' ' + test_config_global filter.bug.process "test-tool rot13-filter --log=bug.log clean smudge delay" && test_config_global filter.bug.required true && rm -rf repo && @@ -990,10 +987,10 @@ do mode_prereq='UTF8_NFD_TO_NFC' ;; esac - test_expect_success PERL,SYMLINKS,$mode_prereq \ + test_expect_success SYMLINKS,$mode_prereq \ "delayed checkout with $mode-collision don't write to the wrong place" ' test_config_global filter.delay.process \ - "\"$TEST_ROOT/rot13-filter.pl\" --always-delay delayed.log clean smudge delay" && + "test-tool rot13-filter --always-delay --log=delayed.log clean smudge delay" && test_config_global filter.delay.required true && git init $mode-collision && @@ -1026,12 +1023,12 @@ do ' done -test_expect_success PERL,SYMLINKS,CASE_INSENSITIVE_FS \ +test_expect_success SYMLINKS,CASE_INSENSITIVE_FS \ "delayed checkout with submodule collision don't write to the wrong place" ' git init collision-with-submodule && ( cd collision-with-submodule && - git config filter.delay.process "\"$TEST_ROOT/rot13-filter.pl\" --always-delay delayed.log clean smudge delay" && + git config filter.delay.process "test-tool rot13-filter --always-delay --log=delayed.log clean smudge delay" && git config filter.delay.required true && # We need Git to treat the submodule "a" and the @@ -1062,11 +1059,11 @@ test_expect_success PERL,SYMLINKS,CASE_INSENSITIVE_FS \ ) ' -test_expect_success PERL 'setup for progress tests' ' +test_expect_success 'setup for progress tests' ' git init progress && ( cd progress && - git config filter.delay.process "rot13-filter.pl delay-progress.log clean smudge delay" && + git config filter.delay.process "test-tool rot13-filter --log=delay-progress.log clean smudge delay" && git config filter.delay.required true && echo "*.a filter=delay" >.gitattributes && @@ -1132,4 +1129,26 @@ do ' done +test_expect_success 'delayed checkout correctly reports the number of updated entries' ' + rm -rf repo && + git init repo && + ( + cd repo && + git config filter.delay.process "test-tool rot13-filter --log=delayed.log clean smudge delay" && + git config filter.delay.required true && + + echo "*.a filter=delay" >.gitattributes && + echo a >test-delay10.a && + echo a >test-delay11.a && + git add . && + git commit -m files && + + rm *.a && + git checkout . 2>err && + grep "IN: smudge test-delay10.a .* \\[DELAYED\\]" delayed.log && + grep "IN: smudge test-delay11.a .* \\[DELAYED\\]" delayed.log && + grep "Updated 2 paths from the index" err + ) +' + test_done |