diff options
Diffstat (limited to 't')
-rw-r--r-- | t/helper/test-sha1-array.c | 3 | ||||
-rwxr-xr-x | t/t0001-init.sh | 17 | ||||
-rwxr-xr-x | t/t1007-hash-object.sh | 25 | ||||
-rwxr-xr-x | t/t1450-fsck.sh | 16 | ||||
-rwxr-xr-x | t/t1512-rev-parse-disambiguation.sh | 70 | ||||
-rwxr-xr-x | t/t4150-am.sh | 23 | ||||
-rwxr-xr-x | t/t5100-mailinfo.sh | 84 | ||||
-rw-r--r-- | t/t5100/comment.expect | 5 | ||||
-rw-r--r-- | t/t5100/comment.in | 9 | ||||
-rw-r--r-- | t/t5100/info0018 | 5 | ||||
-rw-r--r-- | t/t5100/info0018--no-inbody-headers | 5 | ||||
-rw-r--r-- | t/t5100/msg0015 | 2 | ||||
-rw-r--r-- | t/t5100/msg0018 | 2 | ||||
-rw-r--r-- | t/t5100/msg0018--no-inbody-headers | 8 | ||||
-rw-r--r-- | t/t5100/patch0018 | 6 | ||||
-rw-r--r-- | t/t5100/patch0018--no-inbody-headers | 6 | ||||
-rw-r--r-- | t/t5100/quoted-string.expect | 5 | ||||
-rw-r--r-- | t/t5100/quoted-string.in | 9 | ||||
-rw-r--r-- | t/t5100/sample.mbox | 19 | ||||
-rwxr-xr-x | t/t6006-rev-list-format.sh | 2 | ||||
-rwxr-xr-x | t/t6101-rev-parse-parents.sh | 94 | ||||
-rwxr-xr-x | t/t9500-gitweb-standalone-no-errors.sh | 8 |
22 files changed, 381 insertions, 42 deletions
diff --git a/t/helper/test-sha1-array.c b/t/helper/test-sha1-array.c index 09f7790971..f7a53c4ad6 100644 --- a/t/helper/test-sha1-array.c +++ b/t/helper/test-sha1-array.c @@ -1,9 +1,10 @@ #include "cache.h" #include "sha1-array.h" -static void print_sha1(const unsigned char sha1[20], void *data) +static int print_sha1(const unsigned char sha1[20], void *data) { puts(sha1_to_hex(sha1)); + return 0; } int cmd_main(int argc, const char **argv) diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 8ffbbea4d6..b8fc588b19 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -393,4 +393,21 @@ test_expect_success 'remote init from does not use config from cwd' ' test_cmp expect actual ' +test_expect_success 're-init from a linked worktree' ' + git init main-worktree && + ( + cd main-worktree && + test_commit first && + git worktree add ../linked-worktree && + mv .git/info/exclude expected-exclude && + cp .git/config expected-config && + find .git/worktrees -print | sort >expected && + git -C ../linked-worktree init && + test_cmp expected-exclude .git/info/exclude && + test_cmp expected-config .git/config && + find .git/worktrees -print | sort >actual && + test_cmp expected actual + ) +' + test_done diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index acca9ac562..c5245c5cb4 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -183,9 +183,30 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do pop_repo done -test_expect_success 'corrupt tree' ' +test_expect_success 'too-short tree' ' echo abc >malformed-tree && - test_must_fail git hash-object -t tree malformed-tree + test_must_fail git hash-object -t tree malformed-tree 2>err && + test_i18ngrep "too-short tree object" err +' + +hex2oct() { + perl -ne 'printf "\\%03o", hex for /../g' +} + +test_expect_success 'malformed mode in tree' ' + hex_sha1=$(echo foo | git hash-object --stdin -w) && + bin_sha1=$(echo $hex_sha1 | hex2oct) && + printf "9100644 \0$bin_sha1" >tree-with-malformed-mode && + test_must_fail git hash-object -t tree tree-with-malformed-mode 2>err && + test_i18ngrep "malformed mode in tree entry" err +' + +test_expect_success 'empty filename in tree' ' + hex_sha1=$(echo foo | git hash-object --stdin -w) && + bin_sha1=$(echo $hex_sha1 | hex2oct) && + printf "100644 \0$bin_sha1" >tree-with-empty-filename && + test_must_fail git hash-object -t tree tree-with-empty-filename 2>err && + test_i18ngrep "empty filename in tree entry" err ' test_expect_success 'corrupt commit' ' diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 8f52da2771..ee7d4736db 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -188,8 +188,7 @@ test_expect_success 'commit with NUL in header' ' grep "error in commit $new.*unterminated header: NUL at offset" out ' -test_expect_success 'malformatted tree object' ' - test_when_finished "git update-ref -d refs/tags/wrong" && +test_expect_success 'tree object with duplicate entries' ' test_when_finished "remove_object \$T" && T=$( GIT_INDEX_FILE=test-index && @@ -208,6 +207,19 @@ test_expect_success 'malformatted tree object' ' grep "error in tree .*contains duplicate file entries" out ' +test_expect_success 'unparseable tree object' ' + test_when_finished "git update-ref -d refs/heads/wrong" && + test_when_finished "remove_object \$tree_sha1" && + test_when_finished "remove_object \$commit_sha1" && + tree_sha1=$(printf "100644 \0twenty-bytes-of-junk" | git hash-object -t tree --stdin -w --literally) && + commit_sha1=$(git commit-tree $tree_sha1) && + git update-ref refs/heads/wrong $commit_sha1 && + test_must_fail git fsck 2>out && + test_i18ngrep "error: empty filename in tree entry" out && + test_i18ngrep "$tree_sha1" out && + test_i18ngrep ! "fatal: empty filename in tree entry" out +' + test_expect_success 'tag pointing to nonexistent' ' cat >invalid-tag <<-\EOF && object ffffffffffffffffffffffffffffffffffffffff diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh index e221167cfb..7c659eb585 100755 --- a/t/t1512-rev-parse-disambiguation.sh +++ b/t/t1512-rev-parse-disambiguation.sh @@ -264,6 +264,13 @@ test_expect_success 'ambiguous commit-ish' ' test_must_fail git log 000000000... ' +# There are three objects with this prefix: a blob, a tree, and a tag. We know +# the blob will not pass as a treeish, but the tree and tag should (and thus +# cause an error). +test_expect_success 'ambiguous tags peel to treeish' ' + test_must_fail git rev-parse 0000000000f^{tree} +' + test_expect_success 'rev-parse --disambiguate' ' # The test creates 16 objects that share the prefix and two # commits created by commit-tree in earlier tests share a @@ -273,6 +280,13 @@ test_expect_success 'rev-parse --disambiguate' ' test "$(sed -e "s/^\(.........\).*/\1/" actual | sort -u)" = 000000000 ' +test_expect_success 'rev-parse --disambiguate drops duplicates' ' + git rev-parse --disambiguate=000000000 >expect && + git pack-objects .git/objects/pack/pack <expect && + git rev-parse --disambiguate=000000000 >actual && + test_cmp expect actual +' + test_expect_success 'ambiguous 40-hex ref' ' TREE=$(git mktree </dev/null) && REF=$(git rev-parse HEAD) && @@ -291,4 +305,60 @@ test_expect_success 'ambiguous short sha1 ref' ' grep "refname.*${REF}.*ambiguous" err ' +test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (raw)' ' + test_must_fail git rev-parse 00000 2>stderr && + grep "is ambiguous" stderr >errors && + test_line_count = 1 errors +' + +test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (treeish)' ' + test_must_fail git rev-parse 00000:foo 2>stderr && + grep "is ambiguous" stderr >errors && + test_line_count = 1 errors +' + +test_expect_success C_LOCALE_OUTPUT 'ambiguity errors are not repeated (peel)' ' + test_must_fail git rev-parse 00000^{commit} 2>stderr && + grep "is ambiguous" stderr >errors && + test_line_count = 1 errors +' + +test_expect_success C_LOCALE_OUTPUT 'ambiguity hints' ' + test_must_fail git rev-parse 000000000 2>stderr && + grep ^hint: stderr >hints && + # 16 candidates, plus one intro line + test_line_count = 17 hints +' + +test_expect_success C_LOCALE_OUTPUT 'ambiguity hints respect type' ' + test_must_fail git rev-parse 000000000^{commit} 2>stderr && + grep ^hint: stderr >hints && + # 5 commits, 1 tag (which is a commitish), plus intro line + test_line_count = 7 hints +' + +test_expect_success C_LOCALE_OUTPUT 'failed type-selector still shows hint' ' + # these two blobs share the same prefix "ee3d", but neither + # will pass for a commit + echo 851 | git hash-object --stdin -w && + echo 872 | git hash-object --stdin -w && + test_must_fail git rev-parse ee3d^{commit} 2>stderr && + grep ^hint: stderr >hints && + test_line_count = 3 hints +' + +test_expect_success 'core.disambiguate config can prefer types' ' + # ambiguous between tree and tag + sha1=0000000000f && + test_must_fail git rev-parse $sha1 && + git rev-parse $sha1^{commit} && + git -c core.disambiguate=committish rev-parse $sha1 +' + +test_expect_success 'core.disambiguate does not override context' ' + # treeish ambiguous between tag and tree + test_must_fail \ + git -c core.disambiguate=committish rev-parse $sha1^{tree} +' + test_done diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 9ce9424d15..89a5bacac5 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -977,4 +977,27 @@ test_expect_success 'am --patch-format=mboxrd handles mboxrd' ' test_cmp msg out ' +test_expect_success 'am works with multi-line in-body headers' ' + FORTY="String that has a length of more than forty characters" && + LONG="$FORTY $FORTY" && + rm -fr .git/rebase-apply && + git checkout -f first && + echo one >> file && + git commit -am "$LONG" --author="$LONG <long@example.com>" && + git format-patch --stdout -1 >patch && + # bump from, date, and subject down to in-body header + perl -lpe " + if (/^From:/) { + print \"From: x <x\@example.com>\"; + print \"Date: Sat, 1 Jan 2000 00:00:00 +0000\"; + print \"Subject: x\n\"; + } + " patch >msg && + git checkout HEAD^ && + git am msg && + # Ensure that the author and full message are present + git cat-file commit HEAD | grep "^author.*long@example.com" && + git cat-file commit HEAD | grep "^$LONG" +' + test_done diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 1a5a546230..e6b995161e 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -7,37 +7,39 @@ test_description='git mailinfo and git mailsplit test' . ./test-lib.sh +DATA="$TEST_DIRECTORY/t5100" + test_expect_success 'split sample box' \ - 'git mailsplit -o. "$TEST_DIRECTORY"/t5100/sample.mbox >last && + 'git mailsplit -o. "$DATA/sample.mbox" >last && last=$(cat last) && echo total is $last && - test $(cat last) = 17' + test $(cat last) = 18' check_mailinfo () { mail=$1 opt=$2 mo="$mail$opt" - git mailinfo -u $opt msg$mo patch$mo <$mail >info$mo && - test_cmp "$TEST_DIRECTORY"/t5100/msg$mo msg$mo && - test_cmp "$TEST_DIRECTORY"/t5100/patch$mo patch$mo && - test_cmp "$TEST_DIRECTORY"/t5100/info$mo info$mo + git mailinfo -u $opt "msg$mo" "patch$mo" <"$mail" >"info$mo" && + test_cmp "$DATA/msg$mo" "msg$mo" && + test_cmp "$DATA/patch$mo" "patch$mo" && + test_cmp "$DATA/info$mo" "info$mo" } for mail in 00* do test_expect_success "mailinfo $mail" ' - check_mailinfo $mail "" && - if test -f "$TEST_DIRECTORY"/t5100/msg$mail--scissors + check_mailinfo "$mail" "" && + if test -f "$DATA/msg$mail--scissors" then - check_mailinfo $mail --scissors + check_mailinfo "$mail" --scissors fi && - if test -f "$TEST_DIRECTORY"/t5100/msg$mail--no-inbody-headers + if test -f "$DATA/msg$mail--no-inbody-headers" then - check_mailinfo $mail --no-inbody-headers + check_mailinfo "$mail" --no-inbody-headers fi && - if test -f "$TEST_DIRECTORY"/t5100/msg$mail--message-id + if test -f "$DATA/msg$mail--message-id" then - check_mailinfo $mail --message-id + check_mailinfo "$mail" --message-id fi ' done @@ -45,7 +47,7 @@ done test_expect_success 'split box with rfc2047 samples' \ 'mkdir rfc2047 && - git mailsplit -orfc2047 "$TEST_DIRECTORY"/t5100/rfc2047-samples.mbox \ + git mailsplit -orfc2047 "$DATA/rfc2047-samples.mbox" \ >rfc2047/last && last=$(cat rfc2047/last) && echo total is $last && @@ -54,20 +56,20 @@ test_expect_success 'split box with rfc2047 samples' \ for mail in rfc2047/00* do test_expect_success "mailinfo $mail" ' - git mailinfo -u $mail-msg $mail-patch <$mail >$mail-info && + git mailinfo -u "$mail-msg" "$mail-patch" <"$mail" >"$mail-info" && echo msg && - test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-msg && + test_cmp "$DATA/empty" "$mail-msg" && echo patch && - test_cmp "$TEST_DIRECTORY"/t5100/empty $mail-patch && + test_cmp "$DATA/empty" "$mail-patch" && echo info && - test_cmp "$TEST_DIRECTORY"/t5100/rfc2047-info-$(basename $mail) $mail-info + test_cmp "$DATA/rfc2047-info-$(basename $mail)" "$mail-info" ' done test_expect_success 'respect NULs' ' - git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain && - test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 && + git mailsplit -d3 -o. "$DATA/nul-plain" && + test_cmp "$DATA/nul-plain" 001 && (cat 001 | git mailinfo msg patch) && test_line_count = 4 patch @@ -75,52 +77,52 @@ test_expect_success 'respect NULs' ' test_expect_success 'Preserve NULs out of MIME encoded message' ' - git mailsplit -d5 -o. "$TEST_DIRECTORY"/t5100/nul-b64.in && - test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.in 00001 && + git mailsplit -d5 -o. "$DATA/nul-b64.in" && + test_cmp "$DATA/nul-b64.in" 00001 && git mailinfo msg patch <00001 && - test_cmp "$TEST_DIRECTORY"/t5100/nul-b64.expect patch + test_cmp "$DATA/nul-b64.expect" patch ' test_expect_success 'mailinfo on from header without name works' ' mkdir info-from && - git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in && - test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 && + git mailsplit -oinfo-from "$DATA/info-from.in" && + test_cmp "$DATA/info-from.in" info-from/0001 && git mailinfo info-from/msg info-from/patch \ <info-from/0001 >info-from/out && - test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out + test_cmp "$DATA/info-from.expect" info-from/out ' test_expect_success 'mailinfo finds headers after embedded From line' ' mkdir embed-from && - git mailsplit -oembed-from "$TEST_DIRECTORY"/t5100/embed-from.in && - test_cmp "$TEST_DIRECTORY"/t5100/embed-from.in embed-from/0001 && + git mailsplit -oembed-from "$DATA/embed-from.in" && + test_cmp "$DATA/embed-from.in" embed-from/0001 && git mailinfo embed-from/msg embed-from/patch \ <embed-from/0001 >embed-from/out && - test_cmp "$TEST_DIRECTORY"/t5100/embed-from.expect embed-from/out + test_cmp "$DATA/embed-from.expect" embed-from/out ' test_expect_success 'mailinfo on message with quoted >From' ' mkdir quoted-from && - git mailsplit -oquoted-from "$TEST_DIRECTORY"/t5100/quoted-from.in && - test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.in quoted-from/0001 && + git mailsplit -oquoted-from "$DATA/quoted-from.in" && + test_cmp "$DATA/quoted-from.in" quoted-from/0001 && git mailinfo quoted-from/msg quoted-from/patch \ <quoted-from/0001 >quoted-from/out && - test_cmp "$TEST_DIRECTORY"/t5100/quoted-from.expect quoted-from/msg + test_cmp "$DATA/quoted-from.expect" quoted-from/msg ' test_expect_success 'mailinfo unescapes with --mboxrd' ' mkdir mboxrd && git mailsplit -omboxrd --mboxrd \ - "$TEST_DIRECTORY"/t5100/sample.mboxrd >last && + "$DATA/sample.mboxrd" >last && test x"$(cat last)" = x2 && for i in 0001 0002 do git mailinfo mboxrd/msg mboxrd/patch \ <mboxrd/$i >mboxrd/out && - test_cmp "$TEST_DIRECTORY"/t5100/${i}mboxrd mboxrd/msg + test_cmp "$DATA/${i}mboxrd" mboxrd/msg done && sp=" " && echo "From " >expect && @@ -142,4 +144,18 @@ test_expect_success 'mailinfo unescapes with --mboxrd' ' test_cmp expect mboxrd/msg ' +test_expect_success 'mailinfo handles rfc2822 quoted-string' ' + mkdir quoted-string && + git mailinfo /dev/null /dev/null <"$DATA/quoted-string.in" \ + >quoted-string/info && + test_cmp "$DATA/quoted-string.expect" quoted-string/info +' + +test_expect_success 'mailinfo handles rfc2822 comment' ' + mkdir comment && + git mailinfo /dev/null /dev/null <"$DATA/comment.in" \ + >comment/info && + test_cmp "$DATA/comment.expect" comment/info +' + test_done diff --git a/t/t5100/comment.expect b/t/t5100/comment.expect new file mode 100644 index 0000000000..7228177984 --- /dev/null +++ b/t/t5100/comment.expect @@ -0,0 +1,5 @@ +Author: A U Thor (this is (really) a comment (honestly)) +Email: somebody@example.com +Subject: testing comments +Date: Sun, 25 May 2008 00:38:18 -0700 + diff --git a/t/t5100/comment.in b/t/t5100/comment.in new file mode 100644 index 0000000000..c53a192dfe --- /dev/null +++ b/t/t5100/comment.in @@ -0,0 +1,9 @@ +From 1234567890123456789012345678901234567890 Mon Sep 17 00:00:00 2001 +From: "A U Thor" <somebody@example.com> (this is \(really\) a comment (honestly)) +Date: Sun, 25 May 2008 00:38:18 -0700 +Subject: [PATCH] testing comments + + + +--- +patch diff --git a/t/t5100/info0018 b/t/t5100/info0018 new file mode 100644 index 0000000000..d53e7491c7 --- /dev/null +++ b/t/t5100/info0018 @@ -0,0 +1,5 @@ +Author: Another Thor +Email: a.thor@example.com +Subject: This one contains a tab and a space +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/info0018--no-inbody-headers b/t/t5100/info0018--no-inbody-headers new file mode 100644 index 0000000000..30b17bd913 --- /dev/null +++ b/t/t5100/info0018--no-inbody-headers @@ -0,0 +1,5 @@ +Author: A U Thor +Email: a.u.thor@example.com +Subject: check multiline inbody headers +Date: Fri, 9 Jun 2006 00:44:16 -0700 + diff --git a/t/t5100/msg0015 b/t/t5100/msg0015 index 4abb3d5c6c..e69de29bb2 100644 --- a/t/t5100/msg0015 +++ b/t/t5100/msg0015 @@ -1,2 +0,0 @@ - - a list - - of stuff diff --git a/t/t5100/msg0018 b/t/t5100/msg0018 new file mode 100644 index 0000000000..56de83d7fc --- /dev/null +++ b/t/t5100/msg0018 @@ -0,0 +1,2 @@ +a commit message + diff --git a/t/t5100/msg0018--no-inbody-headers b/t/t5100/msg0018--no-inbody-headers new file mode 100644 index 0000000000..b1e05d3862 --- /dev/null +++ b/t/t5100/msg0018--no-inbody-headers @@ -0,0 +1,8 @@ +From: Another Thor + <a.thor@example.com> +Subject: This one contains + a tab + and a space + +a commit message + diff --git a/t/t5100/patch0018 b/t/t5100/patch0018 new file mode 100644 index 0000000000..789df6d030 --- /dev/null +++ b/t/t5100/patch0018 @@ -0,0 +1,6 @@ +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content diff --git a/t/t5100/patch0018--no-inbody-headers b/t/t5100/patch0018--no-inbody-headers new file mode 100644 index 0000000000..789df6d030 --- /dev/null +++ b/t/t5100/patch0018--no-inbody-headers @@ -0,0 +1,6 @@ +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content diff --git a/t/t5100/quoted-string.expect b/t/t5100/quoted-string.expect new file mode 100644 index 0000000000..cab1bcebf9 --- /dev/null +++ b/t/t5100/quoted-string.expect @@ -0,0 +1,5 @@ +Author: Author "The Author" Name +Email: somebody@example.com +Subject: testing quoted-pair +Date: Sun, 25 May 2008 00:38:18 -0700 + diff --git a/t/t5100/quoted-string.in b/t/t5100/quoted-string.in new file mode 100644 index 0000000000..e2e627ae23 --- /dev/null +++ b/t/t5100/quoted-string.in @@ -0,0 +1,9 @@ +From 1234567890123456789012345678901234567890 Mon Sep 17 00:00:00 2001 +From: "Author \"The Author\" Name" <somebody@example.com> +Date: Sun, 25 May 2008 00:38:18 -0700 +Subject: [PATCH] testing quoted-pair + + + +--- +patch diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 8b2ae064c3..6d4d0e4474 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -699,3 +699,22 @@ index e69de29..d95f3ad 100644 +++ b/foo @@ -0,0 +1 @@ +New content +From nobody Mon Sep 17 00:00:00 2001 +From: A U Thor <a.u.thor@example.com> +Subject: check multiline inbody headers +Date: Fri, 9 Jun 2006 00:44:16 -0700 + +From: Another Thor + <a.thor@example.com> +Subject: This one contains + a tab + and a space + +a commit message + +diff --git a/foo b/foo +index e69de29..d95f3ad 100644 +--- a/foo ++++ b/foo +@@ -0,0 +1 @@ ++content diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh index f6020cd2aa..a1dcdb81d7 100755 --- a/t/t6006-rev-list-format.sh +++ b/t/t6006-rev-list-format.sh @@ -225,7 +225,7 @@ test_expect_success '%C(auto,...) respects --color=auto (stdout not tty)' ' test_expect_success '%C(auto) respects --color' ' git log --color --format="%C(auto)%H" -1 >actual && - printf "\\033[m\\033[33m%s\\033[m\\n" $(git rev-parse HEAD) >expect && + printf "\\033[33m%s\\033[m\\n" $(git rev-parse HEAD) >expect && test_cmp expect actual ' diff --git a/t/t6101-rev-parse-parents.sh b/t/t6101-rev-parse-parents.sh index 1c6952d049..64a9850e31 100755 --- a/t/t6101-rev-parse-parents.sh +++ b/t/t6101-rev-parse-parents.sh @@ -102,4 +102,98 @@ test_expect_success 'short SHA-1 works' ' test_cmp_rev_output start "git rev-parse ${start%?}" ' +# rev^- tests; we can use a simpler setup for these + +test_expect_success 'setup for rev^- tests' ' + test_commit one && + test_commit two && + test_commit three && + + # Merge in a branch for testing rev^- + git checkout -b branch && + git checkout HEAD^^ && + git merge -m merge --no-edit --no-ff branch && + git checkout -b merge +' + +# The merged branch has 2 commits + the merge +test_expect_success 'rev-list --count merge^- = merge^..merge' ' + git rev-list --count merge^..merge >expect && + echo 3 >actual && + test_cmp expect actual +' + +# All rev^- rev-parse tests + +test_expect_success 'rev-parse merge^- = merge^..merge' ' + git rev-parse merge^..merge >expect && + git rev-parse merge^- >actual && + test_cmp expect actual +' + +test_expect_success 'rev-parse merge^-1 = merge^..merge' ' + git rev-parse merge^1..merge >expect && + git rev-parse merge^-1 >actual && + test_cmp expect actual +' + +test_expect_success 'rev-parse merge^-2 = merge^2..merge' ' + git rev-parse merge^2..merge >expect && + git rev-parse merge^-2 >actual && + test_cmp expect actual +' + +test_expect_success 'rev-parse merge^-0 (invalid parent)' ' + test_must_fail git rev-parse merge^-0 +' + +test_expect_success 'rev-parse merge^-3 (invalid parent)' ' + test_must_fail git rev-parse merge^-3 +' + +test_expect_success 'rev-parse merge^-^ (garbage after ^-)' ' + test_must_fail git rev-parse merge^-^ +' + +test_expect_success 'rev-parse merge^-1x (garbage after ^-1)' ' + test_must_fail git rev-parse merge^-1x +' + +# All rev^- rev-list tests (should be mostly the same as rev-parse; the reason +# for the duplication is that rev-parse and rev-list use different parsers). + +test_expect_success 'rev-list merge^- = merge^..merge' ' + git rev-list merge^..merge >expect && + git rev-list merge^- >actual && + test_cmp expect actual +' + +test_expect_success 'rev-list merge^-1 = merge^1..merge' ' + git rev-list merge^1..merge >expect && + git rev-list merge^-1 >actual && + test_cmp expect actual +' + +test_expect_success 'rev-list merge^-2 = merge^2..merge' ' + git rev-list merge^2..merge >expect && + git rev-list merge^-2 >actual && + test_cmp expect actual +' + +test_expect_success 'rev-list merge^-0 (invalid parent)' ' + test_must_fail git rev-list merge^-0 +' + +test_expect_success 'rev-list merge^-3 (invalid parent)' ' + test_must_fail git rev-list merge^-3 +' + +test_expect_success 'rev-list merge^-^ (garbage after ^-)' ' + test_must_fail git rev-list merge^-^ +' + +test_expect_success 'rev-list merge^-1x (garbage after ^-1)' ' + test_must_fail git rev-list merge^-1x +' + test_done diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index e94b2f147a..6d06ed96cb 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -709,6 +709,14 @@ test_expect_success HIGHLIGHT \ git commit -m "Add test.sh" && gitweb_run "p=.git;a=blob;f=test.sh"' +test_expect_success HIGHLIGHT \ + 'syntax highlighting (highlighter language autodetection)' \ + 'git config gitweb.highlight yes && + echo "#!/usr/bin/perl" > test && + git add test && + git commit -m "Add test" && + gitweb_run "p=.git;a=blob;f=test"' + # ---------------------------------------------------------------------- # forks of projects |