diff options
Diffstat (limited to 't')
39 files changed, 569 insertions, 155 deletions
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index 76d8b7b803..5a734b1b7b 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -25,6 +25,7 @@ our \$favicon = 'file:///$TEST_DIRECTORY/../gitweb/git-favicon.png'; our \$projects_list = ''; our \$export_ok = ''; our \$strict_export = ''; +our \$maxload = undef; EOF diff --git a/t/lib-patch-mode.sh b/t/lib-patch-mode.sh index 75a3ee283d..ce36f34d03 100755..100644 --- a/t/lib-patch-mode.sh +++ b/t/lib-patch-mode.sh @@ -1,3 +1,5 @@ +: included from t2016 and others + . ./test-lib.sh if ! test_have_prereq PERL; then diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index 4e72b53140..c3e7e322a8 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -4,21 +4,8 @@ test_description='CRLF conversion' . ./test-lib.sh -q_to_nul () { - perl -pe 'y/Q/\000/' -} - -q_to_cr () { - tr Q '\015' -} - -append_cr () { - sed -e 's/$/Q/' | tr Q '\015' -} - -remove_cr () { - tr '\015' Q <"$1" | grep Q >/dev/null && - tr '\015' Q <"$1" | sed -ne 's/Q$//p' +has_cr() { + tr '\015' Q <"$1" | grep Q >/dev/null } test_expect_success setup ' @@ -156,7 +143,7 @@ test_expect_success 'checkout with autocrlf=true' ' for f in one dir/two do - remove_cr "$f" >tmp && mv -f tmp $f && + remove_cr <"$f" >tmp && mv -f tmp $f && git update-index -- $f || { echo "Eh? $f" false @@ -180,7 +167,7 @@ test_expect_success 'checkout with autocrlf=input' ' for f in one dir/two do - if remove_cr "$f" >/dev/null + if has_cr "$f" then echo "Eh? $f" false @@ -245,7 +232,7 @@ test_expect_success 'apply patch (autocrlf=true)' ' git read-tree --reset -u HEAD && git apply patch.file && - test "$patched" = "`remove_cr one | git hash-object --stdin`" || { + test "$patched" = "`remove_cr <one | git hash-object --stdin`" || { echo "Eh? apply without index" false } @@ -272,7 +259,7 @@ test_expect_success 'apply patch --index (autocrlf=true)' ' git apply --index patch.file && test "$patched" = `git rev-parse :one` && - test "$patched" = "`remove_cr one | git hash-object --stdin`" || { + test "$patched" = "`remove_cr <one | git hash-object --stdin`" || { echo "Eh? apply with --index" false } @@ -285,7 +272,7 @@ test_expect_success '.gitattributes says two is binary' ' git config core.autocrlf true && git read-tree --reset -u HEAD && - if remove_cr dir/two >/dev/null + if has_cr dir/two then echo "Huh?" false @@ -293,7 +280,7 @@ test_expect_success '.gitattributes says two is binary' ' : happy fi && - if remove_cr one >/dev/null + if has_cr one then : happy else @@ -301,7 +288,7 @@ test_expect_success '.gitattributes says two is binary' ' false fi && - if remove_cr three >/dev/null + if has_cr three then echo "Huh?" false @@ -316,7 +303,7 @@ test_expect_success '.gitattributes says two is input' ' echo "two crlf=input" >.gitattributes && git read-tree --reset -u HEAD && - if remove_cr dir/two >/dev/null + if has_cr dir/two then echo "Huh?" false @@ -331,7 +318,7 @@ test_expect_success '.gitattributes says two and three are text' ' echo "t* crlf" >.gitattributes && git read-tree --reset -u HEAD && - if remove_cr dir/two >/dev/null + if has_cr dir/two then : happy else @@ -339,7 +326,7 @@ test_expect_success '.gitattributes says two and three are text' ' false fi && - if remove_cr three >/dev/null + if has_cr three then : happy else @@ -357,14 +344,14 @@ test_expect_success 'in-tree .gitattributes (1)' ' rm -rf tmp one dir .gitattributes patch.file three && git read-tree --reset -u HEAD && - if remove_cr one >/dev/null + if has_cr one then echo "Eh? one should not have CRLF" false else : happy fi && - remove_cr three >/dev/null || { + has_cr three || { echo "Eh? three should still have CRLF" false } @@ -376,14 +363,14 @@ test_expect_success 'in-tree .gitattributes (2)' ' git read-tree --reset HEAD && git checkout-index -f -q -u -a && - if remove_cr one >/dev/null + if has_cr one then echo "Eh? one should not have CRLF" false else : happy fi && - remove_cr three >/dev/null || { + has_cr three || { echo "Eh? three should still have CRLF" false } @@ -396,14 +383,14 @@ test_expect_success 'in-tree .gitattributes (3)' ' git checkout-index -u .gitattributes && git checkout-index -u one dir/two three && - if remove_cr one >/dev/null + if has_cr one then echo "Eh? one should not have CRLF" false else : happy fi && - remove_cr three >/dev/null || { + has_cr three || { echo "Eh? three should still have CRLF" false } @@ -416,14 +403,14 @@ test_expect_success 'in-tree .gitattributes (4)' ' git checkout-index -u one dir/two three && git checkout-index -u .gitattributes && - if remove_cr one >/dev/null + if has_cr one then echo "Eh? one should not have CRLF" false else : happy fi && - remove_cr three >/dev/null || { + has_cr three || { echo "Eh? three should still have CRLF" false } @@ -456,7 +443,7 @@ test_expect_success 'checkout when deleting .gitattributes' ' git checkout master~1 && git checkout master && - remove_cr .file2 >/dev/null + has_cr .file2 ' diff --git a/t/t0022-crlf-rename.sh b/t/t0022-crlf-rename.sh index f1e1d48869..7af3fbcc7b 100755 --- a/t/t0022-crlf-rename.sh +++ b/t/t0022-crlf-rename.sh @@ -12,7 +12,7 @@ test_expect_success setup ' test_tick && git commit -m Initial && - sed -e "s/\$/
/" "$TEST_DIRECTORY"/t0022-crlf-rename.sh >elpmas && + append_cr <"$TEST_DIRECTORY"/t0022-crlf-rename.sh >elpmas && git add elpmas && rm -f sample && diff --git a/t/t0101-at-syntax.sh b/t/t0101-at-syntax.sh new file mode 100755 index 0000000000..a1998b558f --- /dev/null +++ b/t/t0101-at-syntax.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +test_description='various @{whatever} syntax tests' +. ./test-lib.sh + +test_expect_success 'setup' ' + test_commit one && + test_commit two +' + +check_at() { + echo "$2" >expect && + git log -1 --format=%s "$1" >actual && + test_cmp expect actual +} + +test_expect_success '@{0} shows current' ' + check_at @{0} two +' + +test_expect_success '@{1} shows old' ' + check_at @{1} one +' + +test_expect_success '@{now} shows current' ' + check_at @{now} two +' + +test_expect_success '@{2001-09-17} (before the first commit) shows old' ' + check_at @{2001-09-17} one +' + +test_expect_success 'silly approxidates work' ' + check_at @{3.hot.dogs.on.2001-09-17} one +' + +test_expect_success 'notice misspelled upstream' ' + test_must_fail git log -1 --format=%s @{usptream} +' + +test_expect_success 'complain about total nonsense' ' + test_must_fail git log -1 --format=%s @{utter.bogosity} +' + +test_done diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index f89d7e9e49..f11f98c3ce 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -398,6 +398,17 @@ test_expect_success 'alternative GIT_CONFIG' 'cmp output expect' test_expect_success 'alternative GIT_CONFIG (--file)' \ 'git config --file other-config -l > output && cmp output expect' +test_expect_success 'refer config from subdirectory' ' + mkdir x && + ( + cd x && + echo strasse >expect + git config --get --file ../other-config ein.bahn >actual && + test_cmp expect actual + ) + +' + GIT_CONFIG=other-config git config anwohner.park ausweis cat > expect << EOF diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index a22632f483..49cae3ed52 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -66,12 +66,12 @@ tagger T A Gger <tagger@example.com> 1234567890 -0000 This is an invalid tag. EOF -test_expect_failure 'tag pointing to nonexistent' ' - tag=$(git hash-object -w --stdin < invalid-tag) && +test_expect_success 'tag pointing to nonexistent' ' + tag=$(git hash-object -t tag -w --stdin < invalid-tag) && echo $tag > .git/refs/tags/invalid && - git fsck --tags 2>out && + test_must_fail git fsck --tags >out && cat out && - grep "could not load tagged object" out && + grep "broken link" out && rm .git/refs/tags/invalid ' @@ -84,12 +84,12 @@ tagger T A Gger <tagger@example.com> 1234567890 -0000 This is an invalid tag. EOF -test_expect_failure 'tag pointing to something else than its type' ' - tag=$(git hash-object -w --stdin < wrong-tag) && +test_expect_success 'tag pointing to something else than its type' ' + tag=$(git hash-object -t tag -w --stdin < wrong-tag) && echo $tag > .git/refs/tags/wrong && - git fsck --tags 2>out && + test_must_fail git fsck --tags 2>out && cat out && - grep "some sane error message" out && + grep "error in tag.*broken links" out && rm .git/refs/tags/wrong ' diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh index 95c9b0923f..8c8dfdaf9f 100755 --- a/t/t1507-rev-parse-upstream.sh +++ b/t/t1507-rev-parse-upstream.sh @@ -107,4 +107,33 @@ test_expect_success 'checkout other@{u}' ' test_cmp expect actual ' +cat >expect <<EOF +commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5 +Reflog: master@{0} (C O Mitter <committer@example.com>) +Reflog message: branch: Created from HEAD +Author: A U Thor <author@example.com> +Date: Thu Apr 7 15:15:13 2005 -0700 + + 3 +EOF +test_expect_success 'log -g other@{u}' ' + git log -1 -g other@{u} >actual && + test_cmp expect actual +' + +cat >expect <<EOF +commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5 +Reflog: master@{Thu Apr 7 15:17:13 2005 -0700} (C O Mitter <committer@example.com>) +Reflog message: branch: Created from HEAD +Author: A U Thor <author@example.com> +Date: Thu Apr 7 15:15:13 2005 -0700 + + 3 +EOF + +test_expect_success 'log -g other@{u}@{now}' ' + git log -1 -g other@{u}@{now} >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh new file mode 100755 index 0000000000..d5d6244178 --- /dev/null +++ b/t/t1508-at-combinations.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +test_description='test various @{X} syntax combinations together' +. ./test-lib.sh + +check() { +test_expect_${3:-success} "$1 = $2" " + echo '$2' >expect && + git log -1 --format=%s '$1' >actual && + test_cmp expect actual +" +} +nonsense() { +test_expect_${2:-success} "$1 is nonsensical" " + test_must_fail git log -1 '$1' +" +} +fail() { + "$@" failure +} + +test_expect_success 'setup' ' + test_commit master-one && + test_commit master-two && + git checkout -b upstream-branch && + test_commit upstream-one && + test_commit upstream-two && + git checkout -b old-branch && + test_commit old-one && + test_commit old-two && + git checkout -b new-branch && + test_commit new-one && + test_commit new-two && + git config branch.old-branch.remote . && + git config branch.old-branch.merge refs/heads/master && + git config branch.new-branch.remote . && + git config branch.new-branch.merge refs/heads/upstream-branch +' + +check HEAD new-two +check "@{1}" new-one +check "@{-1}" old-two +check "@{-1}@{1}" old-one +check "@{u}" upstream-two +check "@{u}@{1}" upstream-one +check "@{-1}@{u}" master-two +check "@{-1}@{u}@{1}" master-one +nonsense "@{u}@{-1}" +nonsense "@{1}@{u}" + +test_done diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 4e6a44b623..4314ad2d66 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -134,10 +134,6 @@ test_expect_success 'rebase -q is quiet' ' test ! -s output.out ' -q_to_cr () { - tr Q '\015' -} - test_expect_success 'Rebase a commit that sprinkles CRs in' ' ( echo "One" diff --git a/t/t3408-rebase-multi-line.sh b/t/t3408-rebase-multi-line.sh index e12cd578e8..2062b858bb 100755 --- a/t/t3408-rebase-multi-line.sh +++ b/t/t3408-rebase-multi-line.sh @@ -32,8 +32,8 @@ test_expect_success rebase ' git checkout side && git rebase master && - git cat-file commit HEAD | sed -e "1,/^$/d" >actual && - git cat-file commit side@{1} | sed -e "1,/^$/d" >expect && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit side@{1} | sed -e "1,/^\$/d" >expect && test_cmp expect actual ' diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 76b1bb4545..0aaf0ad84b 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -271,4 +271,12 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' test "$status" != 0 ' +test_expect_success 'rm removes subdirectories recursively' ' + mkdir -p dir/subdir/subsubdir && + echo content >dir/subdir/subsubdir/file && + git add dir/subdir/subsubdir/file && + git rm -f dir/subdir/subsubdir/file && + ! test -d dir +' + test_done diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh index 5868052425..29103f65dc 100755 --- a/t/t3902-quoted.sh +++ b/t/t3902-quoted.sh @@ -25,7 +25,7 @@ for_each_name () { for name in \ Name "Name and a${LF}LF" "Name and an${HT}HT" "Name${DQ}" \ "$FN$HT$GN" "$FN$LF$GN" "$FN $GN" "$FN$GN" "$FN$DQ$GN" \ - "With SP in it" + "With SP in it" "$FN/file" do eval "$1" done @@ -33,6 +33,7 @@ for_each_name () { test_expect_success setup ' + mkdir "$FN" && for_each_name "echo initial >\"\$name\"" git add . && git commit -q -m Initial && @@ -54,6 +55,7 @@ With SP in it "\346\277\261\351\207\216\n\347\264\224" "\346\277\261\351\207\216 \347\264\224" "\346\277\261\351\207\216\"\347\264\224" +"\346\277\261\351\207\216/file" "\346\277\261\351\207\216\347\264\224" EOF @@ -67,6 +69,7 @@ With SP in it "濱野\n純" 濱野 純 "濱野\"純" +濱野/file 濱野純 EOF @@ -97,6 +100,13 @@ test_expect_success 'check fully quoted output from diff-tree' ' ' +test_expect_success 'check fully quoted output from ls-tree' ' + + git ls-tree --name-only -r HEAD >current && + test_cmp expect.quoted current + +' + test_expect_success 'setting core.quotepath' ' git config --bool core.quotepath false @@ -130,4 +140,11 @@ test_expect_success 'check fully quoted output from diff-tree' ' ' +test_expect_success 'check fully quoted output from ls-tree' ' + + git ls-tree --name-only -r HEAD >current && + test_cmp expect.raw current + +' + test_done diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 5514f74b30..476e5ec038 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -194,6 +194,15 @@ test_expect_success 'pop -q is quiet' ' test ! -s output.out ' +test_expect_success 'pop -q --index works and is quiet' ' + echo foo > file && + git add file && + git stash save --quiet && + git stash pop -q --index > output.out 2>&1 && + test foo = "$(git show :file)" && + test ! -s output.out +' + test_expect_success 'drop -q is quiet' ' git stash && git stash drop -q > output.out 2>&1 && diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh index f64aa48d24..bc46563afc 100755 --- a/t/t4012-diff-binary.sh +++ b/t/t4012-diff-binary.sh @@ -77,10 +77,6 @@ test_expect_success 'apply binary patch' \ tree1=`git write-tree` && test "$tree1" = "$tree0"' -q_to_nul() { - perl -pe 'y/Q/\000/' -} - nul_to_q() { perl -pe 'y/\000/Q/' } diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index 3bc1cccf88..f2a2aaa2b9 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -93,9 +93,9 @@ test_expect_success 'extra headers' ' git config --add format.headers "Cc: S. E. Cipient <scipient@example.com> " && git format-patch --stdout master..side > patch2 && - sed -e "/^$/q" patch2 > hdrs2 && - grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs2 && - grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs2 + sed -e "/^\$/q" patch2 > hdrs2 && + grep "^To: R. E. Cipient <rcipient@example.com>\$" hdrs2 && + grep "^Cc: S. E. Cipient <scipient@example.com>\$" hdrs2 ' @@ -104,9 +104,9 @@ test_expect_success 'extra headers without newlines' ' git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" && git config --add format.headers "Cc: S. E. Cipient <scipient@example.com>" && git format-patch --stdout master..side >patch3 && - sed -e "/^$/q" patch3 > hdrs3 && - grep "^To: R. E. Cipient <rcipient@example.com>$" hdrs3 && - grep "^Cc: S. E. Cipient <scipient@example.com>$" hdrs3 + sed -e "/^\$/q" patch3 > hdrs3 && + grep "^To: R. E. Cipient <rcipient@example.com>\$" hdrs3 && + grep "^Cc: S. E. Cipient <scipient@example.com>\$" hdrs3 ' @@ -115,32 +115,32 @@ test_expect_success 'extra headers with multiple To:s' ' git config --replace-all format.headers "To: R. E. Cipient <rcipient@example.com>" && git config --add format.headers "To: S. E. Cipient <scipient@example.com>" && git format-patch --stdout master..side > patch4 && - sed -e "/^$/q" patch4 > hdrs4 && - grep "^To: R. E. Cipient <rcipient@example.com>,$" hdrs4 && - grep "^ *S. E. Cipient <scipient@example.com>$" hdrs4 + sed -e "/^\$/q" patch4 > hdrs4 && + grep "^To: R. E. Cipient <rcipient@example.com>,\$" hdrs4 && + grep "^ *S. E. Cipient <scipient@example.com>\$" hdrs4 ' test_expect_success 'additional command line cc' ' git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" && - git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch5 && - grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch5 && - grep "^ *S. E. Cipient <scipient@example.com>$" patch5 + git format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch5 && + grep "^Cc: R. E. Cipient <rcipient@example.com>,\$" patch5 && + grep "^ *S. E. Cipient <scipient@example.com>\$" patch5 ' test_expect_success 'command line headers' ' git config --unset-all format.headers && - git format-patch --add-header="Cc: R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch6 && - grep "^Cc: R. E. Cipient <rcipient@example.com>$" patch6 + git format-patch --add-header="Cc: R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch6 && + grep "^Cc: R. E. Cipient <rcipient@example.com>\$" patch6 ' test_expect_success 'configuration headers and command line headers' ' git config --replace-all format.headers "Cc: R. E. Cipient <rcipient@example.com>" && - git format-patch --add-header="Cc: S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^$/q" >patch7 && - grep "^Cc: R. E. Cipient <rcipient@example.com>,$" patch7 && - grep "^ *S. E. Cipient <scipient@example.com>$" patch7 + git format-patch --add-header="Cc: S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\$/q" >patch7 && + grep "^Cc: R. E. Cipient <rcipient@example.com>,\$" patch7 && + grep "^ *S. E. Cipient <scipient@example.com>\$" patch7 ' test_expect_success 'multiple files' ' @@ -406,9 +406,9 @@ test_expect_success 'cover-letter inherits diff options' ' git mv file foo && git commit -m foo && git format-patch --cover-letter -1 && - ! grep "file => foo .* 0 *$" 0000-cover-letter.patch && + ! grep "file => foo .* 0 *\$" 0000-cover-letter.patch && git format-patch --cover-letter -1 -M && - grep "file => foo .* 0 *$" 0000-cover-letter.patch + grep "file => foo .* 0 *\$" 0000-cover-letter.patch ' @@ -425,7 +425,7 @@ EOF test_expect_success 'shortlog of cover-letter wraps overly-long onelines' ' git format-patch --cover-letter -2 && - sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output && + sed -e "1,/A U Thor/d" -e "/^\$/q" < 0000-cover-letter.patch > output && test_cmp expect output ' @@ -450,7 +450,7 @@ EOF test_expect_success 'format-patch respects -U' ' git format-patch -U4 -2 && - sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && test_cmp expect output ' @@ -471,7 +471,7 @@ EOF test_expect_success 'format-patch -p suppresses stat' ' git format-patch -p -2 && - sed -e "1,/^$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && + sed -e "1,/^\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output && test_cmp expect output ' diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 2cf7e01ac2..7584efa36b 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -76,7 +76,7 @@ test_expect_success 'check combined output (1)' ' verify_helper sidewithone ' -test_expect_failure 'check combined output (2)' ' +test_expect_success 'check combined output (2)' ' git show sidesansone -- >sidesansone && verify_helper sidesansone ' diff --git a/t/t4041-diff-submodule.sh b/t/t4041-diff-submodule.sh index 5bb4fed3f5..464305405a 100755 --- a/t/t4041-diff-submodule.sh +++ b/t/t4041-diff-submodule.sh @@ -191,6 +191,73 @@ EOF " commit_file sm1 && +test_expect_success 'submodule is up to date' " + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +EOF +" + +test_expect_success 'submodule contains untracked content' " + echo new > sm1/new-file && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head6-dirty: +EOF +" + +test_expect_success 'submodule contains untracked and modifed content' " + echo new > sm1/foo6 && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head6-dirty: +EOF +" + +test_expect_success 'submodule contains modifed content' " + rm -f sm1/new-file && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head6-dirty: +EOF +" + +(cd sm1; git commit -mchange foo6 >/dev/null) && +head8=$(cd sm1; git rev-parse --verify HEAD | cut -c1-7) && +test_expect_success 'submodule is modified' " + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head8: + > change +EOF +" + +test_expect_success 'modified submodule contains untracked content' " + echo new > sm1/new-file && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head8-dirty: + > change +EOF +" + +test_expect_success 'modified submodule contains untracked and modifed content' " + echo modification >> sm1/foo6 && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head8-dirty: + > change +EOF +" + +test_expect_success 'modified submodule contains modifed content' " + rm -f sm1/new-file && + git diff-index -p --submodule=log HEAD >actual && + diff actual - <<-EOF +Submodule sm1 $head6..$head8-dirty: + > change +EOF +" + rm -rf sm1 test_expect_success 'deleted submodule' " git diff-index -p --submodule=log HEAD >actual && diff --git a/t/t4125-apply-ws-fuzz.sh b/t/t4125-apply-ws-fuzz.sh index 3b471b641b..9671de7999 100755 --- a/t/t4125-apply-ws-fuzz.sh +++ b/t/t4125-apply-ws-fuzz.sh @@ -37,11 +37,11 @@ test_expect_success setup ' # patch-2 is the same as patch-1 but is based # on a version that already has whitespace fixed, # and does not introduce whitespace breakages. - sed -e "s/ $//" patch-1 >patch-2 && + sed -e "s/ \$//" patch-1 >patch-2 && # If all whitespace breakages are fixed the contents # should look like file-fixed - sed -e "s/ $//" file-1 >file-fixed + sed -e "s/ \$//" file-1 >file-fixed ' diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 8296605234..810b04b817 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -83,6 +83,12 @@ test_expect_success setup ' echo "X-Fake-Field: Line Three" && git format-patch --stdout first | sed -e "1d" } > patch1.eml && + { + echo "X-Fake-Field: Line One" && + echo "X-Fake-Field: Line Two" && + echo "X-Fake-Field: Line Three" && + git format-patch --stdout first | sed -e "1d" + } | append_cr >patch1-crlf.eml && sed -n -e "3,\$p" msg >file && git add file && test_tick && @@ -123,6 +129,15 @@ test_expect_success 'am applies patch e-mail not in a mbox' ' test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" ' +test_expect_success 'am applies patch e-mail not in a mbox with CRLF' ' + git checkout first && + git am patch1-crlf.eml && + ! test -d .git/rebase-apply && + test -z "$(git diff second)" && + test "$(git rev-parse second)" = "$(git rev-parse HEAD)" && + test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)" +' + GIT_AUTHOR_NAME="Another Thor" GIT_AUTHOR_EMAIL="a.thor@example.com" GIT_COMMITTER_NAME="Co M Miter" @@ -287,7 +302,7 @@ test_expect_success 'am --committer-date-is-author-date' ' git checkout first && test_tick && git am --committer-date-is-author-date patch1 && - git cat-file commit HEAD | sed -e "/^$/q" >head1 && + git cat-file commit HEAD | sed -e "/^\$/q" >head1 && at=$(sed -ne "/^author /s/.*> //p" head1) && ct=$(sed -ne "/^committer /s/.*> //p" head1) && test "$at" = "$ct" @@ -297,7 +312,7 @@ test_expect_success 'am without --committer-date-is-author-date' ' git checkout first && test_tick && git am patch1 && - git cat-file commit HEAD | sed -e "/^$/q" >head1 && + git cat-file commit HEAD | sed -e "/^\$/q" >head1 && at=$(sed -ne "/^author /s/.*> //p" head1) && ct=$(sed -ne "/^committer /s/.*> //p" head1) && test "$at" != "$ct" @@ -311,7 +326,7 @@ test_expect_success 'am --ignore-date' ' git checkout first && test_tick && git am --ignore-date patch1 && - git cat-file commit HEAD | sed -e "/^$/q" >head1 && + git cat-file commit HEAD | sed -e "/^\$/q" >head1 && at=$(sed -ne "/^author /s/.*> //p" head1) && echo "$at" | grep "+0000" ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 779a5adf55..1dc224f6fb 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -255,7 +255,7 @@ EOF test_expect_success 'log --graph with merge' ' git log --graph --date-order --pretty=tformat:%s | - sed "s/ *$//" >actual && + sed "s/ *\$//" >actual && test_cmp expect actual ' @@ -315,7 +315,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | git name-rev --name-only --stdin | - sed "s/Merge:.*/Merge: A B/;s/ *$//" >actual && + sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' @@ -383,7 +383,7 @@ EOF test_expect_success 'log --graph with merge' ' git log --graph --date-order --pretty=tformat:%s | - sed "s/ *$//" >actual && + sed "s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index 0037f63d91..27bfba55bd 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -189,6 +189,16 @@ test_expect_success 'git archive --format=zip with --output' \ 'git archive --format=zip --output=d2.zip HEAD && test_cmp d.zip d2.zip' +test_expect_success 'git archive with --output, inferring format' ' + git archive --output=d3.zip HEAD && + test_cmp d.zip d3.zip +' + +test_expect_success 'git archive with --output, override inferred format' ' + git archive --format=tar --output=d4.zip HEAD && + test_cmp b.tar d4.zip +' + $UNZIP -v >/dev/null 2>&1 if [ $? -eq 127 ]; then say "Skipping ZIP tests, because unzip was not found" diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh index e2aa254eae..7649b810b1 100755 --- a/t/t5300-pack-object.sh +++ b/t/t5300-pack-object.sh @@ -16,7 +16,9 @@ test_expect_success \ perl -e "print \"a\" x 4096;" > a && perl -e "print \"b\" x 4096;" > b && perl -e "print \"c\" x 4096;" > c && - git update-index --add a b c && + test-genrandom "seed a" 2097152 > a_big && + test-genrandom "seed b" 2097152 > b_big && + git update-index --add a a_big b b_big c && cat c >d && echo foo >>d && git update-index --add d && tree=`git write-tree` && commit=`git commit-tree $tree </dev/null` && { @@ -280,26 +282,8 @@ test_expect_success \ :' -test_expect_success \ - 'fake a SHA1 hash collision' \ - 'test -f .git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67 && - cp -f .git/objects/9d/235ed07cd19811a6ceb342de82f190e49c9f68 \ - .git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67' - -test_expect_success \ - 'make sure index-pack detects the SHA1 collision' \ - 'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg && - grep "SHA1 COLLISION FOUND" msg' - -test_expect_success \ - 'honor pack.packSizeLimit' \ - 'git config pack.packSizeLimit 200 && - packname_4=$(git pack-objects test-4 <obj-list) && - test 3 = $(ls test-4-*.pack | wc -l)' - test_expect_success 'unpacking with --strict' ' - git config --unset pack.packsizelimit && for j in a b c d e f g do for i in 0 1 2 3 4 5 6 7 8 9 @@ -392,10 +376,42 @@ test_expect_success 'index-pack with --strict' ' ) ' -test_expect_success 'tolerate absurdly small packsizelimit' ' - git config pack.packSizeLimit 2 && - packname_9=$(git pack-objects test-9 <obj-list) && - test $(wc -l <obj-list) = $(ls test-9-*.pack | wc -l) +test_expect_success 'honor pack.packSizeLimit' ' + git config pack.packSizeLimit 3m && + packname_10=$(git pack-objects test-10 <obj-list) && + test 2 = $(ls test-10-*.pack | wc -l) +' + +test_expect_success 'verify resulting packs' ' + git verify-pack test-10-*.pack +' + +test_expect_success 'tolerate packsizelimit smaller than biggest object' ' + git config pack.packSizeLimit 1 && + packname_11=$(git pack-objects test-11 <obj-list) && + test 5 = $(ls test-11-*.pack | wc -l) ' +test_expect_success 'verify resulting packs' ' + git verify-pack test-11-*.pack +' + +# +# WARNING! +# +# The following test is destructive. Please keep the next +# two tests at the end of this file. +# + +test_expect_success \ + 'fake a SHA1 hash collision' \ + 'test -f .git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67 && + cp -f .git/objects/9d/235ed07cd19811a6ceb342de82f190e49c9f68 \ + .git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67' + +test_expect_success \ + 'make sure index-pack detects the SHA1 collision' \ + 'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg && + grep "SHA1 COLLISION FOUND" msg' + test_done diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh index 83a8e14c6c..53f54a2789 100755 --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@ -105,10 +105,8 @@ test_expect_success 'non-fast-forward push show ref status' ' ' test_expect_success 'non-fast-forward push shows help message' ' - grep \ -"To prevent you from losing history, non-fast-forward updates were rejected -Merge the remote changes before pushing again. See the '"'non-fast-forward'"' -section of '"'git push --help'"' for details." output + grep "To prevent you from losing history, non-fast-forward updates were rejected" \ + output ' test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper' ' @@ -126,10 +124,8 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output && grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output && - grep \ -"To prevent you from losing history, non-fast-forward updates were rejected -Merge the remote changes before pushing again. See the '"'non-fast-forward'"' -section of '"'git push --help'"' for details." output + grep "To prevent you from losing history, non-fast-forward updates were rejected" \ + output ' stop_httpd diff --git a/t/t5705-clone-2gb.sh b/t/t5705-clone-2gb.sh index 9f52154cac..adfaae8c5b 100755 --- a/t/t5705-clone-2gb.sh +++ b/t/t5705-clone-2gb.sh @@ -31,7 +31,7 @@ test_expect_success 'setup' ' echo "data 5" && echo ">2gb" && cat commit) | - git fast-import && + git fast-import --big-file-threshold=2 && test ! -f exit-status ' diff --git a/t/t6000lib.sh b/t/t6000lib.sh index f55627b641..985d517a1c 100755..100644 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -1,3 +1,5 @@ +: included from 6002 and others + [ -d .git/refs/tags ] || mkdir -p .git/refs/tags :> sed.script diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh index 7dcf391914..6291307cd0 100755 --- a/t/t6023-merge-file.sh +++ b/t/t6023-merge-file.sh @@ -146,8 +146,8 @@ test_expect_success 'binary files cannot be merged' ' grep "Cannot merge binary files" merge.err ' -sed -e "s/deerit.$/deerit;/" -e "s/me;$/me./" < new5.txt > new6.txt -sed -e "s/deerit.$/deerit,/" -e "s/me;$/me,/" < new5.txt > new7.txt +sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt > new6.txt +sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt > new7.txt test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' ' diff --git a/t/t6033-merge-crlf.sh b/t/t6033-merge-crlf.sh index 75d9602de4..e8d65eefb5 100755 --- a/t/t6033-merge-crlf.sh +++ b/t/t6033-merge-crlf.sh @@ -1,13 +1,5 @@ #!/bin/sh -append_cr () { - sed -e 's/$/Q/' | tr Q '\015' -} - -remove_cr () { - tr '\015' Q | sed -e 's/Q$//' -} - test_description='merge conflict in crlf repo b---M diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh index d1b22871c4..3202e1de6d 100755 --- a/t/t6035-merge-dir-to-symlink.sh +++ b/t/t6035-merge-dir-to-symlink.sh @@ -48,7 +48,7 @@ test_expect_success 'setup for merge test' ' git tag baseline ' -test_expect_failure 'do not lose a/b-2/c/d in merge (resolve)' ' +test_expect_success 'do not lose a/b-2/c/d in merge (resolve)' ' git reset --hard && git checkout baseline^0 && git merge -s resolve master && diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh index 7eceb086be..ebae1522c8 100755 --- a/t/t7002-grep.sh +++ b/t/t7002-grep.sh @@ -291,6 +291,14 @@ y:y yy z:zzz EOF +test_expect_success 'grep -q, silently report matches' ' + >empty && + git grep -q mmap >actual && + test_cmp empty actual && + test_must_fail git grep -q qfwfq >actual && + test_cmp empty actual +' + # Create 1024 file names that sort between "y" and "z" to make sure # the two files are handled by different calls to an external grep. # This depends on MAXARGS in builtin-grep.c being 1024 or less. @@ -478,4 +486,37 @@ test_expect_success 'inside git repository but with --no-index' ' ) ' +test_expect_success 'setup double-dash tests' ' +cat >double-dash <<EOF && +-- +-> +other +EOF +git add double-dash +' + +cat >expected <<EOF +double-dash:-> +EOF +test_expect_success 'grep -- pattern' ' + git grep -- "->" >actual && + test_cmp expected actual +' +test_expect_success 'grep -- pattern -- pathspec' ' + git grep -- "->" -- double-dash >actual && + test_cmp expected actual +' +test_expect_success 'grep -e pattern -- path' ' + git grep -e "->" -- double-dash >actual && + test_cmp expected actual +' + +cat >expected <<EOF +double-dash:-- +EOF +test_expect_success 'grep -e -- -- path' ' + git grep -e -- -- double-dash >actual && + test_cmp expected actual +' + test_done diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 9503875e97..0da13a8d6b 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -306,4 +306,43 @@ test_expect_success '--remap-to-ancestor with filename filters' ' test $orig_invariant = $(git rev-parse invariant) ' +test_expect_success 'setup submodule' ' + rm -fr ?* .git && + git init && + test_commit file && + mkdir submod && + submodurl="$PWD/submod" && + ( cd submod && + git init && + test_commit file-in-submod ) && + git submodule add "$submodurl" && + git commit -m "added submodule" && + test_commit add-file && + ( cd submod && test_commit add-in-submodule ) && + git add submod && + git commit -m "changed submodule" && + git branch original HEAD +' + +orig_head=`git show-ref --hash --head HEAD` + +test_expect_success 'rewrite submodule with another content' ' + git filter-branch --tree-filter "test -d submod && { + rm -rf submod && + git rm -rf --quiet submod && + mkdir submod && + : > submod/file + } || :" HEAD && + test $orig_head != `git show-ref --hash --head HEAD` +' + +test_expect_success 'replace submodule revision' ' + git reset --hard original && + git filter-branch -f --tree-filter \ + "if git ls-files --error-unmatch -- submod > /dev/null 2>&1 + then git update-index --cacheinfo 160000 0123456789012345678901234567890123456789 submod + fi" HEAD && + test $orig_head != `git show-ref --hash --head HEAD` +' + test_done diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh index 8eec0fa9bc..9f5c3edb03 100755 --- a/t/t7500-commit.sh +++ b/t/t7500-commit.sh @@ -150,7 +150,7 @@ EOF test_expect_success '--signoff' ' echo "yet another content *narf*" >> foo && echo "zort" | git commit -s -F - foo && - git cat-file commit HEAD | sed "1,/^$/d" > output && + git cat-file commit HEAD | sed "1,/^\$/d" > output && test_cmp expect output ' diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh index ad834f200a..3bbddd03cb 100755 --- a/t/t8003-blame.sh +++ b/t/t8003-blame.sh @@ -157,4 +157,14 @@ EOF git --no-pager blame $COMMIT -- uno >/dev/null ' +test_expect_success 'blame -L with invalid start' ' + test_must_fail git blame -L5 tres 2>errors && + grep "has only 2 lines" errors +' + +test_expect_success 'blame -L with invalid end' ' + test_must_fail git blame -L1,5 tres 2>errors && + grep "has only 2 lines" errors +' + test_done diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 752adaac85..c09f375288 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -186,8 +186,8 @@ test_expect_success 'Prompting works' ' --smtp-server="$(pwd)/fake.sendmail" \ $patches \ 2>errors && - grep "^From: Example <from@example.com>$" msgtxt1 && - grep "^To: to@example.com$" msgtxt1 + grep "^From: Example <from@example.com>\$" msgtxt1 && + grep "^To: to@example.com\$" msgtxt1 ' test_expect_success 'cccmd works' ' @@ -236,7 +236,7 @@ test_expect_success 'Author From: in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 grep "From: A <author@example.com>" msgbody1 ' @@ -247,7 +247,7 @@ test_expect_success 'Author From: not in message body' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ $patches && - sed "1,/^$/d" < msgtxt1 > msgbody1 + sed "1,/^\$/d" < msgtxt1 > msgbody1 ! grep "From: A <author@example.com>" msgbody1 ' diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 60d6f5d1ba..131f032988 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1536,4 +1536,50 @@ test_expect_success 'R: ignore non-git options' ' git fast-import <input ' +## +## R: very large blobs +## +blobsize=$((2*1024*1024 + 53)) +test-genrandom bar $blobsize >expect +cat >input <<INPUT_END +commit refs/heads/big-file +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE +data <<COMMIT +R - big file +COMMIT + +M 644 inline big1 +data $blobsize +INPUT_END +cat expect >>input +cat >>input <<INPUT_END +M 644 inline big2 +data $blobsize +INPUT_END +cat expect >>input +echo >>input + +test_expect_success \ + 'R: blob bigger than threshold' \ + 'test_create_repo R && + git --git-dir=R/.git fast-import --big-file-threshold=1 <input' +test_expect_success \ + 'R: verify created pack' \ + ': >verify && + for p in R/.git/objects/pack/*.pack; + do + git verify-pack -v $p >>verify || exit; + done' +test_expect_success \ + 'R: verify written objects' \ + 'git --git-dir=R/.git cat-file blob big-file:big1 >actual && + test_cmp expect actual && + a=$(git --git-dir=R/.git rev-parse big-file:big1) && + b=$(git --git-dir=R/.git rev-parse big-file:big2) && + test $a = $b' +test_expect_success \ + 'R: blob appears only once' \ + 'n=$(grep $a verify | wc -l) && + test 1 = $n' + test_done diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index c2ec3cb4bd..4327eb8baa 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -96,7 +96,7 @@ EOF test_expect_success 'pserver authentication' \ 'cat request-anonymous | git-cvsserver pserver >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'pserver authentication failure (non-anonymous user)' \ 'if cat request-git | git-cvsserver pserver >log 2>&1 @@ -105,11 +105,11 @@ test_expect_success 'pserver authentication failure (non-anonymous user)' \ else true fi && - sed -ne \$p log | grep "^I HATE YOU$"' + sed -ne \$p log | grep "^I HATE YOU\$"' test_expect_success 'pserver authentication (login)' \ 'cat login-anonymous | git-cvsserver pserver >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'pserver authentication failure (login/non-anonymous user)' \ 'if cat login-git | git-cvsserver pserver >log 2>&1 @@ -118,7 +118,7 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)' else true fi && - sed -ne \$p log | grep "^I HATE YOU$"' + sed -ne \$p log | grep "^I HATE YOU\$"' # misuse pserver authentication for testing of req_Root @@ -156,7 +156,7 @@ test_expect_success 'req_Root failure (conflicting roots)' \ test_expect_success 'req_Root (strict paths)' \ 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'req_Root failure (strict-paths)' ' ! cat request-anonymous | @@ -165,7 +165,7 @@ test_expect_success 'req_Root failure (strict-paths)' ' test_expect_success 'req_Root (w/o strict-paths)' \ 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'req_Root failure (w/o strict-paths)' ' ! cat request-anonymous | @@ -183,7 +183,7 @@ EOF test_expect_success 'req_Root (base-path)' \ 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'req_Root failure (base-path)' ' ! cat request-anonymous | @@ -194,14 +194,14 @@ GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 test_expect_success 'req_Root (export-all)' \ 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' test_expect_success 'req_Root failure (export-all w/o whitelist)' \ '! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)' test_expect_success 'req_Root (everything together)' \ 'cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && - sed -ne \$p log | grep "^I LOVE YOU$"' + sed -ne \$p log | grep "^I LOVE YOU\$"' GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh index 40637d6782..ed7b513f3e 100755 --- a/t/t9401-git-cvsserver-crlf.sh +++ b/t/t9401-git-cvsserver-crlf.sh @@ -11,14 +11,6 @@ repository using cvs CLI client via git-cvsserver server' . ./test-lib.sh -q_to_nul () { - perl -pe 'y/Q/\000/' -} - -q_to_cr () { - tr Q '\015' -} - marked_as () { foundEntry="$(grep "^/$2/" "$1/CVS/Entries")" if [ x"$foundEntry" = x"" ] ; then diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh index 0688a57e1d..d196cc5ca9 100755 --- a/t/t9501-gitweb-standalone-http-status.sh +++ b/t/t9501-gitweb-standalone-http-status.sh @@ -33,7 +33,6 @@ test_expect_success \ grep "403 - Snapshot format not allowed" gitweb.output && gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" && grep "403 - Unsupported snapshot format" gitweb.output' -test_debug 'cat gitweb.output' cat >>gitweb_config.perl <<\EOF @@ -50,7 +49,6 @@ test_expect_success \ grep "403 - Snapshot format not allowed" gitweb.output && gitweb_run "p=.git;a=snapshot;h=HEAD;sf=zip" && grep "Status: 200 OK" gitweb.output' -test_debug 'cat gitweb.output' cat >>gitweb_config.perl <<\EOF @@ -72,7 +70,7 @@ test_expect_success \ 'snapshots: tgz explicitly enabled' \ 'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" && grep "Status: 200 OK" gitweb.output' -test_debug 'cat gitweb.output' +test_debug 'cat gitweb.headers' # ---------------------------------------------------------------------- @@ -82,7 +80,7 @@ test_expect_success 'snapshots: good tree-ish id' ' gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && grep "Status: 200 OK" gitweb.output ' -test_debug 'cat gitweb.output' +test_debug 'cat gitweb.headers' test_expect_success 'snapshots: bad tree-ish id' ' gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" && @@ -105,7 +103,7 @@ test_expect_success 'snapshots: good object id' ' gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" && grep "Status: 200 OK" gitweb.output ' -test_debug 'cat gitweb.output' +test_debug 'cat gitweb.headers' test_expect_success 'snapshots: bad object id' ' gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" && @@ -114,4 +112,26 @@ test_expect_success 'snapshots: bad object id' ' test_debug 'cat gitweb.output' +# ---------------------------------------------------------------------- +# load checking + +# always hit the load limit +cat >>gitweb_config.perl <<\EOF +our $maxload = -1; +EOF + +test_expect_success 'load checking: load too high (default action)' ' + gitweb_run "p=.git" && + grep "Status: 503 Service Unavailable" gitweb.headers && + grep "503 - The load average on the server is too high" gitweb.body +' +test_debug 'cat gitweb.log' # just in case +test_debug 'cat gitweb.headers' + +# turn off load checking +cat >>gitweb_config.perl <<\EOF +our $maxload = undef; +EOF + + test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index baa4093073..afd3053f96 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -230,6 +230,22 @@ test_decode_color () { -e 's/.\[m/<RESET>/g' } +q_to_nul () { + perl -pe 'y/Q/\000/' +} + +q_to_cr () { + tr Q '\015' +} + +append_cr () { + sed -e 's/$/Q/' | tr Q '\015' +} + +remove_cr () { + tr '\015' Q | sed -e 's/Q$//' +} + test_tick () { if test -z "${test_tick+set}" then |