diff options
Diffstat (limited to 't')
-rw-r--r-- | t/chainlint.sed | 67 | ||||
-rw-r--r-- | t/chainlint/here-doc.expect | 2 | ||||
-rw-r--r-- | t/chainlint/here-doc.test | 7 | ||||
-rw-r--r-- | t/chainlint/subshell-here-doc.expect | 1 | ||||
-rw-r--r-- | t/chainlint/subshell-here-doc.test | 4 | ||||
-rwxr-xr-x | t/check-non-portable-shell.pl | 3 | ||||
-rwxr-xr-x | t/lib-submodule-update.sh | 5 | ||||
-rw-r--r-- | t/t0019/parse_json.perl | 3 | ||||
-rwxr-xr-x | t/t0028-working-tree-encoding.sh | 6 | ||||
-rwxr-xr-x | t/t3401-rebase-and-am-rename.sh | 110 | ||||
-rwxr-xr-x | t/t3404-rebase-interactive.sh | 18 | ||||
-rwxr-xr-x | t/t4013-diff-various.sh | 2 | ||||
-rwxr-xr-x | t/t5310-pack-bitmaps.sh | 2 | ||||
-rwxr-xr-x | t/t5318-commit-graph.sh | 2 | ||||
-rwxr-xr-x | t/t5552-skipping-fetch-negotiator.sh | 12 | ||||
-rwxr-xr-x | t/t5562-http-backend-content-length.sh | 11 | ||||
-rwxr-xr-x | t/t5703-upload-pack-ref-in-want.sh | 4 | ||||
-rwxr-xr-x | t/t7400-submodule-basic.sh | 5 | ||||
-rw-r--r-- | t/test-lib.sh | 4 |
19 files changed, 208 insertions, 60 deletions
diff --git a/t/chainlint.sed b/t/chainlint.sed index 8544df38df..70df40e34b 100644 --- a/t/chainlint.sed +++ b/t/chainlint.sed @@ -94,14 +94,14 @@ # here-doc -- swallow it to avoid false hits within its body (but keep the # command to which it was attached) -/<<[ ]*[-\\']*[A-Za-z0-9_]/ { - s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</ +/<<[ ]*[-\\'"]*[A-Za-z0-9_]/ { + s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</ s/[ ]*<<// - :hereslurp + :hered N /^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ s/\n.*$// - bhereslurp + bhered } s/^<[^>]*>// s/\n.*$// @@ -131,9 +131,8 @@ b b :subshell -# bare "(" line? +# bare "(" line? -- stash for later printing /^[ ]*([ ]*$/ { - # stash for later printing h bnextline } @@ -150,7 +149,7 @@ s/.*\n// :slurp # incomplete line "...\" -/\\$/bincomplete +/\\$/bicmplte # multi-line quoted string "...\n..."? /"/bdqstring # multi-line quoted string '...\n...'? (but not contraction in string "it's") @@ -159,7 +158,7 @@ s/.*\n// } :folded # here-doc -- swallow it -/<<[ ]*[-\\']*[A-Za-z0-9_]/bheredoc +/<<[ ]*[-\\'"]*[A-Za-z0-9_]/bheredoc # comment or empty line -- discard since final non-comment, non-empty line # before closing ")", "done", "elsif", "else", or "fi" will need to be # re-visited to drop "suspect" marking since final line of those constructs @@ -172,7 +171,7 @@ s/.*\n// /"[^"]*#[^"]*"/!s/[ ]#.*$// } # one-liner "case ... esac" -/^[ ]*case[ ]*..*esac/bcheckchain +/^[ ]*case[ ]*..*esac/bchkchn # multi-line "case ... esac" /^[ ]*case[ ]..*[ ]in/bcase # multi-line "for ... done" or "while ... done" @@ -201,32 +200,32 @@ s/.*\n// /^[ ]*fi[ ]*[<>|]/bdone /^[ ]*fi[ ]*)/bdone # nested one-liner "(...) &&" -/^[ ]*(.*)[ ]*&&[ ]*$/bcheckchain +/^[ ]*(.*)[ ]*&&[ ]*$/bchkchn # nested one-liner "(...)" -/^[ ]*(.*)[ ]*$/bcheckchain +/^[ ]*(.*)[ ]*$/bchkchn # nested one-liner "(...) >x" (or "2>x" or "<x" or "|x") -/^[ ]*(.*)[ ]*[0-9]*[<>|]/bcheckchain +/^[ ]*(.*)[ ]*[0-9]*[<>|]/bchkchn # nested multi-line "(...\n...)" /^[ ]*(/bnest # multi-line "{...\n...}" /^[ ]*{/bblock # closing ")" on own line -- exit subshell -/^[ ]*)/bclosesolo +/^[ ]*)/bclssolo # "$((...))" -- arithmetic expansion; not closing ")" -/\$(([^)][^)]*))[^)]*$/bcheckchain +/\$(([^)][^)]*))[^)]*$/bchkchn # "$(...)" -- command substitution; not closing ")" -/\$([^)][^)]*)[^)]*$/bcheckchain +/\$([^)][^)]*)[^)]*$/bchkchn # multi-line "$(...\n...)" -- command substitution; treat as nested subshell /\$([^)]*$/bnest # "=(...)" -- Bash array assignment; not closing ")" -/=(/bcheckchain +/=(/bchkchn # closing "...) &&" /)[ ]*&&[ ]*$/bclose # closing "...)" /)[ ]*$/bclose # closing "...) >x" (or "2>x" or "<x" or "|x") /)[ ]*[<>|]/bclose -:checkchain +:chkchn # mark suspect if line uses ";" internally rather than "&&" (but not ";" in a # string and not ";;" in one-liner "case...esac") /;/{ @@ -245,7 +244,7 @@ n bslurp # found incomplete line "...\" -- slurp up next line -:incomplete +:icmplte N s/\\\n// bslurp @@ -281,13 +280,13 @@ bfolded # found here-doc -- swallow it to avoid false hits within its body (but keep # the command to which it was attached) :heredoc -s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</ +s/^\(.*\)<<[ ]*[-\\'"]*\([A-Za-z0-9_][A-Za-z0-9_]*\)['"]*/<\2>\1<</ s/[ ]*<<// -:hereslurpsub +:heredsub N /^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{ s/\n.*$// - bhereslurpsub + bheredsub } s/^<[^>]*>// s/\n.*$// @@ -317,43 +316,43 @@ x # is 'done' or 'fi' cuddled with ")" to close subshell? /done.*)/bclose /fi.*)/bclose -bcheckchain +bchkchn # found nested multi-line "(...\n...)" -- pass through untouched :nest x -:nestslurp +:nstslurp n # closing ")" on own line -- stop nested slurp -/^[ ]*)/bnestclose +/^[ ]*)/bnstclose # comment -- not closing ")" if in comment -/^[ ]*#/bnestcontinue +/^[ ]*#/bnstcnt # "$((...))" -- arithmetic expansion; not closing ")" -/\$(([^)][^)]*))[^)]*$/bnestcontinue +/\$(([^)][^)]*))[^)]*$/bnstcnt # "$(...)" -- command substitution; not closing ")" -/\$([^)][^)]*)[^)]*$/bnestcontinue +/\$([^)][^)]*)[^)]*$/bnstcnt # closing "...)" -- stop nested slurp -/)/bnestclose -:nestcontinue +/)/bnstclose +:nstcnt x -bnestslurp -:nestclose +bnstslurp +:nstclose s/^/>>/ # is it "))" which closes nested and parent subshells? /)[ ]*)/bslurp -bcheckchain +bchkchn # found multi-line "{...\n...}" block -- pass through untouched :block x n # closing "}" -- stop block slurp -/}/bcheckchain +/}/bchkchn bblock # found closing ")" on own line -- drop "suspect" from final line of subshell # since that line legitimately lacks "&&" and exit subshell loop -:closesolo +:clssolo x s/?!AMP?!// p diff --git a/t/chainlint/here-doc.expect b/t/chainlint/here-doc.expect index aff6568716..534b065e38 100644 --- a/t/chainlint/here-doc.expect +++ b/t/chainlint/here-doc.expect @@ -4,4 +4,6 @@ cat >foo && cat >bar && +cat >boo && + horticulture diff --git a/t/chainlint/here-doc.test b/t/chainlint/here-doc.test index f2bb14b693..ad4ce8afd9 100644 --- a/t/chainlint/here-doc.test +++ b/t/chainlint/here-doc.test @@ -21,6 +21,13 @@ boz woz FUMP +# LINT: swallow "quoted" here-doc +cat <<"zump" >boo && +snoz +boz +woz +zump + # LINT: swallow here-doc (EOF is last line of test) horticulture <<\EOF gomez diff --git a/t/chainlint/subshell-here-doc.expect b/t/chainlint/subshell-here-doc.expect index 7663ea7fc4..74723e7340 100644 --- a/t/chainlint/subshell-here-doc.expect +++ b/t/chainlint/subshell-here-doc.expect @@ -6,5 +6,6 @@ ( cat >bup && cat >bup2 && + cat >bup3 && meep >) diff --git a/t/chainlint/subshell-here-doc.test b/t/chainlint/subshell-here-doc.test index b6b5a9b33a..f6b3ba4214 100644 --- a/t/chainlint/subshell-here-doc.test +++ b/t/chainlint/subshell-here-doc.test @@ -31,5 +31,9 @@ glink FIZZ ARBITRARY2 + cat <<-"ARBITRARY3" >bup3 && + glink + FIZZ + ARBITRARY3 meep ) diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl index d5823f71d8..b45bdac688 100755 --- a/t/check-non-portable-shell.pl +++ b/t/check-non-portable-shell.pl @@ -41,6 +41,9 @@ while (<>) { /^\s*[^#]\s*which\s/ and err 'which is not portable (use type)'; /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)'; /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)'; + /\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)'; + /(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)'; + /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)'; /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index 5b56b23166..016391723c 100755 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -235,7 +235,7 @@ reset_work_tree_to_interested () { then mkdir -p submodule_update/.git/modules/sub1/modules && cp -r submodule_update_repo/.git/modules/sub1/modules/sub2 submodule_update/.git/modules/sub1/modules/sub2 - # core.worktree is unset for sub2 as it is not checked out + GIT_WORK_TREE=. git -C submodule_update/.git/modules/sub1/modules/sub2 config --unset core.worktree fi && # indicate we are interested in the submodule: git -C submodule_update config submodule.sub1.url "bogus" && @@ -709,8 +709,7 @@ test_submodule_recursing_with_args_common() { git branch -t remove_sub1 origin/remove_sub1 && $command remove_sub1 && test_superproject_content origin/remove_sub1 && - ! test -e sub1 && - test_must_fail git config -f .git/modules/sub1/config core.worktree + ! test -e sub1 ) ' # ... absorbing a .git directory along the way. diff --git a/t/t0019/parse_json.perl b/t/t0019/parse_json.perl index ca4e5bfa78..fea87fb81b 100644 --- a/t/t0019/parse_json.perl +++ b/t/t0019/parse_json.perl @@ -34,6 +34,9 @@ sub dump_item { } elsif (ref($value) eq 'HASH') { print "$label_in hash\n"; dump_hash($label_in, $value); + } elsif (ref $value) { + my $bool = $value ? 1 : 0; + print "$label_in $bool\n"; } elsif (defined $value) { print "$label_in $value\n"; } else { diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh index 12b8eb963a..7e87b5a200 100755 --- a/t/t0028-working-tree-encoding.sh +++ b/t/t0028-working-tree-encoding.sh @@ -203,7 +203,11 @@ test_expect_success 'error if encoding garbage is already in Git' ' test_i18ngrep "error: BOM is required" err.out ' -test_expect_success 'check roundtrip encoding' ' +test_lazy_prereq ICONV_SHIFT_JIS ' + iconv -f UTF-8 -t SHIFT-JIS </dev/null +' + +test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' ' test_when_finished "rm -f roundtrip.shift roundtrip.utf16" && test_when_finished "git reset --hard HEAD" && diff --git a/t/t3401-rebase-and-am-rename.sh b/t/t3401-rebase-and-am-rename.sh index 8f832957fc..e0b5111993 100755 --- a/t/t3401-rebase-and-am-rename.sh +++ b/t/t3401-rebase-and-am-rename.sh @@ -5,7 +5,7 @@ test_description='git rebase + directory rename tests' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-rebase.sh -test_expect_success 'setup testcase' ' +test_expect_success 'setup testcase where directory rename should be detected' ' test_create_repo dir-rename && ( cd dir-rename && @@ -102,4 +102,112 @@ test_expect_failure 'am: directory rename detected' ' ) ' +test_expect_success 'setup testcase where directory rename should NOT be detected' ' + test_create_repo no-dir-rename && + ( + cd no-dir-rename && + + mkdir x && + test_seq 1 10 >x/a && + test_seq 11 20 >x/b && + test_seq 21 30 >x/c && + echo original >project_info && + git add x project_info && + git commit -m "Initial" && + + git branch O && + git branch A && + git branch B && + + git checkout A && + echo v2 >project_info && + git add project_info && + git commit -m "Modify project_info" && + + git checkout B && + mkdir y && + git mv x/c y/c && + echo v1 >project_info && + git add project_info && + git commit -m "Rename x/c to y/c, modify project_info" + ) +' + +test_expect_success 'rebase --interactive: NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail env FAKE_LINES="1" git rebase --interactive A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'rebase (am): NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail git rebase A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'rebase --merge: NO directory rename' ' + test_when_finished "git -C no-dir-rename rebase --abort" && + ( + cd no-dir-rename && + + git checkout B^0 && + + set_fake_editor && + test_must_fail git rebase --merge A && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + +test_expect_success 'am: NO directory rename' ' + test_when_finished "git -C no-dir-rename am --abort" && + ( + cd no-dir-rename && + + git checkout A^0 && + + git format-patch -1 B && + + test_must_fail git am --3way 0001*.patch && + + git ls-files -s >out && + test_line_count = 6 out && + + test_path_is_file x/a && + test_path_is_file x/b && + test_path_is_missing x/c + ) +' + test_done diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 259c27233d..86bba5ed7c 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1426,9 +1426,21 @@ test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' ' test_expect_success 'valid author header after --root swap' ' rebase_setup_and_clean author-header no-conflict-branch && set_fake_editor && - FAKE_LINES="2 1" git rebase -i --root && - git cat-file commit HEAD^ >out && - grep "^author ..*> [0-9][0-9]* [-+][0-9][0-9][0-9][0-9]$" out + git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit && + git cat-file commit HEAD | grep ^author >expected && + FAKE_LINES="5 1" git rebase -i --root && + git cat-file commit HEAD^ | grep ^author >actual && + test_cmp expected actual +' + +test_expect_success 'valid author header when author contains single quote' ' + rebase_setup_and_clean author-header no-conflict-branch && + set_fake_editor && + git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit && + git cat-file commit HEAD | grep ^author >expected && + FAKE_LINES="2" git rebase -i HEAD~2 && + git cat-file commit HEAD | grep ^author >actual && + test_cmp expected actual ' test_done diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index f8d853595b..73f7038253 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -140,7 +140,7 @@ do expect="$TEST_DIRECTORY/t4013/diff.$test" actual="$pfx-diff.$test" - test_expect_success "git $cmd # magic is ${magic:-"(not used)"}" ' + test_expect_success "git $cmd # magic is ${magic:-(not used)}" ' { echo "$ git $cmd" case "$magic" in diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh index 557bd0d0c0..7bff7923f2 100755 --- a/t/t5310-pack-bitmaps.sh +++ b/t/t5310-pack-bitmaps.sh @@ -335,7 +335,7 @@ test_expect_success 'truncated bitmap fails gracefully' ' git rev-list --use-bitmap-index --count --all >expect && bitmap=$(ls .git/objects/pack/*.bitmap) && test_when_finished "rm -f $bitmap" && - head -c 512 <$bitmap >$bitmap.tmp && + test_copy_bytes 512 <$bitmap >$bitmap.tmp && mv -f $bitmap.tmp $bitmap && git rev-list --use-bitmap-index --count --all >actual 2>stderr && test_cmp expect actual && diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index 3c1ffad491..0c500f7ca2 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -134,7 +134,7 @@ test_expect_success 'Add one more commit' ' git branch commits/8 && ls $objdir/pack | grep idx >existing-idx && git repack && - ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx + ls $objdir/pack| grep idx | grep -v -f existing-idx >new-idx ' # Current graph structure: diff --git a/t/t5552-skipping-fetch-negotiator.sh b/t/t5552-skipping-fetch-negotiator.sh index 5ad5bece55..30857b84a8 100755 --- a/t/t5552-skipping-fetch-negotiator.sh +++ b/t/t5552-skipping-fetch-negotiator.sh @@ -46,7 +46,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc test_commit -C server to_fetch && git init client && - for i in $(seq 7) + for i in $(test_seq 7) do test_commit -C client c$i done && @@ -89,7 +89,7 @@ test_expect_success 'when two skips collide, favor the larger one' ' test_commit -C server to_fetch && git init client && - for i in $(seq 11) + for i in $(test_seq 11) do test_commit -C client c$i done && @@ -168,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC test_commit -C server to_fetch && git init client && - for i in $(seq 8) + for i in $(test_seq 8) do git -C client checkout --orphan b$i && test_commit -C client b$i.c0 done && - for j in $(seq 19) + for j in $(test_seq 19) do - for i in $(seq 8) + for i in $(test_seq 8) do git -C client checkout b$i && test_commit -C client b$i.c$j @@ -205,7 +205,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC # fetch-pack should thus not send any more commits in the b1 branch, but # should still send the others (in this test, just check b2). - for i in $(seq 0 8) + for i in $(test_seq 0 8) do have_not_sent b1.c$i done && diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index 43570ce120..f94d01f69e 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -153,4 +153,15 @@ test_expect_success 'CONTENT_LENGTH overflow ssite_t' ' grep "fatal:.*CONTENT_LENGTH" err ' +test_expect_success 'empty CONTENT_LENGTH' ' + env \ + QUERY_STRING=/repo.git/HEAD \ + PATH_TRANSLATED="$PWD"/.git/HEAD \ + GIT_HTTP_EXPORT_ALL=TRUE \ + REQUEST_METHOD=GET \ + CONTENT_LENGTH="" \ + git http-backend <empty_body >act.out 2>act.err && + verify_http_result "200 OK" +' + test_done diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index a73c55a47e..d1ccc22331 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' ' git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" && git checkout -b side && - for i in $(seq 1 33); do test_commit s$i; done && + for i in $(test_seq 1 33); do test_commit s$i; done && # Add novel commits to upstream git checkout master && @@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' ' git clone "file://$REPO" "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" && git checkout -b side && - for i in $(seq 1 33); do test_commit s$i; done && + for i in $(test_seq 1 33); do test_commit s$i; done && # Add novel commits to upstream git checkout master && diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 7d3d984210..c0ffc1022a 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -984,11 +984,6 @@ test_expect_success 'submodule deinit should remove the whole submodule section rmdir init ' -test_expect_success 'submodule deinit should unset core.worktree' ' - test_path_is_file .git/modules/example/config && - test_must_fail git config -f .git/modules/example/config core.worktree -' - test_expect_success 'submodule deinit from subdirectory' ' git submodule update --init && git config submodule.example.foo bar && diff --git a/t/test-lib.sh b/t/test-lib.sh index 8bb0f4348e..44288cbb59 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -867,7 +867,7 @@ then # handle only executables, unless they are shell libraries that # need to be in the exec-path. test -x "$1" || - test "# " = "$(head -c 2 <"$1")" || + test "# " = "$(test_copy_bytes 2 <"$1")" || return; base=$(basename "$1") @@ -882,7 +882,7 @@ then # do not override scripts if test -x "$symlink_target" && test ! -d "$symlink_target" && - test "#!" != "$(head -c 2 < "$symlink_target")" + test "#!" != "$(test_copy_bytes 2 <"$symlink_target")" then symlink_target=../valgrind.sh fi |