diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t2300-cd-to-toplevel.sh | 37 | ||||
-rwxr-xr-x | t/t3001-ls-files-others-exclude.sh | 6 | ||||
-rwxr-xr-x | t/t3200-branch.sh | 3 | ||||
-rwxr-xr-x | t/t3409-rebase-preserve-merges.sh | 56 | ||||
-rwxr-xr-x | t/t3600-rm.sh | 17 | ||||
-rwxr-xr-x | t/t5400-send-pack.sh | 2 | ||||
-rwxr-xr-x | t/t5521-pull-symlink.sh | 78 | ||||
-rwxr-xr-x | t/t6120-describe.sh | 6 | ||||
-rwxr-xr-x | t/t7007-show.sh | 20 | ||||
-rwxr-xr-x | t/t9129-git-svn-i18n-commitencoding.sh | 30 | ||||
-rwxr-xr-x | t/t9300-fast-import.sh | 18 | ||||
-rwxr-xr-x | t/t9301-fast-export.sh | 20 | ||||
-rw-r--r-- | t/test-lib.sh | 1 |
13 files changed, 267 insertions, 27 deletions
diff --git a/t/t2300-cd-to-toplevel.sh b/t/t2300-cd-to-toplevel.sh new file mode 100755 index 0000000000..beddb4e9f2 --- /dev/null +++ b/t/t2300-cd-to-toplevel.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +test_description='cd_to_toplevel' + +. ./test-lib.sh + +test_cd_to_toplevel () { + test_expect_success "$2" ' + ( + cd '"'$1'"' && + . git-sh-setup && + cd_to_toplevel && + [ "$(/bin/pwd)" = "$TOPLEVEL" ] + ) + ' +} + +TOPLEVEL="$(/bin/pwd)/repo" +mkdir -p repo/sub/dir +mv .git repo/ +SUBDIRECTORY_OK=1 + +test_cd_to_toplevel repo 'at physical root' + +test_cd_to_toplevel repo/sub/dir 'at physical subdir' + +ln -s repo symrepo +test_cd_to_toplevel symrepo 'at symbolic root' + +ln -s repo/sub/dir subdir-link +test_cd_to_toplevel subdir-link 'at symbolic subdir' + +cd repo +ln -s sub/dir internal-link +test_cd_to_toplevel internal-link 'at internal symbolic subdir' + +test_done diff --git a/t/t3001-ls-files-others-exclude.sh b/t/t3001-ls-files-others-exclude.sh index 8666946b02..85aef12a11 100755 --- a/t/t3001-ls-files-others-exclude.sh +++ b/t/t3001-ls-files-others-exclude.sh @@ -140,4 +140,10 @@ test_expect_success 'trailing slash in exclude forces directory match (2)' ' ' +test_expect_success 'negated exclude matches can override previous ones' ' + + git ls-files --others --exclude="a.*" --exclude="!a.1" >output && + grep "^a.1" output +' + test_done diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 25e9971fd8..61a2010f5b 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -194,7 +194,8 @@ test_expect_success 'test deleting branch deletes branch config' \ test_expect_success 'test deleting branch without config' \ 'git branch my7 s && - test "$(git branch -d my7 2>&1)" = "Deleted branch my7."' + sha1=$(git rev-parse my7 | cut -c 1-7) && + test "$(git branch -d my7 2>&1)" = "Deleted branch my7 ($sha1)."' test_expect_success 'test --track without .fetch entries' \ 'git branch --track my8 && diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 8cde40f8e8..e6c832780f 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -11,15 +11,23 @@ Run "git rebase -p" and check that merges are properly carried along GIT_AUTHOR_EMAIL=bogus_email_address export GIT_AUTHOR_EMAIL -#echo 'Setting up: +# Clone 1 (trivial merge): # -#A1--A2 <-- origin/master -# \ \ -# B1--M <-- topic -# \ -# B2 <-- origin/topic +# A1--A2 <-- origin/master +# \ \ +# B1--M <-- topic +# \ +# B2 <-- origin/topic # -#' +# Clone 2 (conflicting merge): +# +# A1--A2--B3 <-- origin/master +# \ \ +# B1------M <-- topic +# \ +# B2 <-- origin/topic +# +# In both cases, 'topic' is rebased onto 'origin/topic'. test_expect_success 'setup for merge-preserving rebase' \ 'echo First > A && @@ -37,12 +45,19 @@ test_expect_success 'setup for merge-preserving rebase' \ cd clone1 && git checkout -b topic origin/topic && git merge origin/master && - cd .. + cd .. && + + echo Fifth > B && + git add B && + git commit -m "Add different B" && - git clone ./. clone2 + git clone ./. clone2 && cd clone2 && git checkout -b topic origin/topic && - git merge origin/master && + test_must_fail git merge origin/master && + echo Resolved > B && + git add B && + git commit -m "Merge origin/master into topic" && cd .. && git checkout topic && @@ -51,11 +66,30 @@ test_expect_success 'setup for merge-preserving rebase' \ ' test_expect_success 'rebase -p fakes interactive rebase' ' - cd clone2 && + ( + cd clone1 && git fetch && git rebase -p origin/topic && test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) && test 1 = $(git rev-list --all --pretty=oneline | grep "Merge commit" | wc -l) + ) +' + +test_expect_success '--continue works after a conflict' ' + ( + cd clone2 && + git fetch && + test_must_fail git rebase -p origin/topic && + test 2 = $(git ls-files B | wc -l) && + echo Resolved again > B && + test_must_fail git rebase --continue && + grep "^@@@ " .git/rebase-merge/patch && + git add B && + git rebase --continue && + test 1 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Add different" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Merge origin" | wc -l) + ) ' test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index b7d46e50a8..95542e9cfe 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -251,4 +251,21 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' ' +test_expect_success 'choking "git rm" should not let it die with cruft' ' + git reset -q --hard && + H=0000000000000000000000000000000000000000 && + i=0 && + while test $i -lt 12000 + do + echo "100644 $H 0 some-file-$i" + i=$(( $i + 1 )) + done | git update-index --index-info && + git rm -n "some-file-*" | :; + test -f .git/index.lock + status=$? + rm -f .git/index.lock + git reset -q --hard + test "$status" != 0 +' + test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index da69f087b4..b21317d685 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -99,7 +99,7 @@ test_expect_success \ ! test -f victim/.git/refs/heads/extra ' -unset GIT_CONFIG GIT_CONFIG_LOCAL +unset GIT_CONFIG HOME=`pwd`/no-such-directory export HOME ;# this way we force the victim/.git/config to be used. diff --git a/t/t5521-pull-symlink.sh b/t/t5521-pull-symlink.sh new file mode 100755 index 0000000000..5672b51e2e --- /dev/null +++ b/t/t5521-pull-symlink.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +test_description='pulling from symlinked subdir' + +. ./test-lib.sh + +# The scenario we are building: +# +# trash\ directory/ +# clone-repo/ +# subdir/ +# bar +# subdir-link -> clone-repo/subdir/ +# +# The working directory is subdir-link. + +mkdir subdir +echo file >subdir/file +git add subdir/file +git commit -q -m file +git clone -q . clone-repo +ln -s clone-repo/subdir/ subdir-link + + +# Demonstrate that things work if we just avoid the symlink +# +test_expect_success 'pulling from real subdir' ' + ( + echo real >subdir/file && + git commit -m real subdir/file && + cd clone-repo/subdir/ && + git pull && + test real = $(cat file) + ) +' + +# From subdir-link, pulling should work as it does from +# clone-repo/subdir/. +# +# Instead, the error pull gave was: +# +# fatal: 'origin': unable to chdir or not a git archive +# fatal: The remote end hung up unexpectedly +# +# because git would find the .git/config for the "trash directory" +# repo, not for the clone-repo repo. The "trash directory" repo +# had no entry for origin. Git found the wrong .git because +# git rev-parse --show-cdup printed a path relative to +# clone-repo/subdir/, not subdir-link/. Git rev-parse --show-cdup +# used the correct .git, but when the git pull shell script did +# "cd `git rev-parse --show-cdup`", it ended up in the wrong +# directory. A POSIX shell's "cd" works a little differently +# than chdir() in C; "cd -P" is much closer to chdir(). +# +test_expect_success 'pulling from symlinked subdir' ' + ( + echo link >subdir/file && + git commit -m link subdir/file && + cd subdir-link/ && + git pull && + test link = $(cat file) + ) +' + +# Prove that the remote end really is a repo, and other commands +# work fine in this context. It's just that "git pull" breaks. +# +test_expect_success 'pushing from symlinked subdir' ' + ( + cd subdir-link/ && + echo push >file && + git commit -m push ./file && + git push + ) && + test push = $(git show HEAD:subdir/file) +' + +test_done diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index e6c9e59b61..8c7e081c53 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -100,6 +100,12 @@ check_describe B --tags HEAD^^2^ check_describe B-0-* --long HEAD^^2^ check_describe A-3-* --long HEAD^^2 +: >err.expect +check_describe A --all A^0 +test_expect_success 'no warning was displayed for A' ' + test_cmp err.expect err.actual +' + test_expect_success 'rename tag A to Q locally' ' mv .git/refs/tags/A .git/refs/tags/Q ' diff --git a/t/t7007-show.sh b/t/t7007-show.sh new file mode 100755 index 0000000000..cce222f052 --- /dev/null +++ b/t/t7007-show.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +test_description='git show' + +. ./test-lib.sh + +test_expect_success setup ' + echo hello world >foo && + H=$(git hash-object -w foo) && + git tag -a foo-tag -m "Tags $H" $H && + HH=$(expr "$H" : "\(..\)") && + H38=$(expr "$H" : "..\(.*\)") && + rm -f .git/objects/$HH/$H38 +' + +test_expect_success 'showing a tag that point at a missing object' ' + test_must_fail git --no-pager show foo-tag +' + +test_done diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh index 938b7fe4b4..8a9dde44d5 100755 --- a/t/t9129-git-svn-i18n-commitencoding.sh +++ b/t/t9129-git-svn-i18n-commitencoding.sh @@ -60,21 +60,25 @@ do ' done -test_expect_success 'ISO-8859-1 should match UTF-8 in svn' ' -( - cd ISO-8859-1 && - compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt -) -' - -for H in EUCJP ISO-2022-JP -do - test_expect_success '$H should match UTF-8 in svn' ' +if locale -a |grep -q en_US.utf8; then + test_expect_success 'ISO-8859-1 should match UTF-8 in svn' ' ( - cd $H && - compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt + cd ISO-8859-1 && + compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt ) ' -done + + for H in EUCJP ISO-2022-JP + do + test_expect_success '$H should match UTF-8 in svn' ' + ( + cd $H && + compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt + ) + ' + done +else + say "UTF-8 locale not available, test skipped" +fi test_done diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 91b5aced1b..821be7ce8d 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -56,6 +56,12 @@ M 644 :2 file2 M 644 :3 file3 M 755 :4 file4 +tag series-A +from :5 +data <<EOF +An annotated tag without a tagger +EOF + INPUT_END test_expect_success \ 'A: create pack from stdin' \ @@ -102,6 +108,18 @@ test_expect_success \ 'git cat-file blob master:file4 >actual && test_cmp expect actual' cat >expect <<EOF +object $(git rev-parse refs/heads/master) +type commit +tag series-A + +An annotated tag without a tagger +EOF +test_expect_success 'A: verify tag/series-A' ' + git cat-file tag tags/series-A >actual && + test_cmp expect actual +' + +cat >expect <<EOF :2 `git rev-parse --verify master:file2` :3 `git rev-parse --verify master:file3` :4 `git rev-parse --verify master:file4` diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 2057435462..9985721055 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -239,4 +239,24 @@ test_expect_success 'fast-export | fast-import when master is tagged' ' ' +cat > tag-content << EOF +object $(git rev-parse HEAD) +type commit +tag rosten +EOF + +test_expect_success 'cope with tagger-less tags' ' + + TAG=$(git hash-object -t tag -w tag-content) && + git update-ref refs/tags/sonnenschein $TAG && + git fast-export -C -C --signed-tags=strip --all > output && + test $(grep -c "^tag " output) = 4 && + ! grep "Unspecified Tagger" output && + git fast-export -C -C --signed-tags=strip --all \ + --fake-missing-tagger > output && + test $(grep -c "^tag " output) = 4 && + grep "Unspecified Tagger" output + +' + test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index 8936173ee2..22ed448d56 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -471,7 +471,6 @@ PATH=$TEST_DIRECTORY/..:$PATH GIT_EXEC_PATH=$(pwd)/.. GIT_TEMPLATE_DIR=$(pwd)/../templates/blt unset GIT_CONFIG -unset GIT_CONFIG_LOCAL GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_NOGLOBAL=1 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL |