diff options
Diffstat (limited to 't')
64 files changed, 1268 insertions, 551 deletions
diff --git a/t/.gitignore b/t/.gitignore index fad67c097b..11ffd910c1 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -1 +1 @@ -trash +/trash directory diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 9decd2e1e8..5d3bd9dda9 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -20,12 +20,13 @@ then fi svnrepo=$PWD/svnrepo +export svnrepo perl -w -e " use SVN::Core; use SVN::Repos; \$SVN::Core::VERSION gt '1.1.0' or exit(42); -system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41); +system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41); " >&3 2>&4 x=$? if test $x -ne 0 @@ -73,11 +74,16 @@ for d in \ done start_httpd () { + repo_base_path="$1" if test -z "$SVN_HTTPD_PORT" then echo >&2 'SVN_HTTPD_PORT is not defined!' return fi + if test -z "$repo_base_path" + then + repo_base_path=svn + fi mkdir "$GIT_DIR"/logs @@ -90,13 +96,13 @@ LockFile logs/accept.lock Listen 127.0.0.1:$SVN_HTTPD_PORT LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so -<Location /svn> +<Location /$repo_base_path> DAV svn SVNPath $rawsvnrepo </Location> EOF "$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start - svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn + svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path" } stop_httpd () { diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 7f206c56cf..a5c4436fd1 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -61,7 +61,8 @@ prepare_httpd() { -new -x509 -nodes \ -out $HTTPD_ROOT_PATH/httpd.pem \ -keyout $HTTPD_ROOT_PATH/httpd.pem - export GIT_SSL_NO_VERIFY=t + GIT_SSL_NO_VERIFY=t + export GIT_SSL_NO_VERIFY HTTPD_PARA="$HTTPD_PARA -DSSL" else HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 27b54cbb12..690f80ab27 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -305,10 +305,10 @@ test_expect_success 'absolute path works as expected' ' file="$dir"/index && test "$file" = "$(test-absolute-path $dir2/index)" && basename=blub && - test "$dir/$basename" = $(cd .git && test-absolute-path $basename) && + test "$dir/$basename" = "$(cd .git && test-absolute-path "$basename")" && ln -s ../first/file .git/syml && sym="$(cd first; pwd -P)"/file && - test "$sym" = "$(test-absolute-path $dir2/syml)" + test "$sym" = "$(test-absolute-path "$dir2/syml")" ' test_expect_success 'very long name in the index handled sanely' ' diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index b9cef3422c..fc386ba033 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -21,7 +21,7 @@ LF=' ' test_expect_success 'update-index and ls-files' ' - cd $HERE && + cd "$HERE" && git update-index --add one && case "`git ls-files`" in one) echo ok one ;; @@ -41,7 +41,7 @@ test_expect_success 'update-index and ls-files' ' ' test_expect_success 'cat-file' ' - cd $HERE && + cd "$HERE" && two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && @@ -54,7 +54,7 @@ test_expect_success 'cat-file' ' rm -f actual dir/actual test_expect_success 'diff-files' ' - cd $HERE && + cd "$HERE" && echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in @@ -74,7 +74,7 @@ test_expect_success 'diff-files' ' ' test_expect_success 'write-tree' ' - cd $HERE && + cd "$HERE" && top=`git write-tree` && echo $top && cd dir && @@ -84,7 +84,7 @@ test_expect_success 'write-tree' ' ' test_expect_success 'checkout-index' ' - cd $HERE && + cd "$HERE" && git checkout-index -f -u one && cmp one original.one && cd dir && @@ -93,7 +93,7 @@ test_expect_success 'checkout-index' ' ' test_expect_success 'read-tree' ' - cd $HERE && + cd "$HERE" && rm -f one dir/two && tree=`git write-tree` && git read-tree --reset -u "$tree" && @@ -107,27 +107,27 @@ test_expect_success 'read-tree' ' ' test_expect_success 'no file/rev ambiguity check inside .git' ' - cd $HERE && + cd "$HERE" && git commit -a -m 1 && - cd $HERE/.git && + cd "$HERE"/.git && git show -s HEAD ' test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd $HERE && + cd "$HERE" && git clone -s --bare .git foo.git && cd foo.git && GIT_DIR=. git show -s HEAD ' # This still does not work as it should... : test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd $HERE && + cd "$HERE" && git clone -s --bare .git foo.git && cd foo.git && git show -s HEAD ' test_expect_success 'detection should not be fooled by a symlink' ' - cd $HERE && + cd "$HERE" && rm -fr foo.git && git clone -s .git another && ln -s another yetanother && diff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh index 99985dcd79..f366b53fb6 100755 --- a/t/t1303-wacky-config.sh +++ b/t/t1303-wacky-config.sh @@ -34,4 +34,10 @@ test_expect_success 'add key in different section' ' check section2.key bar ' +SECTION="test.q\"s\\sq'sp e.key" +test_expect_success 'make sure git-config escapes section names properly' ' + git config "$SECTION" bar && + check "$SECTION" bar +' + test_done diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh index 38a2bf09af..85da4caa7e 100755 --- a/t/t1500-rev-parse.sh +++ b/t/t1500-rev-parse.sh @@ -51,8 +51,9 @@ test_rev_parse 'core.bare undefined' false false true mkdir work || exit 1 cd work || exit 1 -export GIT_DIR=../.git -export GIT_CONFIG="$(pwd)"/../.git/config +GIT_DIR=../.git +GIT_CONFIG="$(pwd)"/../.git/config +export GIT_DIR GIT_CONFIG git config core.bare false test_rev_parse 'GIT_DIR=../.git, core.bare = false' false false true '' @@ -64,8 +65,8 @@ git config --unset core.bare test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true '' mv ../.git ../repo.git || exit 1 -export GIT_DIR=../repo.git -export GIT_CONFIG="$(pwd)"/../repo.git/config +GIT_DIR=../repo.git +GIT_CONFIG="$(pwd)"/../repo.git/config git config core.bare false test_rev_parse 'GIT_DIR=../repo.git, core.bare = false' false false true '' diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index 7ee3820ce9..2ee88d8a06 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -32,24 +32,25 @@ mkdir -p work/sub/dir || exit 1 mv .git repo.git || exit 1 say "core.worktree = relative path" -export GIT_DIR=repo.git -export GIT_CONFIG="$(pwd)"/$GIT_DIR/config +GIT_DIR=repo.git +GIT_CONFIG="$(pwd)"/$GIT_DIR/config +export GIT_DIR GIT_CONFIG unset GIT_WORK_TREE git config core.worktree ../work test_rev_parse 'outside' false false false cd work || exit 1 -export GIT_DIR=../repo.git -export GIT_CONFIG="$(pwd)"/$GIT_DIR/config +GIT_DIR=../repo.git +GIT_CONFIG="$(pwd)"/$GIT_DIR/config test_rev_parse 'inside' false false true '' cd sub/dir || exit 1 -export GIT_DIR=../../../repo.git -export GIT_CONFIG="$(pwd)"/$GIT_DIR/config +GIT_DIR=../../../repo.git +GIT_CONFIG="$(pwd)"/$GIT_DIR/config test_rev_parse 'subdirectory' false false true sub/dir/ cd ../../.. || exit 1 say "core.worktree = absolute path" -export GIT_DIR=$(pwd)/repo.git -export GIT_CONFIG=$GIT_DIR/config +GIT_DIR=$(pwd)/repo.git +GIT_CONFIG=$GIT_DIR/config git config core.worktree "$(pwd)/work" test_rev_parse 'outside' false false false cd work || exit 1 @@ -59,25 +60,26 @@ test_rev_parse 'subdirectory' false false true sub/dir/ cd ../../.. || exit 1 say "GIT_WORK_TREE=relative path (override core.worktree)" -export GIT_DIR=$(pwd)/repo.git -export GIT_CONFIG=$GIT_DIR/config +GIT_DIR=$(pwd)/repo.git +GIT_CONFIG=$GIT_DIR/config git config core.worktree non-existent -export GIT_WORK_TREE=work +GIT_WORK_TREE=work +export GIT_WORK_TREE test_rev_parse 'outside' false false false cd work || exit 1 -export GIT_WORK_TREE=. +GIT_WORK_TREE=. test_rev_parse 'inside' false false true '' cd sub/dir || exit 1 -export GIT_WORK_TREE=../.. +GIT_WORK_TREE=../.. test_rev_parse 'subdirectory' false false true sub/dir/ cd ../../.. || exit 1 mv work repo.git/work say "GIT_WORK_TREE=absolute path, work tree below git dir" -export GIT_DIR=$(pwd)/repo.git -export GIT_CONFIG=$GIT_DIR/config -export GIT_WORK_TREE=$(pwd)/repo.git/work +GIT_DIR=$(pwd)/repo.git +GIT_CONFIG=$GIT_DIR/config +GIT_WORK_TREE=$(pwd)/repo.git/work test_rev_parse 'outside' false false false cd repo.git || exit 1 test_rev_parse 'in repo.git' false true false diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh new file mode 100755 index 0000000000..95244c9bcf --- /dev/null +++ b/t/t1503-rev-parse-verify.sh @@ -0,0 +1,107 @@ +#!/bin/sh +# +# Copyright (c) 2008 Christian Couder +# +test_description='test git rev-parse --verify' + +exec </dev/null + +. ./test-lib.sh + +add_line_into_file() +{ + _line=$1 + _file=$2 + + if [ -f "$_file" ]; then + echo "$_line" >> $_file || return $? + MSG="Add <$_line> into <$_file>." + else + echo "$_line" > $_file || return $? + git add $_file || return $? + MSG="Create file <$_file> with <$_line> inside." + fi + + test_tick + git-commit --quiet -m "$MSG" $_file +} + +HASH1= +HASH2= +HASH3= +HASH4= + +test_expect_success 'set up basic repo with 1 file (hello) and 4 commits' ' + add_line_into_file "1: Hello World" hello && + HASH1=$(git rev-parse --verify HEAD) && + add_line_into_file "2: A new day for git" hello && + HASH2=$(git rev-parse --verify HEAD) && + add_line_into_file "3: Another new day for git" hello && + HASH3=$(git rev-parse --verify HEAD) && + add_line_into_file "4: Ciao for now" hello && + HASH4=$(git rev-parse --verify HEAD) +' + +test_expect_success 'works with one good rev' ' + rev_hash1=$(git rev-parse --verify $HASH1) && + test "$rev_hash1" = "$HASH1" && + rev_hash2=$(git rev-parse --verify $HASH2) && + test "$rev_hash2" = "$HASH2" && + rev_hash3=$(git rev-parse --verify $HASH3) && + test "$rev_hash3" = "$HASH3" && + rev_hash4=$(git rev-parse --verify $HASH4) && + test "$rev_hash4" = "$HASH4" && + rev_master=$(git rev-parse --verify master) && + test "$rev_master" = "$HASH4" && + rev_head=$(git rev-parse --verify HEAD) && + test "$rev_head" = "$HASH4" +' + +test_expect_success 'fails with any bad rev or many good revs' ' + test_must_fail git rev-parse --verify 2>error && + grep "single revision" error && + test_must_fail git rev-parse --verify foo 2>error && + grep "single revision" error && + test_must_fail git rev-parse --verify HEAD bar 2>error && + grep "single revision" error && + test_must_fail git rev-parse --verify baz HEAD 2>error && + grep "single revision" error && + test_must_fail git rev-parse --verify $HASH2 HEAD 2>error && + grep "single revision" error +' + +test_expect_success 'fails silently when using -q' ' + test_must_fail git rev-parse --verify --quiet 2>error && + test -z "$(cat error)" && + test_must_fail git rev-parse -q --verify foo 2>error && + test -z "$(cat error)" && + test_must_fail git rev-parse --verify -q HEAD bar 2>error && + test -z "$(cat error)" && + test_must_fail git rev-parse --quiet --verify baz HEAD 2>error && + test -z "$(cat error)" && + test_must_fail git rev-parse -q --verify $HASH2 HEAD 2>error && + test -z "$(cat error)" +' + +test_expect_success 'no stdout output on error' ' + test -z "$(git rev-parse --verify)" && + test -z "$(git rev-parse --verify foo)" && + test -z "$(git rev-parse --verify baz HEAD)" && + test -z "$(git rev-parse --verify HEAD bar)" && + test -z "$(git rev-parse --verify $HASH2 HEAD)" +' + +test_expect_success 'use --default' ' + git rev-parse --verify --default master && + git rev-parse --verify --default master HEAD && + git rev-parse --default master --verify && + git rev-parse --default master --verify HEAD && + git rev-parse --verify HEAD --default master && + test_must_fail git rev-parse --verify foo --default master && + test_must_fail git rev-parse --default HEAD --verify bar && + test_must_fail git rev-parse --verify --default HEAD baz && + test_must_fail git rev-parse --default foo --verify && + test_must_fail git rev-parse --verify --default bar +' + +test_done diff --git a/t/t3050-subprojects-fetch.sh b/t/t3050-subprojects-fetch.sh index 2b21b1070d..4261e9641e 100755 --- a/t/t3050-subprojects-fetch.sh +++ b/t/t3050-subprojects-fetch.sh @@ -20,7 +20,7 @@ test_expect_success setup ' ' test_expect_success clone ' - git clone file://`pwd`/.git cloned && + git clone "file://$(pwd)/.git" cloned && (git rev-parse HEAD; git ls-files -s) >expected && ( cd cloned && diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index cb5f7a4441..8d8768688d 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -224,4 +224,238 @@ test_expect_success 'avoid ambiguous track' ' test -z "$(git config branch.all1.merge)" ' +test_expect_success 'autosetuprebase local on a tracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase local && + (git show-ref -q refs/remotes/local/o || git-fetch local) && + git branch mybase && + git branch --track myr1 mybase && + test "$(git config branch.myr1.remote)" = . && + test "$(git config branch.myr1.merge)" = refs/heads/mybase && + test "$(git config branch.myr1.rebase)" = true +' + +test_expect_success 'autosetuprebase always on a tracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase always && + (git show-ref -q refs/remotes/local/o || git-fetch local) && + git branch mybase2 && + git branch --track myr2 mybase && + test "$(git config branch.myr2.remote)" = . && + test "$(git config branch.myr2.merge)" = refs/heads/mybase && + test "$(git config branch.myr2.rebase)" = true +' + +test_expect_success 'autosetuprebase remote on a tracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase remote && + (git show-ref -q refs/remotes/local/o || git-fetch local) && + git branch mybase3 && + git branch --track myr3 mybase2 && + test "$(git config branch.myr3.remote)" = . && + test "$(git config branch.myr3.merge)" = refs/heads/mybase2 && + ! test "$(git config branch.myr3.rebase)" = true +' + +test_expect_success 'autosetuprebase never on a tracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase never && + (git show-ref -q refs/remotes/local/o || git-fetch local) && + git branch mybase4 && + git branch --track myr4 mybase2 && + test "$(git config branch.myr4.remote)" = . && + test "$(git config branch.myr4.merge)" = refs/heads/mybase2 && + ! test "$(git config branch.myr4.rebase)" = true +' + +test_expect_success 'autosetuprebase local on a tracked remote branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase local && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track myr5 local/master && + test "$(git config branch.myr5.remote)" = local && + test "$(git config branch.myr5.merge)" = refs/heads/master && + ! test "$(git config branch.myr5.rebase)" = true +' + +test_expect_success 'autosetuprebase never on a tracked remote branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase never && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track myr6 local/master && + test "$(git config branch.myr6.remote)" = local && + test "$(git config branch.myr6.merge)" = refs/heads/master && + ! test "$(git config branch.myr6.rebase)" = true +' + +test_expect_success 'autosetuprebase remote on a tracked remote branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase remote && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track myr7 local/master && + test "$(git config branch.myr7.remote)" = local && + test "$(git config branch.myr7.merge)" = refs/heads/master && + test "$(git config branch.myr7.rebase)" = true +' + +test_expect_success 'autosetuprebase always on a tracked remote branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + git config branch.autosetuprebase remote && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track myr8 local/master && + test "$(git config branch.myr8.remote)" = local && + test "$(git config branch.myr8.merge)" = refs/heads/master && + test "$(git config branch.myr8.rebase)" = true +' + +test_expect_success 'autosetuprebase unconfigured on a tracked remote branch' ' + git config --unset branch.autosetuprebase && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --track myr9 local/master && + test "$(git config branch.myr9.remote)" = local && + test "$(git config branch.myr9.merge)" = refs/heads/master && + test "z$(git config branch.myr9.rebase)" = z +' + +test_expect_success 'autosetuprebase unconfigured on a tracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/o || git-fetch local) && + git branch mybase10 && + git branch --track myr10 mybase2 && + test "$(git config branch.myr10.remote)" = . && + test "$(git config branch.myr10.merge)" = refs/heads/mybase2 && + test "z$(git config branch.myr10.rebase)" = z +' + +test_expect_success 'autosetuprebase unconfigured on untracked local branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr11 mybase2 && + test "z$(git config branch.myr11.remote)" = z && + test "z$(git config branch.myr11.merge)" = z && + test "z$(git config branch.myr11.rebase)" = z +' + +test_expect_success 'autosetuprebase unconfigured on untracked remote branch' ' + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr12 local/master && + test "z$(git config branch.myr12.remote)" = z && + test "z$(git config branch.myr12.merge)" = z && + test "z$(git config branch.myr12.rebase)" = z +' + +test_expect_success 'autosetuprebase never on an untracked local branch' ' + git config branch.autosetuprebase never && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr13 mybase2 && + test "z$(git config branch.myr13.remote)" = z && + test "z$(git config branch.myr13.merge)" = z && + test "z$(git config branch.myr13.rebase)" = z +' + +test_expect_success 'autosetuprebase local on an untracked local branch' ' + git config branch.autosetuprebase local && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr14 mybase2 && + test "z$(git config branch.myr14.remote)" = z && + test "z$(git config branch.myr14.merge)" = z && + test "z$(git config branch.myr14.rebase)" = z +' + +test_expect_success 'autosetuprebase remote on an untracked local branch' ' + git config branch.autosetuprebase remote && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr15 mybase2 && + test "z$(git config branch.myr15.remote)" = z && + test "z$(git config branch.myr15.merge)" = z && + test "z$(git config branch.myr15.rebase)" = z +' + +test_expect_success 'autosetuprebase always on an untracked local branch' ' + git config branch.autosetuprebase always && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr16 mybase2 && + test "z$(git config branch.myr16.remote)" = z && + test "z$(git config branch.myr16.merge)" = z && + test "z$(git config branch.myr16.rebase)" = z +' + +test_expect_success 'autosetuprebase never on an untracked remote branch' ' + git config branch.autosetuprebase never && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr17 local/master && + test "z$(git config branch.myr17.remote)" = z && + test "z$(git config branch.myr17.merge)" = z && + test "z$(git config branch.myr17.rebase)" = z +' + +test_expect_success 'autosetuprebase local on an untracked remote branch' ' + git config branch.autosetuprebase local && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr18 local/master && + test "z$(git config branch.myr18.remote)" = z && + test "z$(git config branch.myr18.merge)" = z && + test "z$(git config branch.myr18.rebase)" = z +' + +test_expect_success 'autosetuprebase remote on an untracked remote branch' ' + git config branch.autosetuprebase remote && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr19 local/master && + test "z$(git config branch.myr19.remote)" = z && + test "z$(git config branch.myr19.merge)" = z && + test "z$(git config branch.myr19.rebase)" = z +' + +test_expect_success 'autosetuprebase always on an untracked remote branch' ' + git config branch.autosetuprebase always && + git config remote.local.url . && + git config remote.local.fetch refs/heads/*:refs/remotes/local/* && + (git show-ref -q refs/remotes/local/master || git-fetch local) && + git branch --no-track myr20 local/master && + test "z$(git config branch.myr20.remote)" = z && + test "z$(git config branch.myr20.merge)" = z && + test "z$(git config branch.myr20.rebase)" = z +' + +test_expect_success 'detect misconfigured autosetuprebase (bad value)' ' + git config branch.autosetuprebase garbage && + test_must_fail git branch +' + +test_expect_success 'detect misconfigured autosetuprebase (no value)' ' + git config --unset branch.autosetuprebase && + echo "[branch] autosetuprebase" >> .git/config && + test_must_fail git branch && + git config --unset branch.autosetuprebase +' + test_done diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 496f4ec172..91bb5e1d9e 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -9,7 +9,8 @@ This test runs git rebase and checks that the author information is not lost. ' . ./test-lib.sh -export GIT_AUTHOR_EMAIL=bogus_email_address +GIT_AUTHOR_EMAIL=bogus_email_address +export GIT_AUTHOR_EMAIL test_expect_success \ 'prepare repository with topic branches' \ @@ -44,13 +45,13 @@ test_expect_success 'rebase against master' ' test_expect_success \ 'the rebase operation should not have destroyed author information' \ - '! git log | grep "Author:" | grep "<>"' + '! (git log | grep "Author:" | grep "<>")' test_expect_success 'rebase after merge master' ' git reset --hard topic && git merge master && git rebase master && - ! git show | grep "^Merge:" + ! (git show | grep "^Merge:") ' test_expect_success 'rebase of history with merges is linearized' ' diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 9cf873f7eb..b9e3dbd242 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -91,9 +91,8 @@ for line in $FAKE_LINES; do done EOF +test_set_editor "$(pwd)/fake-editor.sh" chmod a+x fake-editor.sh -VISUAL="$(pwd)/fake-editor.sh" -export VISUAL test_expect_success 'no changes are a nop' ' git rebase -i F && diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 37944c39a3..1777ffe8a2 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -4,7 +4,13 @@ test_description='git rebase --abort tests' . ./test-lib.sh +### Test that we handle space characters properly +work_dir="$(pwd)/test dir" + test_expect_success setup ' + mkdir -p "$work_dir" && + cd "$work_dir" && + git init && echo a > a && git add a && git commit -m a && @@ -28,32 +34,35 @@ testrebase() { dotest=$2 test_expect_success "rebase$type --abort" ' + cd "$work_dir" && # Clean up the state from the previous one - git reset --hard pre-rebase - test_must_fail git rebase'"$type"' master && - test -d '$dotest' && + git reset --hard pre-rebase && + test_must_fail git rebase$type master && + test -d "$dotest" && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && - test ! -d '$dotest' + test ! -d "$dotest" ' test_expect_success "rebase$type --abort after --skip" ' + cd "$work_dir" && # Clean up the state from the previous one - git reset --hard pre-rebase - test_must_fail git rebase'"$type"' master && - test -d '$dotest' && + git reset --hard pre-rebase && + test_must_fail git rebase$type master && + test -d "$dotest" && test_must_fail git rebase --skip && test $(git rev-parse HEAD) = $(git rev-parse master) && git-rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && - test ! -d '$dotest' + test ! -d "$dotest" ' test_expect_success "rebase$type --abort after --continue" ' + cd "$work_dir" && # Clean up the state from the previous one - git reset --hard pre-rebase - test_must_fail git rebase'"$type"' master && - test -d '$dotest' && + git reset --hard pre-rebase && + test_must_fail git rebase$type master && + test -d "$dotest" && echo c > a && echo d >> a && git add a && @@ -61,7 +70,7 @@ testrebase() { test $(git rev-parse HEAD) != $(git rev-parse master) && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && - test ! -d '$dotest' + test ! -d "$dotest" ' } diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh index d0a440feba..4911c48378 100755 --- a/t/t3500-cherry.sh +++ b/t/t3500-cherry.sh @@ -10,7 +10,8 @@ checks that git cherry only returns the second patch in the local branch ' . ./test-lib.sh -export GIT_AUTHOR_EMAIL=bogus_email_address +GIT_AUTHOR_EMAIL=bogus_email_address +export GIT_AUTHOR_EMAIL test_expect_success \ 'prepare repository with topic branch, and check cherry finds the 2 patches from there' \ diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 287e058e37..68c5ddebdf 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -81,17 +81,17 @@ test_expect_success '.gitignore test setup' ' test_expect_success '.gitignore is honored' ' git add . && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'error out when attempting to add ignored ones without -f' ' ! git add a.?? && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'error out when attempting to add ignored ones without -f' ' ! git add d.?? && - ! git ls-files | grep "\\.ig" + ! (git ls-files | grep "\\.ig") ' test_expect_success 'add ignored ones with -f' ' diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index 1fd3fb74d7..ba6679c6e4 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -50,4 +50,11 @@ test_expect_success 'git diff-files --raw' ' test_cmp expect actual.files ' +test_expect_success 'git diff (empty submodule dir)' ' + : >empty && + rm -rf sub/* sub/.git && + git diff > actual.empty && + test_cmp empty actual.empty +' + test_done diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh index fa62b6aa21..9b0baac8db 100755 --- a/t/t5000-tar-tree.sh +++ b/t/t5000-tar-tree.sh @@ -67,10 +67,10 @@ test_expect_success \ test_expect_success \ 'validate file modification time' \ - 'TZ=GMT $TAR tvf b.tar a/a | - awk \{print\ \$4,\ \(length\(\$5\)\<7\)\ ?\ \$5\":00\"\ :\ \$5\} \ - >b.mtime && - echo "2005-05-27 22:00:00" >expected.mtime && + 'mkdir extract && + $TAR xf b.tar -C extract a/a && + perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime && + echo "1117231200" >expected.mtime && diff expected.mtime b.mtime' test_expect_success \ diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index b88b5bbd02..09fd917672 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -65,7 +65,7 @@ test_expect_success \ have_64bits= if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) || - ! echo "$msg" | grep "pack too large .* off_t" + ! (echo "$msg" | grep "pack too large .* off_t") then have_64bits=t else diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 788b4a5aae..140e874581 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -31,7 +31,7 @@ add () { sec=$(($sec+1)) commit=$(echo "$text" | GIT_AUTHOR_DATE=$sec \ git commit-tree $tree $parents 2>>log2.txt) - export $name=$commit + eval "$name=$commit; export $name" echo $commit > .git/refs/heads/$branch eval ${branch}TIP=$commit } @@ -129,7 +129,7 @@ pull_to_client 2nd "B" $((64*3)) pull_to_client 3rd "A" $((1*3)) # old fails -test_expect_success "clone shallow" "git-clone --depth 2 file://`pwd`/. shallow" +test_expect_success "clone shallow" 'git-clone --depth 2 "file://$(pwd)/." shallow' (cd shallow; git count-objects -v) > count.shallow diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh index c0dc94909b..1dd8eed5bb 100755 --- a/t/t5512-ls-remote.sh +++ b/t/t5512-ls-remote.sh @@ -17,7 +17,7 @@ test_expect_success setup ' git show-ref -d | sed -e "s/ / /" ) >expected.all && - git remote add self $(pwd)/.git + git remote add self "$(pwd)/.git" ' diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 0a757d5b9f..3af03d4827 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -105,7 +105,7 @@ test_expect_success 'fetch with insteadOf' ' ( TRASH=$(pwd)/ && cd testrepo && - git config url.$TRASH.insteadOf trash/ + git config "url.$TRASH.insteadOf" trash/ && git config remote.up.url trash/. && git config remote.up.fetch "refs/heads/*:refs/remotes/origin/*" && git fetch up && @@ -145,8 +145,8 @@ test_expect_success 'push with wildcard' ' test_expect_success 'push with insteadOf' ' mk_empty && - TRASH=$(pwd)/ && - git config url.$TRASH.insteadOf trash/ && + TRASH="$(pwd)/" && + git config "url./$TRASH/.insteadOf" trash/ && git push trash/testrepo refs/heads/master:refs/remotes/origin/master && ( cd testrepo && diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh index b6a54867b4..e5619a9f5c 100755 --- a/t/t5700-clone-reference.sh +++ b/t/t5700-clone-reference.sh @@ -51,7 +51,7 @@ diff expected current' cd "$base_dir" test_expect_success 'cloning with reference (no -l -s)' \ -'git clone --reference B file://`pwd`/A D' +'git clone --reference B "file://$(pwd)/A" D' cd "$base_dir" diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh index 910ccb4fff..ef7127c1b3 100755 --- a/t/t5710-info-alternate.sh +++ b/t/t5710-info-alternate.sh @@ -81,9 +81,9 @@ test_valid_repo' cd "$base_dir" test_expect_success 'breaking of loops' \ -"echo '$base_dir/B/.git/objects' >> '$base_dir'/A/.git/objects/info/alternates&& +'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&& cd C && -test_valid_repo" +test_valid_repo' cd "$base_dir" diff --git a/t/t6000lib.sh b/t/t6000lib.sh index c0baaa5360..f55627b641 100755 --- a/t/t6000lib.sh +++ b/t/t6000lib.sh @@ -49,13 +49,15 @@ as_author() shift 1 _save=$GIT_AUTHOR_EMAIL - export GIT_AUTHOR_EMAIL="$_author" + GIT_AUTHOR_EMAIL="$_author" + export GIT_AUTHOR_EMAIL "$@" if test -z "$_save" then unset GIT_AUTHOR_EMAIL else - export GIT_AUTHOR_EMAIL="$_save" + GIT_AUTHOR_EMAIL="$_save" + export GIT_AUTHOR_EMAIL fi } @@ -69,7 +71,8 @@ on_committer_date() { _date=$1 shift 1 - export GIT_COMMITTER_DATE="$_date" + GIT_COMMITTER_DATE="$_date" + export GIT_COMMITTER_DATE "$@" unset GIT_COMMITTER_DATE } diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh index 96f3d35530..b6e57b2426 100755 --- a/t/t6010-merge-base.sh +++ b/t/t6010-merge-base.sh @@ -13,10 +13,11 @@ T=$(git write-tree) M=1130000000 Z=+0000 -export GIT_COMMITTER_EMAIL=git@comm.iter.xz -export GIT_COMMITTER_NAME='C O Mmiter' -export GIT_AUTHOR_NAME='A U Thor' -export GIT_AUTHOR_EMAIL=git@au.thor.xz +GIT_COMMITTER_EMAIL=git@comm.iter.xz +GIT_COMMITTER_NAME='C O Mmiter' +GIT_AUTHOR_NAME='A U Thor' +GIT_AUTHOR_EMAIL=git@au.thor.xz +export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL doit() { OFFSET=$1; shift diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh index 5e3e5445c7..933f567983 100755 --- a/t/t6030-bisect-porcelain.sh +++ b/t/t6030-bisect-porcelain.sh @@ -284,6 +284,31 @@ test_expect_success 'bisect starting with a detached HEAD' ' ' +test_expect_success 'bisect refuses to start if branch bisect exists' ' + git bisect reset && + git branch bisect && + test_must_fail git bisect start && + git branch -d bisect && + git checkout -b bisect && + test_must_fail git bisect start && + git checkout master && + git branch -d bisect +' + +test_expect_success 'bisect refuses to start if branch new-bisect exists' ' + git bisect reset && + git branch new-bisect && + test_must_fail git bisect start && + git branch -d new-bisect +' + +test_expect_success 'bisect errors out if bad and good are mistaken' ' + git bisect reset && + test_must_fail git bisect start $HASH2 $HASH4 2> rev_list_error && + grep "mistake good and bad" rev_list_error && + git bisect reset +' + # # test_done diff --git a/t/t6032-merge-large-rename.sh b/t/t6032-merge-large-rename.sh new file mode 100755 index 0000000000..eac5ebac24 --- /dev/null +++ b/t/t6032-merge-large-rename.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +test_description='merging with large rename matrix' +. ./test-lib.sh + +count() { + i=1 + while test $i -le $1; do + echo $i + i=$(($i + 1)) + done +} + +test_expect_success 'setup (initial)' ' + touch file && + git add . && + git commit -m initial && + git tag initial +' + +make_text() { + echo $1: $2 + for i in `count 20`; do + echo $1: $i + done + echo $1: $3 +} + +test_rename() { + test_expect_success "rename ($1, $2)" ' + n='$1' + expect='$2' + git checkout -f master && + git branch -D test$n || true && + git reset --hard initial && + for i in $(count $n); do + make_text $i initial initial >$i + done && + git add . && + git commit -m add=$n && + for i in $(count $n); do + make_text $i changed initial >$i + done && + git commit -a -m change=$n && + git checkout -b test$n HEAD^ && + for i in $(count $n); do + git rm $i + make_text $i initial changed >$i.moved + done && + git add . && + git commit -m change+rename=$n && + case "$expect" in + ok) git merge master ;; + *) test_must_fail git merge master ;; + esac + ' +} + +test_rename 5 ok + +test_expect_success 'set diff.renamelimit to 4' ' + git config diff.renamelimit 4 +' +test_rename 4 ok +test_rename 5 fail + +test_expect_success 'set merge.renamelimit to 5' ' + git config merge.renamelimit 5 +' +test_rename 5 ok +test_rename 6 fail + +test_done diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh index 526d7d1c44..c9bf6fdba3 100755 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@ -82,14 +82,14 @@ test_expect_success 'merge-msg test #1' ' git diff actual expected ' -cat >expected <<\EOF -Merge branch 'left' of ../trash +cat >expected <<EOF +Merge branch 'left' of ../$test EOF test_expect_success 'merge-msg test #2' ' git checkout master && - git fetch ../trash left && + git fetch ../"$test" left && git fmt-merge-msg <.git/FETCH_HEAD >actual && git diff actual expected @@ -106,8 +106,24 @@ Merge branch 'left' Common #1 EOF -test_expect_success 'merge-msg test #3' ' +test_expect_success 'merge-msg test #3-1' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log true && + + git checkout master && + setdate && + git fetch . left && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #3-2' ' + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary true && git checkout master && @@ -136,8 +152,24 @@ Merge branches 'left' and 'right' Common #1 EOF -test_expect_success 'merge-msg test #4' ' +test_expect_success 'merge-msg test #4-1' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log true && + + git checkout master && + setdate && + git fetch . left right && + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #4-2' ' + + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary true && git checkout master && @@ -148,8 +180,24 @@ test_expect_success 'merge-msg test #4' ' git diff actual expected ' -test_expect_success 'merge-msg test #5' ' +test_expect_success 'merge-msg test #5-1' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log yes && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #5-2' ' + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary yes && git checkout master && diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 16df3d4adb..1639c7aa96 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -125,7 +125,7 @@ test_expect_success 'use index-filter to move into a subdirectory' ' "git ls-files -s | sed \"s-\\t-&newsubdir/-\" | GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \ git update-index --index-info && - mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved && + mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved && test -z "$(git diff HEAD directorymoved:newsubdir)"' test_expect_success 'stops when msg filter fails' ' diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 1a7141ecd7..2dcee7ccc5 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -626,7 +626,8 @@ esac cp -R ../t7004 ./gpghome chmod 0700 gpghome -export GNUPGHOME="$(pwd)/gpghome" +GNUPGHOME="$(pwd)/gpghome" +export GNUPGHOME get_tag_header signed-tag $commit commit $time >expect echo 'A signed tag message' >>expect diff --git a/t/t7010-setup.sh b/t/t7010-setup.sh index 02cf7c5c9d..d8a7c79852 100755 --- a/t/t7010-setup.sh +++ b/t/t7010-setup.sh @@ -122,7 +122,7 @@ test_expect_success 'commit using absolute path names' ' test_expect_success 'log using absolute path names' ' echo bb >>a/b/c/d && - git commit -m "bb" $(pwd)/a/b/c/d && + git commit -m "bb" "$(pwd)/a/b/c/d" && git log a/b/c/d >f1.txt && git log "$(pwd)/a/b/c/d" >f2.txt && diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index a50492f7c0..bd77239708 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -112,7 +112,7 @@ test_expect_success 'git-clean with absolute path' ' touch a.out src/part3.c docs/manual.txt obj.o build/lib.so && would_clean=$( cd docs && - git clean -n $(pwd)/../src | + git clean -n "$(pwd)/../src" | sed -n -e "s|^Would remove ||p" ) && test "$would_clean" = ../src/part3.c || { diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index c0288f345f..d3370ff7ff 100755 --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@ -41,7 +41,7 @@ test_expect_success \ test_expect_success \ "using paths with --interactive" \ "echo bong-o-bong >file && - ! echo 7 | git-commit -m foo --interactive file" + ! (echo 7 | git-commit -m foo --interactive file)" test_expect_success \ "using invalid commit with -C" \ @@ -79,8 +79,8 @@ test_expect_success \ cat >editor <<\EOF #!/bin/sh -sed -e "s/a file/an amend commit/g" < $1 > $1- -mv $1- $1 +sed -e "s/a file/an amend commit/g" < "$1" > "$1-" +mv "$1-" "$1" EOF chmod 755 editor @@ -99,8 +99,8 @@ test_expect_success \ cat >editor <<\EOF #!/bin/sh -sed -e "s/amend/older/g" < $1 > $1- -mv $1- $1 +sed -e "s/amend/older/g" < "$1" > "$1-" +mv "$1-" "$1" EOF chmod 755 editor diff --git a/t/t7504-commit-msg-hook.sh b/t/t7504-commit-msg-hook.sh index eff36aaee3..88577af953 100755 --- a/t/t7504-commit-msg-hook.sh +++ b/t/t7504-commit-msg-hook.sh @@ -19,6 +19,9 @@ cp FAKE_MSG "$1" exit 0 EOF chmod +x fake-editor + +## Not using test_set_editor here so we can easily ensure the editor variable +## is only set for the editor tests FAKE_EDITOR="$(pwd)/fake-editor" export FAKE_EDITOR @@ -27,7 +30,7 @@ test_expect_success 'with no hook (editor)' ' echo "more foo" >> file && git add file && echo "more foo" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit ' @@ -44,7 +47,7 @@ test_expect_success '--no-verify with no hook (editor)' ' echo "more bar" > file && git add file && echo "more bar" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify ' @@ -71,7 +74,7 @@ test_expect_success 'with succeeding hook (editor)' ' echo "more more" >> file && git add file && echo "more more" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit ' @@ -88,7 +91,7 @@ test_expect_success '--no-verify with succeeding hook (editor)' ' echo "even more more" >> file && git add file && echo "even more more" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify ' @@ -111,7 +114,7 @@ test_expect_success 'with failing hook (editor)' ' echo "more another" >> file && git add file && echo "more another" > FAKE_MSG && - ! (GIT_EDITOR="$FAKE_EDITOR" git commit) + ! (GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit) ' @@ -128,7 +131,7 @@ test_expect_success '--no-verify with failing hook (editor)' ' echo "more stuff" >> file && git add file && echo "more stuff" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify ' @@ -146,7 +149,7 @@ test_expect_success 'with non-executable hook (editor)' ' echo "content again" >> file && git add file && echo "content again" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit -m "content again" + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -m "content again" ' @@ -163,7 +166,7 @@ test_expect_success '--no-verify with non-executable hook (editor)' ' echo "even more content" >> file && git add file && echo "even more content" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify ' @@ -193,7 +196,7 @@ test_expect_success 'hook edits commit message (editor)' ' echo "additional content" >> file && git add file && echo "additional content" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit && commit_msg_is "new message" ' @@ -212,7 +215,7 @@ test_expect_success "hook doesn't edit commit message (editor)" ' echo "more plus" >> file && git add file && echo "more plus" > FAKE_MSG && - GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify && commit_msg_is "more plus" ' diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh index 802aa624d0..cd6c7c8342 100755 --- a/t/t7505-prepare-commit-msg-hook.sh +++ b/t/t7505-prepare-commit-msg-hook.sh @@ -18,6 +18,9 @@ cat > fake-editor <<'EOF' exit 0 EOF chmod +x fake-editor + +## Not using test_set_editor here so we can easily ensure the editor variable +## is only set for the editor tests FAKE_EDITOR="$(pwd)/fake-editor" export FAKE_EDITOR @@ -58,7 +61,7 @@ test_expect_success 'with hook (-m editor)' ' echo "more" >> file && git add file && - GIT_EDITOR="$FAKE_EDITOR" git commit -e -m "more more" && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -m "more more" && test "`git log -1 --pretty=format:%s`" = message ' @@ -85,7 +88,7 @@ test_expect_success 'with hook (-F editor)' ' echo "more" >> file && git add file && - (echo more more | GIT_EDITOR="$FAKE_EDITOR" git commit -e -F -) && + (echo more more | GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -e -F -) && test "`git log -1 --pretty=format:%s`" = message ' @@ -104,7 +107,7 @@ test_expect_success 'with hook (editor)' ' echo "more more" >> file && git add file && - GIT_EDITOR="$FAKE_EDITOR" git commit && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit && test "`git log -1 --pretty=format:%s`" = default ' @@ -114,7 +117,7 @@ test_expect_success 'with hook (--amend)' ' head=`git rev-parse HEAD` && echo "more" >> file && git add file && - GIT_EDITOR="$FAKE_EDITOR" git commit --amend && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --amend && test "`git log -1 --pretty=format:%s`" = "$head" ' @@ -124,7 +127,7 @@ test_expect_success 'with hook (-c)' ' head=`git rev-parse HEAD` && echo "more" >> file && git add file && - GIT_EDITOR="$FAKE_EDITOR" git commit -c $head && + GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head && test "`git log -1 --pretty=format:%s`" = "$head" ' @@ -139,7 +142,7 @@ test_expect_success 'with failing hook' ' head=`git rev-parse HEAD` && echo "more" >> file && git add file && - ! GIT_EDITOR="$FAKE_EDITOR" git commit -c $head + ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit -c $head ' @@ -148,7 +151,7 @@ test_expect_success 'with failing hook (--no-verify)' ' head=`git rev-parse HEAD` && echo "more" >> file && git add file && - ! GIT_EDITOR="$FAKE_EDITOR" git commit --no-verify -c $head + ! GIT_EDITOR="\"\$FAKE_EDITOR\"" git commit --no-verify -c $head ' diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh new file mode 100755 index 0000000000..a75130cdbb --- /dev/null +++ b/t/t7506-status-submodule.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +test_description='git-status for submodule' + +. ./test-lib.sh + +test_expect_success 'setup' ' + test_create_repo sub + cd sub && + : >bar && + git add bar && + git commit -m " Add bar" && + cd .. && + git add sub && + git commit -m "Add submodule sub" +' + +test_expect_success 'status clean' ' + git status | + grep "nothing to commit" +' +test_expect_success 'status -a clean' ' + git status -a | + grep "nothing to commit" +' +test_expect_success 'rm submodule contents' ' + rm -rf sub/* sub/.git +' +test_expect_success 'status clean (empty submodule dir)' ' + git status | + grep "nothing to commit" +' +test_expect_success 'status -a clean (empty submodule dir)' ' + git status -a | + grep "nothing to commit" +' + +test_done diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 56869aceed..d21cd290d3 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -104,7 +104,11 @@ create_merge_msgs() { git log --no-merges ^HEAD c2 >>squash.1-5 && echo "Squashed commit of the following:" >squash.1-5-9 && echo >>squash.1-5-9 && - git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 + git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 && + echo > msg.nolog && + echo "* commit 'c3':" >msg.log && + echo " commit 3" >>msg.log && + echo >>msg.log } verify_diff() { @@ -364,7 +368,7 @@ test_expect_success 'merge c1 with c2 (squash in config)' ' test_debug 'gitk --all' -test_expect_success 'override config option -n' ' +test_expect_success 'override config option -n with --summary' ' git reset --hard c1 && git config branch.master.mergeoptions "-n" && test_tick && @@ -373,15 +377,30 @@ test_expect_success 'override config option -n' ' verify_parents $c1 $c2 && if ! grep "^ file | *2 +-$" diffstat.txt then - echo "[OOPS] diffstat was not generated" + echo "[OOPS] diffstat was not generated with --summary" + false + fi +' + +test_expect_success 'override config option -n with --stat' ' + git reset --hard c1 && + git config branch.master.mergeoptions "-n" && + test_tick && + git merge --stat c2 >diffstat.txt && + verify_merge file result.1-5 msg.1-5 && + verify_parents $c1 $c2 && + if ! grep "^ file | *2 +-$" diffstat.txt + then + echo "[OOPS] diffstat was not generated with --stat" + false fi ' test_debug 'gitk --all' -test_expect_success 'override config option --summary' ' +test_expect_success 'override config option --stat' ' git reset --hard c1 && - git config branch.master.mergeoptions "--summary" && + git config branch.master.mergeoptions "--stat" && test_tick && git merge -n c2 >diffstat.txt && verify_merge file result.1-5 msg.1-5 && @@ -441,6 +460,16 @@ test_expect_success 'merge c0 with c1 (ff overrides no-ff)' ' verify_head $c1 ' +test_expect_success 'merge log message' ' + git reset --hard c0 && + git merge --no-log c2 && + git show -s --pretty=format:%b HEAD >msg.act && + verify_diff msg.nolog msg.act "[OOPS] bad merge log message" && + git merge --log c3 && + git show -s --pretty=format:%b HEAD >msg.act && + verify_diff msg.log msg.act "[OOPS] bad merge log message" +' + test_debug 'gitk --all' test_done diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index c0973b4e6e..04baa61c04 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -139,15 +139,16 @@ test_expect_success 'Valid In-Reply-To when prompting' ' test_expect_success 'setup fake editor' ' (echo "#!/bin/sh" && - echo "echo fake edit >>\$1" + echo "echo fake edit >>\"\$1\"" ) >fake-editor && chmod +x fake-editor ' +test_set_editor "$(pwd)/fake-editor" + test_expect_success '--compose works' ' clean_fake_sendmail && echo y | \ - GIT_EDITOR=$(pwd)/fake-editor \ GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject foo \ @@ -166,4 +167,70 @@ test_expect_success 'second message is patch' ' grep "Subject:.*Second" msgtxt2 ' +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<cc@example.com>,<author@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: cc@example.com, A <author@example.com> +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc set' ' + git config sendemail.cc cc@example.com && + git send-email \ + --dry-run \ + --from="Example <from@example.com>" \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM:<from@example.com> +RCPT TO:<to@example.com>,<author@example.com> +From: Example <from@example.com> +To: to@example.com +Cc: A <author@example.com> +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc unset' ' + git config --unset sendemail.cc && + git send-email \ + --dry-run \ + --from="Example <from@example.com>" \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + test_done diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 4e24ab3a7d..bdf29c1734 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -20,39 +20,39 @@ esac echo 'define NO_SVN_TESTS to skip git-svn tests' test_expect_success \ - 'initialize git-svn' " + 'initialize git-svn' ' mkdir import && cd import && echo foo > foo && ln -s foo foo.link mkdir -p dir/a/b/c/d/e && - echo 'deep dir' > dir/a/b/c/d/e/file && + echo "deep dir" > dir/a/b/c/d/e/file && mkdir bar && - echo 'zzz' > bar/zzz && - echo '#!/bin/sh' > exec.sh && + echo "zzz" > bar/zzz && + echo "#!/bin/sh" > exec.sh && chmod +x exec.sh && - svn import -m 'import for git-svn' . $svnrepo >/dev/null && + svn import -m "import for git-svn" . "$svnrepo" >/dev/null && cd .. && rm -rf import && - git-svn init $svnrepo" + git-svn init "$svnrepo"' test_expect_success \ 'import an SVN revision into git' \ 'git-svn fetch' -test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'" +test_expect_success "checkout from svn" 'svn co "$svnrepo" "$SVN_TREE"' name='try a deep --rmdir with a commit' -test_expect_success "$name" " +test_expect_success "$name" ' git checkout -f -b mybranch remotes/git-svn && mv dir/a/b/c/d/e/file dir/file && cp dir/file file && git update-index --add --remove dir/a/b/c/d/e/file dir/file file && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch && - svn up '$SVN_TREE' && - test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a" + svn up "$SVN_TREE" && + test -d "$SVN_TREE"/dir && test ! -d "$SVN_TREE"/dir/a' name='detect node change from file to directory #1' @@ -68,108 +68,108 @@ test_expect_success "$name" " name='detect node change from directory to file #1' -test_expect_success "$name" " - rm -rf dir '$GIT_DIR'/index && +test_expect_success "$name" ' + rm -rf dir "$GIT_DIR"/index && git checkout -f -b mybranch2 remotes/git-svn && mv bar/zzz zzz && rm -rf bar && mv zzz bar && git update-index --remove -- bar/zzz && git update-index --add -- bar && - git commit -m '$name' && + git commit -m "$name" && ! git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch2" || true + remotes/git-svn..mybranch2' || true name='detect node change from file to directory #2' -test_expect_success "$name" " - rm -f '$GIT_DIR'/index && +test_expect_success "$name" ' + rm -f "$GIT_DIR"/index && git checkout -f -b mybranch3 remotes/git-svn && rm bar/zzz && git update-index --remove bar/zzz && mkdir bar/zzz && echo yyy > bar/zzz/yyy && git update-index --add bar/zzz/yyy && - git commit -m '$name' && + git commit -m "$name" && ! git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch3" || true + remotes/git-svn..mybranch3' || true name='detect node change from directory to file #2' -test_expect_success "$name" " - rm -f '$GIT_DIR'/index && +test_expect_success "$name" ' + rm -f "$GIT_DIR"/index && git checkout -f -b mybranch4 remotes/git-svn && rm -rf dir && git update-index --remove -- dir/file && touch dir && echo asdf > dir && git update-index --add -- dir && - git commit -m '$name' && + git commit -m "$name" && ! git-svn set-tree --find-copies-harder --rmdir \ - remotes/git-svn..mybranch4" || true + remotes/git-svn..mybranch4' || true name='remove executable bit from a file' -test_expect_success "$name" " - rm -f '$GIT_DIR'/index && +test_expect_success "$name" ' + rm -f "$GIT_DIR"/index && git checkout -f -b mybranch5 remotes/git-svn && chmod -x exec.sh && git update-index exec.sh && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch5 && - svn up '$SVN_TREE' && - test ! -x '$SVN_TREE'/exec.sh" + svn up "$SVN_TREE" && + test ! -x "$SVN_TREE"/exec.sh' name='add executable bit back file' -test_expect_success "$name" " +test_expect_success "$name" ' chmod +x exec.sh && git update-index exec.sh && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch5 && - svn up '$SVN_TREE' && - test -x '$SVN_TREE'/exec.sh" + svn up "$SVN_TREE" && + test -x "$SVN_TREE"/exec.sh' name='executable file becomes a symlink to bar/zzz (file)' -test_expect_success "$name" " +test_expect_success "$name" ' rm exec.sh && ln -s bar/zzz exec.sh && git update-index exec.sh && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch5 && - svn up '$SVN_TREE' && - test -L '$SVN_TREE'/exec.sh" + svn up "$SVN_TREE" && + test -L "$SVN_TREE"/exec.sh' name='new symlink is added to a file that was also just made executable' -test_expect_success "$name" " +test_expect_success "$name" ' chmod +x bar/zzz && ln -s bar/zzz exec-2.sh && git update-index --add bar/zzz exec-2.sh && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch5 && - svn up '$SVN_TREE' && - test -x '$SVN_TREE'/bar/zzz && - test -L '$SVN_TREE'/exec-2.sh" + svn up "$SVN_TREE" && + test -x "$SVN_TREE"/bar/zzz && + test -L "$SVN_TREE"/exec-2.sh' name='modify a symlink to become a file' -test_expect_success "$name" " +test_expect_success "$name" ' echo git help > help || true && rm exec-2.sh && cp help exec-2.sh && git update-index exec-2.sh && - git commit -m '$name' && + git commit -m "$name" && git-svn set-tree --find-copies-harder --rmdir \ remotes/git-svn..mybranch5 && - svn up '$SVN_TREE' && - test -f '$SVN_TREE'/exec-2.sh && - test ! -L '$SVN_TREE'/exec-2.sh && - git diff help $SVN_TREE/exec-2.sh" + svn up "$SVN_TREE" && + test -f "$SVN_TREE"/exec-2.sh && + test ! -L "$SVN_TREE"/exec-2.sh && + git diff help "$SVN_TREE"/exec-2.sh' if test "$have_utf8" = t then @@ -190,10 +190,10 @@ name='test fetch functionality (svn => git) with alternate GIT_SVN_ID' GIT_SVN_ID=alt export GIT_SVN_ID test_expect_success "$name" \ - "git-svn init $svnrepo && git-svn fetch && + 'git-svn init "$svnrepo" && git-svn fetch && git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a && git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b && - git diff a b" + git diff a b' name='check imported tree checksums expected tree checksums' rm -f expected @@ -219,22 +219,22 @@ test_expect_success 'exit if remote refs are ambigious' " ! git-svn migrate " -test_expect_success 'exit if init-ing a would clobber a URL' " - svnadmin create ${PWD}/svnrepo2 && - svn mkdir -m 'mkdir bar' ${svnrepo}2/bar && +test_expect_success 'exit if init-ing a would clobber a URL' ' + svnadmin create "${PWD}/svnrepo2" && + svn mkdir -m "mkdir bar" "${svnrepo}2/bar" && git config --unset svn-remote.svn.fetch \ - '^bar:refs/remotes/git-svn$' && - ! git-svn init ${svnrepo}2/bar - " + "^bar:refs/remotes/git-svn$" && + ! git-svn init "${svnrepo}2/bar" + ' test_expect_success \ - 'init allows us to connect to another directory in the same repo' " - git-svn init --minimize-url -i bar $svnrepo/bar && + 'init allows us to connect to another directory in the same repo' ' + git-svn init --minimize-url -i bar "$svnrepo/bar" && git config --get svn-remote.svn.fetch \ - '^bar:refs/remotes/bar$' && + "^bar:refs/remotes/bar$" && git config --get svn-remote.svn.fetch \ - '^:refs/remotes/git-svn$' - " + "^:refs/remotes/git-svn$" + ' test_expect_success 'able to dcommit to a subdirectory' " git-svn fetch -i bar && diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index d7a704754e..f420796c31 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -52,7 +52,7 @@ EOF cd .. rm -rf import -test_expect_success 'checkout working copy from svn' "svn co $svnrepo test_wc" +test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc' test_expect_success 'setup some commits to svn' \ 'cd test_wc && echo Greetings >> kw.c && @@ -66,7 +66,7 @@ test_expect_success 'setup some commits to svn' \ svn commit -m "Propset Id" && cd ..' -test_expect_success 'initialize git-svn' "git-svn init $svnrepo" +test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"' test_expect_success 'fetch revisions from svn' 'git-svn fetch' name='test svn:keywords ignoring' @@ -90,9 +90,9 @@ test_expect_success "propset CR on crlf files" \ cd ..' test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ - "git-svn fetch && + 'git-svn fetch && git pull . remotes/git-svn && - svn co $svnrepo new_wc" + svn co "$svnrepo" new_wc' for i in crlf ne_crlf lf ne_lf cr ne_cr empty_cr empty_lf empty empty_crlf do diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index 4e0808380f..0e7ce34b9b 100755 --- a/t/t9102-git-svn-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh @@ -2,29 +2,29 @@ test_description='git-svn rmdir' . ./lib-git-svn.sh -test_expect_success 'initialize repo' " +test_expect_success 'initialize repo' ' mkdir import && cd import && mkdir -p deeply/nested/directory/number/1 && mkdir -p deeply/nested/directory/number/2 && echo foo > deeply/nested/directory/number/1/file && echo foo > deeply/nested/directory/number/2/another && - svn import -m 'import for git-svn' . $svnrepo && + svn import -m "import for git-svn" . "$svnrepo" && cd .. - " + ' -test_expect_success 'mirror via git-svn' " - git-svn init $svnrepo && +test_expect_success 'mirror via git-svn' ' + git-svn init "$svnrepo" && git-svn fetch && git checkout -f -b test-rmdir remotes/git-svn - " + ' -test_expect_success 'Try a commit on rmdir' " +test_expect_success 'Try a commit on rmdir' ' git rm -f deeply/nested/directory/number/2/another && - git commit -a -m 'remove another' && + git commit -a -m "remove another" && git-svn set-tree --rmdir HEAD && - svn ls -R $svnrepo | grep ^deeply/nested/directory/number/1 - " + svn ls -R "$svnrepo" | grep ^deeply/nested/directory/number/1 + ' test_done diff --git a/t/t9103-git-svn-tracked-directory-removed.sh b/t/t9103-git-svn-tracked-directory-removed.sh index 0f0b0fd2c6..9ffd8458ef 100755 --- a/t/t9103-git-svn-tracked-directory-removed.sh +++ b/t/t9103-git-svn-tracked-directory-removed.sh @@ -10,30 +10,30 @@ test_expect_success 'make history for tracking' ' mkdir import && mkdir import/trunk && echo hello >> import/trunk/README && - svn import -m initial import $svnrepo && + svn import -m initial import "$svnrepo" && rm -rf import && - svn co $svnrepo/trunk trunk && + svn co "$svnrepo"/trunk trunk && echo bye bye >> trunk/README && - svn rm -m "gone" $svnrepo/trunk && + svn rm -m "gone" "$svnrepo"/trunk && rm -rf trunk && mkdir trunk && echo "new" > trunk/FOLLOWME && - svn import -m "new trunk" trunk $svnrepo/trunk + svn import -m "new trunk" trunk "$svnrepo"/trunk ' test_expect_success 'clone repo with git' ' - git svn clone -s $svnrepo x && + git svn clone -s "$svnrepo" x && test -f x/FOLLOWME && test ! -f x/README ' -test_expect_success 'make sure r2 still has old file' ' +test_expect_success 'make sure r2 still has old file' " cd x && - test -n "$(git svn find-rev r1)" && - git reset --hard $(git svn find-rev r1) && + test -n \"\$(git svn find-rev r1)\" && + git reset --hard \$(git svn find-rev r1) && test -f README && test ! -f FOLLOWME && - test x$(git svn find-rev r2) = x -' + test x\$(git svn find-rev r2) = x +" test_done diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 7ba76309ac..4d964e2db7 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -6,165 +6,165 @@ test_description='git-svn fetching' . ./lib-git-svn.sh -test_expect_success 'initialize repo' " +test_expect_success 'initialize repo' ' mkdir import && cd import && mkdir -p trunk && echo hello > trunk/readme && - svn import -m 'initial' . $svnrepo && + svn import -m "initial" . "$svnrepo" && cd .. && - svn co $svnrepo wc && + svn co "$svnrepo" wc && cd wc && echo world >> trunk/readme && poke trunk/readme && - svn commit -m 'another commit' && + svn commit -m "another commit" && svn up && svn mv trunk thunk && echo goodbye >> thunk/readme && poke thunk/readme && - svn commit -m 'bye now' && + svn commit -m "bye now" && cd .. - " + ' -test_expect_success 'init and fetch a moved directory' " - git-svn init --minimize-url -i thunk $svnrepo/thunk && +test_expect_success 'init and fetch a moved directory' ' + git-svn init --minimize-url -i thunk "$svnrepo"/thunk && git-svn fetch -i thunk && - test \"\`git rev-parse --verify refs/remotes/thunk@2\`\" \ - = \"\`git rev-parse --verify refs/remotes/thunk~1\`\" && - test \"\`git cat-file blob refs/remotes/thunk:readme |\ - sed -n -e '3p'\`\" = goodbye && - test -z \"\`git config --get svn-remote.svn.fetch \ - '^trunk:refs/remotes/thunk@2$'\`\" - " + test "`git rev-parse --verify refs/remotes/thunk@2`" \ + = "`git rev-parse --verify refs/remotes/thunk~1`" && + test "`git cat-file blob refs/remotes/thunk:readme |\ + sed -n -e "3p"`" = goodbye && + test -z "`git config --get svn-remote.svn.fetch \ + "^trunk:refs/remotes/thunk@2$"`" + ' -test_expect_success 'init and fetch from one svn-remote' " - git config svn-remote.svn.url $svnrepo && +test_expect_success 'init and fetch from one svn-remote' ' + git config svn-remote.svn.url "$svnrepo" && git config --add svn-remote.svn.fetch \ trunk:refs/remotes/svn/trunk && git config --add svn-remote.svn.fetch \ thunk:refs/remotes/svn/thunk && git-svn fetch -i svn/thunk && - test \"\`git rev-parse --verify refs/remotes/svn/trunk\`\" \ - = \"\`git rev-parse --verify refs/remotes/svn/thunk~1\`\" && - test \"\`git cat-file blob refs/remotes/svn/thunk:readme |\ - sed -n -e '3p'\`\" = goodbye - " + test "`git rev-parse --verify refs/remotes/svn/trunk`" \ + = "`git rev-parse --verify refs/remotes/svn/thunk~1`" && + test "`git cat-file blob refs/remotes/svn/thunk:readme |\ + sed -n -e "3p"`" = goodbye + ' -test_expect_success 'follow deleted parent' " - (svn cp -m 'resurrecting trunk as junk' \ - $svnrepo/trunk@2 $svnrepo/junk || - svn cp -m 'resurrecting trunk as junk' \ - -r2 $svnrepo/trunk $svnrepo/junk) && +test_expect_success 'follow deleted parent' ' + (svn cp -m "resurrecting trunk as junk" \ + "$svnrepo"/trunk@2 "$svnrepo"/junk || + svn cp -m "resurrecting trunk as junk" \ + -r2 "$svnrepo"/trunk "$svnrepo"/junk) && git config --add svn-remote.svn.fetch \ junk:refs/remotes/svn/junk && git-svn fetch -i svn/thunk && git-svn fetch -i svn/junk && - test -z \"\`git diff svn/junk svn/trunk\`\" && - test \"\`git merge-base svn/junk svn/trunk\`\" \ - = \"\`git rev-parse svn/trunk\`\" - " + test -z "`git diff svn/junk svn/trunk`" && + test "`git merge-base svn/junk svn/trunk`" \ + = "`git rev-parse svn/trunk`" + ' -test_expect_success 'follow larger parent' " +test_expect_success 'follow larger parent' ' mkdir -p import/trunk/thunk/bump/thud && echo hi > import/trunk/thunk/bump/thud/file && - svn import -m 'import a larger parent' import $svnrepo/larger-parent && - svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger && + svn import -m "import a larger parent" import "$svnrepo"/larger-parent && + svn cp -m "hi" "$svnrepo"/larger-parent "$svnrepo"/another-larger && git-svn init --minimize-url -i larger \ - $svnrepo/another-larger/trunk/thunk/bump/thud && + "$svnrepo"/another-larger/trunk/thunk/bump/thud && git-svn fetch -i larger && git rev-parse --verify refs/remotes/larger && git rev-parse --verify \ refs/remotes/larger-parent/trunk/thunk/bump/thud && - test \"\`git merge-base \ + test "`git merge-base \ refs/remotes/larger-parent/trunk/thunk/bump/thud \ - refs/remotes/larger\`\" = \ - \"\`git rev-parse refs/remotes/larger\`\" + refs/remotes/larger`" = \ + "`git rev-parse refs/remotes/larger`" true - " + ' -test_expect_success 'follow higher-level parent' " - svn mkdir -m 'follow higher-level parent' $svnrepo/blob && - svn co $svnrepo/blob blob && +test_expect_success 'follow higher-level parent' ' + svn mkdir -m "follow higher-level parent" "$svnrepo"/blob && + svn co "$svnrepo"/blob blob && cd blob && echo hi > hi && svn add hi && - svn commit -m 'hihi' && + svn commit -m "hihi" && cd .. - svn mkdir -m 'new glob at top level' $svnrepo/glob && - svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob && - git-svn init --minimize-url -i blob $svnrepo/glob/blob && + svn mkdir -m "new glob at top level" "$svnrepo"/glob && + svn mv -m "move blob down a level" "$svnrepo"/blob "$svnrepo"/glob/blob && + git-svn init --minimize-url -i blob "$svnrepo"/glob/blob && git-svn fetch -i blob - " + ' -test_expect_success 'follow deleted directory' " - svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye && - svn rm -m 'remove glob' $svnrepo/glob && - git-svn init --minimize-url -i glob $svnrepo/glob && +test_expect_success 'follow deleted directory' ' + svn mv -m "bye!" "$svnrepo"/glob/blob/hi "$svnrepo"/glob/blob/bye && + svn rm -m "remove glob" "$svnrepo"/glob && + git-svn init --minimize-url -i glob "$svnrepo"/glob && git-svn fetch -i glob && - test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi && - test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1 - " + test "`git cat-file blob refs/remotes/glob:blob/bye`" = hi && + test "`git ls-tree refs/remotes/glob | wc -l `" -eq 1 + ' # ref: r9270 of the Subversion repository: (http://svn.collab.net/repos/svn) # in trunk/subversion/bindings/swig/perl -test_expect_success 'follow-parent avoids deleting relevant info' " +test_expect_success 'follow-parent avoids deleting relevant info' ' mkdir -p import/trunk/subversion/bindings/swig/perl/t && for i in a b c ; do \ - echo \$i > import/trunk/subversion/bindings/swig/perl/\$i.pm && - echo _\$i > import/trunk/subversion/bindings/swig/perl/t/\$i.t; \ + echo $i > import/trunk/subversion/bindings/swig/perl/$i.pm && + echo _$i > import/trunk/subversion/bindings/swig/perl/t/$i.t; \ done && - echo 'bad delete test' > \ + echo "bad delete test" > \ import/trunk/subversion/bindings/swig/perl/t/larger-parent && - echo 'bad delete test 2' > \ + echo "bad delete test 2" > \ import/trunk/subversion/bindings/swig/perl/another-larger && cd import && - svn import -m 'r9270 test' . $svnrepo/r9270 && + svn import -m "r9270 test" . "$svnrepo"/r9270 && cd .. && - svn co $svnrepo/r9270/trunk/subversion/bindings/swig/perl r9270 && + svn co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 && cd r9270 && svn mkdir native && svn mv t native/t && - for i in a b c; do svn mv \$i.pm native/\$i.pm; done && + for i in a b c; do svn mv $i.pm native/$i.pm; done && echo z >> native/t/c.t && poke native/t/c.t && - svn commit -m 'reorg test' && + svn commit -m "reorg test" && cd .. && git-svn init --minimize-url -i r9270-t \ - $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t && + "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && git-svn fetch -i r9270-t && - test \`git rev-list r9270-t | wc -l\` -eq 2 && - test \"\`git ls-tree --name-only r9270-t~1\`\" = \ - \"\`git ls-tree --name-only r9270-t\`\" - " + test `git rev-list r9270-t | wc -l` -eq 2 && + test "`git ls-tree --name-only r9270-t~1`" = \ + "`git ls-tree --name-only r9270-t`" + ' -test_expect_success "track initial change if it was only made to parent" " - svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk && +test_expect_success "track initial change if it was only made to parent" ' + svn cp -m "wheee!" "$svnrepo"/r9270/trunk "$svnrepo"/r9270/drunk && git-svn init --minimize-url -i r9270-d \ - $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t && + "$svnrepo"/r9270/drunk/subversion/bindings/swig/perl/native/t && git-svn fetch -i r9270-d && - test \`git rev-list r9270-d | wc -l\` -eq 3 && - test \"\`git ls-tree --name-only r9270-t\`\" = \ - \"\`git ls-tree --name-only r9270-d\`\" && - test \"\`git rev-parse r9270-t\`\" = \ - \"\`git rev-parse r9270-d~1\`\" - " + test `git rev-list r9270-d | wc -l` -eq 3 && + test "`git ls-tree --name-only r9270-t`" = \ + "`git ls-tree --name-only r9270-d`" && + test "`git rev-parse r9270-t`" = \ + "`git rev-parse r9270-d~1`" + ' -test_expect_success "track multi-parent paths" " - svn cp -m 'resurrect /glob' $svnrepo/r9270 $svnrepo/glob && +test_expect_success "track multi-parent paths" ' + svn cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob && git-svn multi-fetch && - test \`git cat-file commit refs/remotes/glob | \ - grep '^parent ' | wc -l\` -eq 2 - " + test `git cat-file commit refs/remotes/glob | \ + grep "^parent " | wc -l` -eq 2 + ' test_expect_success "multi-fetch continues to work" " git-svn multi-fetch " -test_expect_success "multi-fetch works off a 'clean' repository" " - rm -r $GIT_DIR/svn $GIT_DIR/refs/remotes $GIT_DIR/logs && - mkdir $GIT_DIR/svn && +test_expect_success "multi-fetch works off a 'clean' repository" ' + rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" && + mkdir "$GIT_DIR/svn" && git-svn multi-fetch - " + ' test_debug 'gitk --all &' diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index 318e172ef5..63230367bb 100755 --- a/t/t9105-git-svn-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh @@ -4,18 +4,18 @@ test_description='git-svn commit-diff' . ./lib-git-svn.sh -test_expect_success 'initialize repo' " +test_expect_success 'initialize repo' ' mkdir import && cd import && echo hello > readme && - svn import -m 'initial' . $svnrepo && + svn import -m "initial" . "$svnrepo" && cd .. && echo hello > readme && git update-index --add readme && - git commit -a -m 'initial' && + git commit -a -m "initial" && echo world >> readme && - git commit -a -m 'another' - " + git commit -a -m "another" + ' head=`git rev-parse --verify HEAD^0` prev=`git rev-parse --verify HEAD^1` @@ -24,20 +24,20 @@ prev=`git rev-parse --verify HEAD^1` # commit, so only a basic test of functionality is needed since we've # already tested commit extensively elsewhere -test_expect_success 'test the commit-diff command' " - test -n '$prev' && test -n '$head' && - git-svn commit-diff -r1 '$prev' '$head' '$svnrepo' && - svn co $svnrepo wc && +test_expect_success 'test the commit-diff command' ' + test -n "$prev" && test -n "$head" && + git-svn commit-diff -r1 "$prev" "$head" "$svnrepo" && + svn co "$svnrepo" wc && cmp readme wc/readme - " + ' -test_expect_success 'commit-diff to a sub-directory (with git-svn config)' " - svn import -m 'sub-directory' import $svnrepo/subdir && - git-svn init --minimize-url $svnrepo/subdir && +test_expect_success 'commit-diff to a sub-directory (with git-svn config)' ' + svn import -m "sub-directory" import "$svnrepo"/subdir && + git-svn init --minimize-url "$svnrepo"/subdir && git-svn fetch && - git-svn commit-diff -r3 '$prev' '$head' && - svn cat $svnrepo/subdir/readme > readme.2 && + git-svn commit-diff -r3 "$prev" "$head" && + svn cat "$svnrepo"/subdir/readme > readme.2 && cmp readme readme.2 - " + ' test_done diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh index f74ab1269e..58a3a7b1c3 100755 --- a/t/t9106-git-svn-commit-diff-clobber.sh +++ b/t/t9106-git-svn-commit-diff-clobber.sh @@ -4,56 +4,56 @@ test_description='git-svn commit-diff clobber' . ./lib-git-svn.sh -test_expect_success 'initialize repo' " +test_expect_success 'initialize repo' ' mkdir import && cd import && echo initial > file && - svn import -m 'initial' . $svnrepo && + svn import -m "initial" . "$svnrepo" && cd .. && echo initial > file && git update-index --add file && - git commit -a -m 'initial' - " -test_expect_success 'commit change from svn side' " - svn co $svnrepo t.svn && + git commit -a -m "initial" + ' +test_expect_success 'commit change from svn side' ' + svn co "$svnrepo" t.svn && cd t.svn && echo second line from svn >> file && poke file && - svn commit -m 'second line from svn' && + svn commit -m "second line from svn" && cd .. && rm -rf t.svn - " + ' -test_expect_success 'commit conflicting change from git' " +test_expect_success 'commit conflicting change from git' ' echo second line from git >> file && - git commit -a -m 'second line from git' && - ! git-svn commit-diff -r1 HEAD~1 HEAD $svnrepo -" + git commit -a -m "second line from git" && + ! git-svn commit-diff -r1 HEAD~1 HEAD "$svnrepo" +' -test_expect_success 'commit complementing change from git' " +test_expect_success 'commit complementing change from git' ' git reset --hard HEAD~1 && echo second line from svn >> file && - git commit -a -m 'second line from svn' && + git commit -a -m "second line from svn" && echo third line from git >> file && - git commit -a -m 'third line from git' && - git-svn commit-diff -r2 HEAD~1 HEAD $svnrepo - " + git commit -a -m "third line from git" && + git-svn commit-diff -r2 HEAD~1 HEAD "$svnrepo" + ' -test_expect_success 'dcommit fails to commit because of conflict' " - git-svn init $svnrepo && +test_expect_success 'dcommit fails to commit because of conflict' ' + git-svn init "$svnrepo" && git-svn fetch && git reset --hard refs/remotes/git-svn && - svn co $svnrepo t.svn && + svn co "$svnrepo" t.svn && cd t.svn && echo fourth line from svn >> file && poke file && - svn commit -m 'fourth line from svn' && + svn commit -m "fourth line from svn" && cd .. && rm -rf t.svn && - echo 'fourth line from git' >> file && - git commit -a -m 'fourth line from git' && + echo "fourth line from git" >> file && + git commit -a -m "fourth line from git" && ! git-svn dcommit - " + ' test_expect_success 'dcommit does the svn equivalent of an index merge' " git reset --hard refs/remotes/git-svn && @@ -66,15 +66,15 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' " git-svn dcommit " -test_expect_success 'commit another change from svn side' " - svn co $svnrepo t.svn && +test_expect_success 'commit another change from svn side' ' + svn co "$svnrepo" t.svn && cd t.svn && echo third line from svn >> file && poke file && - svn commit -m 'third line from svn' && + svn commit -m "third line from svn" && cd .. && rm -rf t.svn - " + ' test_expect_success 'multiple dcommit from git-svn will not clobber svn' " git reset --hard refs/remotes/git-svn && diff --git a/t/t9106-git-svn-dcommit-clobber-series.sh b/t/t9106-git-svn-dcommit-clobber-series.sh index ca8a00ed0a..a400dc7966 100755 --- a/t/t9106-git-svn-dcommit-clobber-series.sh +++ b/t/t9106-git-svn-dcommit-clobber-series.sh @@ -4,30 +4,30 @@ test_description='git-svn dcommit clobber series' . ./lib-git-svn.sh -test_expect_success 'initialize repo' " +test_expect_success 'initialize repo' ' mkdir import && cd import && - awk 'BEGIN { for (i = 1; i < 64; i++) { print i } }' > file - svn import -m 'initial' . $svnrepo && + awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file + svn import -m "initial" . "$svnrepo" && cd .. && - git svn init $svnrepo && + git svn init "$svnrepo" && git svn fetch && test -e file - " + ' -test_expect_success '(supposedly) non-conflicting change from SVN' " - test x\"\`sed -n -e 58p < file\`\" = x58 && - test x\"\`sed -n -e 61p < file\`\" = x61 && - svn co $svnrepo tmp && +test_expect_success '(supposedly) non-conflicting change from SVN' ' + test x"`sed -n -e 58p < file`" = x58 && + test x"`sed -n -e 61p < file`" = x61 && + svn co "$svnrepo" tmp && cd tmp && - perl -i -p -e 's/^58\$/5588/' file && - perl -i -p -e 's/^61\$/6611/' file && + perl -i -p -e "s/^58$/5588/" file && + perl -i -p -e "s/^61$/6611/" file && poke file && - test x\"\`sed -n -e 58p < file\`\" = x5588 && - test x\"\`sed -n -e 61p < file\`\" = x6611 && - svn commit -m '58 => 5588, 61 => 6611' && + test x"`sed -n -e 58p < file`" = x5588 && + test x"`sed -n -e 61p < file`" = x6611 && + svn commit -m "58 => 5588, 61 => 6611" && cd .. - " + ' test_expect_success 'some unrelated changes to git' " echo hi > life && diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index 0a41d52c7a..d9b553ad55 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -3,61 +3,61 @@ test_description='git-svn metadata migrations from previous versions' . ./lib-git-svn.sh -test_expect_success 'setup old-looking metadata' " - cp $GIT_DIR/config $GIT_DIR/config-old-git-svn && +test_expect_success 'setup old-looking metadata' ' + cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && mkdir import && cd import && for i in trunk branches/a branches/b \ tags/0.1 tags/0.2 tags/0.3; do - mkdir -p \$i && \ - echo hello >> \$i/README || exit 1 + mkdir -p $i && \ + echo hello >> $i/README || exit 1 done && \ - svn import -m test . $svnrepo + svn import -m test . "$svnrepo" cd .. && - git-svn init $svnrepo && + git-svn init "$svnrepo" && git-svn fetch && - mv $GIT_DIR/svn/* $GIT_DIR/ && - mv $GIT_DIR/svn/.metadata $GIT_DIR/ && - rmdir $GIT_DIR/svn && + mv "$GIT_DIR"/svn/* "$GIT_DIR"/ && + mv "$GIT_DIR"/svn/.metadata "$GIT_DIR"/ && + rmdir "$GIT_DIR"/svn && git update-ref refs/heads/git-svn-HEAD refs/remotes/git-svn && git update-ref refs/heads/svn-HEAD refs/remotes/git-svn && git update-ref -d refs/remotes/git-svn refs/remotes/git-svn - " + ' head=`git rev-parse --verify refs/heads/git-svn-HEAD^0` test_expect_success 'git-svn-HEAD is a real HEAD' "test -n '$head'" -test_expect_success 'initialize old-style (v0) git-svn layout' " - mkdir -p $GIT_DIR/git-svn/info $GIT_DIR/svn/info && - echo $svnrepo > $GIT_DIR/git-svn/info/url && - echo $svnrepo > $GIT_DIR/svn/info/url && +test_expect_success 'initialize old-style (v0) git-svn layout' ' + mkdir -p "$GIT_DIR"/git-svn/info "$GIT_DIR"/svn/info && + echo "$svnrepo" > "$GIT_DIR"/git-svn/info/url && + echo "$svnrepo" > "$GIT_DIR"/svn/info/url && git-svn migrate && - ! test -d $GIT_DIR/git-svn && + ! test -d "$GIT_DIR"/git-svn && git rev-parse --verify refs/remotes/git-svn^0 && git rev-parse --verify refs/remotes/svn^0 && - test \`git config --get svn-remote.svn.url\` = '$svnrepo' && - test \`git config --get svn-remote.svn.fetch\` = \ - ':refs/remotes/git-svn' - " + test "$(git config --get svn-remote.svn.url)" = "$svnrepo" && + test `git config --get svn-remote.svn.fetch` = \ + ":refs/remotes/git-svn" + ' -test_expect_success 'initialize a multi-repository repo' " - git-svn init $svnrepo -T trunk -t tags -b branches && +test_expect_success 'initialize a multi-repository repo' ' + git-svn init "$svnrepo" -T trunk -t tags -b branches && git config --get-all svn-remote.svn.fetch > fetch.out && - grep '^trunk:refs/remotes/trunk$' fetch.out && - test -n \"\`git config --get svn-remote.svn.branches \ - '^branches/\*:refs/remotes/\*$'\`\" && - test -n \"\`git config --get svn-remote.svn.tags \ - '^tags/\*:refs/remotes/tags/\*$'\`\" && + grep "^trunk:refs/remotes/trunk$" fetch.out && + test -n "`git config --get svn-remote.svn.branches \ + "^branches/\*:refs/remotes/\*$"`" && + test -n "`git config --get svn-remote.svn.tags \ + "^tags/\*:refs/remotes/tags/\*$"`" && git config --unset svn-remote.svn.branches \ - '^branches/\*:refs/remotes/\*$' && + "^branches/\*:refs/remotes/\*$" && git config --unset svn-remote.svn.tags \ - '^tags/\*:refs/remotes/tags/\*$' && - git config --add svn-remote.svn.fetch 'branches/a:refs/remotes/a' && - git config --add svn-remote.svn.fetch 'branches/b:refs/remotes/b' && + "^tags/\*:refs/remotes/tags/\*$" && + git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" && + git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" && for i in tags/0.1 tags/0.2 tags/0.3; do git config --add svn-remote.svn.fetch \ - \$i:refs/remotes/\$i || exit 1; done - " + $i:refs/remotes/$i || exit 1; done + ' # refs should all be different, but the trees should all be the same: test_expect_success 'multi-fetch works on partial urls + paths' " @@ -73,43 +73,43 @@ test_expect_success 'multi-fetch works on partial urls + paths' " refs/remotes/\$j\`\" ||exit 1; done; done " -test_expect_success 'migrate --minimize on old inited layout' " +test_expect_success 'migrate --minimize on old inited layout' ' git config --unset-all svn-remote.svn.fetch && git config --unset-all svn-remote.svn.url && - rm -rf $GIT_DIR/svn && - for i in \`cat fetch.out\`; do - path=\`expr \$i : '\\([^:]*\\):.*$'\` - ref=\`expr \$i : '[^:]*:refs/remotes/\\(.*\\)$'\` - if test -z \"\$ref\"; then continue; fi - if test -n \"\$path\"; then path=\"/\$path\"; fi - ( mkdir -p $GIT_DIR/svn/\$ref/info/ && - echo $svnrepo\$path > $GIT_DIR/svn/\$ref/info/url ) || exit 1; + rm -rf "$GIT_DIR"/svn && + for i in `cat fetch.out`; do + path=`expr $i : "\([^:]*\):.*$"` + ref=`expr $i : "[^:]*:refs/remotes/\(.*\)$"` + if test -z "$ref"; then continue; fi + if test -n "$path"; then path="/$path"; fi + ( mkdir -p "$GIT_DIR"/svn/$ref/info/ && + echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1; done && git-svn migrate --minimize && - test -z \"\`git config -l |grep -v '^svn-remote\.git-svn\.'\`\" && + test -z "`git config -l |grep -v "^svn-remote\.git-svn\."`" && git config --get-all svn-remote.svn.fetch > fetch.out && - grep '^trunk:refs/remotes/trunk$' fetch.out && - grep '^branches/a:refs/remotes/a$' fetch.out && - grep '^branches/b:refs/remotes/b$' fetch.out && - grep '^tags/0\.1:refs/remotes/tags/0\.1$' fetch.out && - grep '^tags/0\.2:refs/remotes/tags/0\.2$' fetch.out && - grep '^tags/0\.3:refs/remotes/tags/0\.3$' fetch.out - grep '^:refs/remotes/git-svn' fetch.out - " + grep "^trunk:refs/remotes/trunk$" fetch.out && + grep "^branches/a:refs/remotes/a$" fetch.out && + grep "^branches/b:refs/remotes/b$" fetch.out && + grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out && + grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out && + grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out + grep "^:refs/remotes/git-svn" fetch.out + ' -test_expect_success ".rev_db auto-converted to .rev_map.UUID" " +test_expect_success ".rev_db auto-converted to .rev_map.UUID" ' git-svn fetch -i trunk && - test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" && - expect=\"\$(ls $GIT_DIR/svn/trunk/.rev_map.*)\" && - test -n \"\$expect\" && - rev_db=\$(echo \$expect | sed -e 's,_map,_db,') && - convert_to_rev_db \$expect \$rev_db && - rm -f \$expect && - test -f \$rev_db && + test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && + expect="$(ls "$GIT_DIR"/svn/trunk/.rev_map.*)" && + test -n "$expect" && + rev_db="$(echo $expect | sed -e "s,_map,_db,")" && + convert_to_rev_db "$expect" "$rev_db" && + rm -f "$expect" && + test -f "$rev_db" && git-svn fetch -i trunk && - test -z \"\$(ls $GIT_DIR/svn/trunk/.rev_db.* 2>/dev/null)\" && - test ! -e $GIT_DIR/svn/trunk/.rev_db && - test -f \$expect - " + test -z "$(ls "$GIT_DIR"/svn/trunk/.rev_db.* 2>/dev/null)" && + test ! -e "$GIT_DIR"/svn/trunk/.rev_db && + test -f "$expect" + ' test_done diff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh index db4344cc84..f6f71d0545 100755 --- a/t/t9108-git-svn-glob.sh +++ b/t/t9108-git-svn-glob.sh @@ -10,77 +10,77 @@ start a new branch initial EOF -test_expect_success 'test refspec globbing' " +test_expect_success 'test refspec globbing' ' mkdir -p trunk/src/a trunk/src/b trunk/doc && - echo 'hello world' > trunk/src/a/readme && - echo 'goodbye world' > trunk/src/b/readme && - svn import -m 'initial' trunk $svnrepo/trunk && - svn co $svnrepo tmp && + echo "hello world" > trunk/src/a/readme && + echo "goodbye world" > trunk/src/b/readme && + svn import -m "initial" trunk "$svnrepo"/trunk && + svn co "$svnrepo" tmp && cd tmp && mkdir branches tags && svn add branches tags && svn cp trunk branches/start && - svn commit -m 'start a new branch' && + svn commit -m "start a new branch" && svn up && - echo 'hi' >> branches/start/src/b/readme && + echo "hi" >> branches/start/src/b/readme && poke branches/start/src/b/readme && - echo 'hey' >> branches/start/src/a/readme && + echo "hey" >> branches/start/src/a/readme && poke branches/start/src/a/readme && - svn commit -m 'hi' && + svn commit -m "hi" && svn up && svn cp branches/start tags/end && - echo 'bye' >> tags/end/src/b/readme && + echo "bye" >> tags/end/src/b/readme && poke tags/end/src/b/readme && - echo 'aye' >> tags/end/src/a/readme && + echo "aye" >> tags/end/src/a/readme && poke tags/end/src/a/readme && - svn commit -m 'the end' && - echo 'byebye' >> tags/end/src/b/readme && + svn commit -m "the end" && + echo "byebye" >> tags/end/src/b/readme && poke tags/end/src/b/readme && - svn commit -m 'nothing to see here' + svn commit -m "nothing to see here" cd .. && - git config --add svn-remote.svn.url $svnrepo && + git config --add svn-remote.svn.url "$svnrepo" && git config --add svn-remote.svn.fetch \ - 'trunk/src/a:refs/remotes/trunk' && + "trunk/src/a:refs/remotes/trunk" && git config --add svn-remote.svn.branches \ - 'branches/*/src/a:refs/remotes/branches/*' && + "branches/*/src/a:refs/remotes/branches/*" && git config --add svn-remote.svn.tags\ - 'tags/*/src/a:refs/remotes/tags/*' && + "tags/*/src/a:refs/remotes/tags/*" && git-svn multi-fetch && git log --pretty=oneline refs/remotes/tags/end | \ - sed -e 's/^.\{41\}//' > output.end && + sed -e "s/^.\{41\}//" > output.end && cmp expect.end output.end && - test \"\`git rev-parse refs/remotes/tags/end~1\`\" = \ - \"\`git rev-parse refs/remotes/branches/start\`\" && - test \"\`git rev-parse refs/remotes/branches/start~2\`\" = \ - \"\`git rev-parse refs/remotes/trunk\`\" - " + test "`git rev-parse refs/remotes/tags/end~1`" = \ + "`git rev-parse refs/remotes/branches/start`" && + test "`git rev-parse refs/remotes/branches/start~2`" = \ + "`git rev-parse refs/remotes/trunk`" + ' echo try to try > expect.two echo nothing to see here >> expect.two cat expect.end >> expect.two -test_expect_success 'test left-hand-side only globbing' " - git config --add svn-remote.two.url $svnrepo && +test_expect_success 'test left-hand-side only globbing' ' + git config --add svn-remote.two.url "$svnrepo" && git config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk && git config --add svn-remote.two.branches \ - 'branches/*:refs/remotes/two/branches/*' && + "branches/*:refs/remotes/two/branches/*" && git config --add svn-remote.two.tags \ - 'tags/*:refs/remotes/two/tags/*' && + "tags/*:refs/remotes/two/tags/*" && cd tmp && - echo 'try try' >> tags/end/src/b/readme && + echo "try try" >> tags/end/src/b/readme && poke tags/end/src/b/readme && - svn commit -m 'try to try' + svn commit -m "try to try" cd .. && git-svn fetch two && - test \`git rev-list refs/remotes/two/tags/end | wc -l\` -eq 6 && - test \`git rev-list refs/remotes/two/branches/start | wc -l\` -eq 3 && - test \`git rev-parse refs/remotes/two/branches/start~2\` = \ - \`git rev-parse refs/remotes/two/trunk\` && - test \`git rev-parse refs/remotes/two/tags/end~3\` = \ - \`git rev-parse refs/remotes/two/branches/start\` && + test `git rev-list refs/remotes/two/tags/end | wc -l` -eq 6 && + test `git rev-list refs/remotes/two/branches/start | wc -l` -eq 3 && + test `git rev-parse refs/remotes/two/branches/start~2` = \ + `git rev-parse refs/remotes/two/trunk` && + test `git rev-parse refs/remotes/two/tags/end~3` = \ + `git rev-parse refs/remotes/two/branches/start` && git log --pretty=oneline refs/remotes/two/tags/end | \ - sed -e 's/^.\{41\}//' > output.two && + sed -e "s/^.\{41\}//" > output.two && cmp expect.two output.two - " + ' test_done diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh index 6235af4db8..047659fde1 100755 --- a/t/t9110-git-svn-use-svm-props.sh +++ b/t/t9110-git-svn-use-svm-props.sh @@ -7,15 +7,15 @@ test_description='git-svn useSvmProps test' . ./lib-git-svn.sh -test_expect_success 'load svm repo' " - svnadmin load -q $rawsvnrepo < ../t9110/svm.dump && - git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr && - git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh && +test_expect_success 'load svm repo' ' + svnadmin load -q "$rawsvnrepo" < ../t9110/svm.dump && + git-svn init --minimize-url -R arr -i bar "$svnrepo"/mirror/arr && + git-svn init --minimize-url -R argh -i dir "$svnrepo"/mirror/argh && git-svn init --minimize-url -R argh -i e \ - $svnrepo/mirror/argh/a/b/c/d/e && + "$svnrepo"/mirror/argh/a/b/c/d/e && git config svn.useSvmProps true && git-svn fetch --all - " + ' uuid=161ce429-a9dd-4828-af4a-52023f968c89 diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh index ec7dedd48b..a8d74dcd3a 100755 --- a/t/t9111-git-svn-use-svnsync-props.sh +++ b/t/t9111-git-svn-use-svnsync-props.sh @@ -7,14 +7,14 @@ test_description='git-svn useSvnsyncProps test' . ./lib-git-svn.sh -test_expect_success 'load svnsync repo' " - svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump && - git-svn init --minimize-url -R arr -i bar $svnrepo/bar && - git-svn init --minimize-url -R argh -i dir $svnrepo/dir && - git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e && +test_expect_success 'load svnsync repo' ' + svnadmin load -q "$rawsvnrepo" < ../t9111/svnsync.dump && + git-svn init --minimize-url -R arr -i bar "$svnrepo"/bar && + git-svn init --minimize-url -R argh -i dir "$svnrepo"/dir && + git-svn init --minimize-url -R argh -i e "$svnrepo"/dir/a/b/c/d/e && git config svn.useSvnsyncProps true && git-svn fetch --all - " + ' uuid=161ce429-a9dd-4828-af4a-52023f968c89 diff --git a/t/t9112-git-svn-md5less-file.sh b/t/t9112-git-svn-md5less-file.sh index 646a5f0cdb..d470a920e4 100755 --- a/t/t9112-git-svn-md5less-file.sh +++ b/t/t9112-git-svn-md5less-file.sh @@ -40,8 +40,8 @@ PROPS-END EOF -test_expect_success 'load svn dumpfile' "svnadmin load $rawsvnrepo < dumpfile.svn" +test_expect_success 'load svn dumpfile' 'svnadmin load "$rawsvnrepo" < dumpfile.svn' -test_expect_success 'initialize git-svn' "git-svn init $svnrepo" +test_expect_success 'initialize git-svn' 'git-svn init "$svnrepo"' test_expect_success 'fetch revisions from svn' 'git-svn fetch' test_done diff --git a/t/t9113-git-svn-dcommit-new-file.sh b/t/t9113-git-svn-dcommit-new-file.sh index 9ef0db9044..31c929b573 100755 --- a/t/t9113-git-svn-dcommit-new-file.sh +++ b/t/t9113-git-svn-dcommit-new-file.sh @@ -15,18 +15,18 @@ test_description='git-svn dcommit new files over svn:// test' start_svnserve () { svnserve --listen-port $SVNSERVE_PORT \ - --root $rawsvnrepo \ + --root "$rawsvnrepo" \ --listen-once \ --listen-host 127.0.0.1 & } -test_expect_success 'start tracking an empty repo' " - svn mkdir -m 'empty dir' $svnrepo/empty-dir && - echo anon-access = write >> $rawsvnrepo/conf/svnserve.conf && +test_expect_success 'start tracking an empty repo' ' + svn mkdir -m "empty dir" "$svnrepo"/empty-dir && + echo anon-access = write >> "$rawsvnrepo"/conf/svnserve.conf && start_svnserve && git svn init svn://127.0.0.1:$SVNSERVE_PORT && git svn fetch - " + ' test_expect_success 'create files in new directory with dcommit' " mkdir git-new-dir && diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index 225060b88b..61d7781616 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -34,35 +34,35 @@ cat << EOF EOF } -test_expect_success 'setup svn repository' " - svn co $svnrepo mysvnwork && +test_expect_success 'setup svn repository' ' + svn co "$svnrepo" mysvnwork && mkdir -p mysvnwork/trunk && cd mysvnwork && big_text_block >> trunk/README && svn add trunk && - svn ci -m 'first commit' trunk && + svn ci -m "first commit" trunk && cd .. - " + ' -test_expect_success 'setup git mirror and merge' " - git svn init $svnrepo -t tags -T trunk -b branches && +test_expect_success 'setup git mirror and merge' ' + git svn init "$svnrepo" -t tags -T trunk -b branches && git svn fetch && git checkout --track -b svn remotes/trunk && git checkout -b merge && echo new file > new_file && git add new_file && - git commit -a -m 'New file' && + git commit -a -m "New file" && echo hello >> README && - git commit -a -m 'hello' && + git commit -a -m "hello" && echo add some stuff >> new_file && - git commit -a -m 'add some stuff' && + git commit -a -m "add some stuff" && git checkout svn && mv -f README tmp && echo friend > README && cat tmp >> README && - git commit -a -m 'friend' && + git commit -a -m "friend" && git pull . merge - " + ' test_debug 'gitk --all & sleep 1' diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh index 182299cbb5..f0fbd3aff7 100755 --- a/t/t9115-git-svn-dcommit-funky-renames.sh +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@ -7,16 +7,16 @@ test_description='git-svn dcommit can commit renames of files with ugly names' . ./lib-git-svn.sh -test_expect_success 'load repository with strange names' " - svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump && - start_httpd - " +test_expect_success 'load repository with strange names' ' + svnadmin load -q "$rawsvnrepo" < ../t9115/funky-names.dump && + start_httpd gtk+ + ' -test_expect_success 'init and fetch repository' " - git svn init $svnrepo && +test_expect_success 'init and fetch repository' ' + git svn init "$svnrepo" && git svn fetch && git reset --hard git-svn - " + ' test_expect_success 'create file in existing ugly and empty dir' ' mkdir "#{bad_directory_name}" && @@ -49,6 +49,39 @@ test_expect_success 'rename pretty file into ugly one' ' git svn dcommit ' +test_expect_success 'add a file with plus signs' ' + echo .. > +_+ && + git update-index --add +_+ && + git commit -m plus && + mkdir gtk+ && + git mv +_+ gtk+/_+_ && + git commit -m plus_dir && + git svn dcommit + ' + +test_expect_success 'clone the repository to test rebase' ' + git svn clone "$svnrepo" test-rebase && + cd test-rebase && + echo test-rebase > test-rebase && + git add test-rebase && + git commit -m test-rebase && + cd .. + ' + +test_expect_success 'make a commit to test rebase' ' + echo test-rebase-main > test-rebase-main && + git add test-rebase-main && + git commit -m test-rebase-main && + git svn dcommit + ' + +test_expect_success 'git-svn rebase works inside a fresh-cloned repository' ' + cd test-rebase && + git svn rebase && + test -e test-rebase-main && + test -e test-rebase + ' + stop_httpd test_done diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh index e1e8bdf0e3..4b2cc878f6 100755 --- a/t/t9116-git-svn-log.sh +++ b/t/t9116-git-svn-log.sh @@ -6,17 +6,17 @@ test_description='git-svn log tests' . ./lib-git-svn.sh -test_expect_success 'setup repository and import' " +test_expect_success 'setup repository and import' ' mkdir import && cd import && for i in trunk branches/a branches/b \ tags/0.1 tags/0.2 tags/0.3; do - mkdir -p \$i && \ - echo hello >> \$i/README || exit 1 + mkdir -p $i && \ + echo hello >> $i/README || exit 1 done && \ - svn import -m test . $svnrepo + svn import -m test . "$svnrepo" cd .. && - git-svn init $svnrepo -T trunk -b branches -t tags && + git-svn init "$svnrepo" -T trunk -b branches -t tags && git-svn fetch && git reset --hard trunk && echo bye >> README && @@ -37,7 +37,7 @@ test_expect_success 'setup repository and import' " echo try >> README && git commit -a -m try && git svn dcommit - " + ' test_expect_success 'run log' " git reset --hard a && diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh index d482b407f2..7a689bb1cd 100755 --- a/t/t9117-git-svn-init-clone.sh +++ b/t/t9117-git-svn-init-clone.sh @@ -13,43 +13,43 @@ rm -r .git mkdir tmp cd tmp -test_expect_success 'setup svnrepo' " +test_expect_success 'setup svnrepo' ' mkdir project project/trunk project/branches project/tags && echo foo > project/trunk/foo && - svn import -m '$test_description' project $svnrepo/project && + svn import -m "$test_description" project "$svnrepo"/project && rm -rf project - " + ' -test_expect_success 'basic clone' " +test_expect_success 'basic clone' ' test ! -d trunk && - git svn clone $svnrepo/project/trunk && + git svn clone "$svnrepo"/project/trunk && test -d trunk/.git/svn && test -e trunk/foo && rm -rf trunk - " + ' -test_expect_success 'clone to target directory' " +test_expect_success 'clone to target directory' ' test ! -d target && - git svn clone $svnrepo/project/trunk target && + git svn clone "$svnrepo"/project/trunk target && test -d target/.git/svn && test -e target/foo && rm -rf target - " + ' -test_expect_success 'clone with --stdlayout' " +test_expect_success 'clone with --stdlayout' ' test ! -d project && - git svn clone -s $svnrepo/project && + git svn clone -s "$svnrepo"/project && test -d project/.git/svn && test -e project/foo && rm -rf project - " + ' -test_expect_success 'clone to target directory with --stdlayout' " +test_expect_success 'clone to target directory with --stdlayout' ' test ! -d target && - git svn clone -s $svnrepo/project target && + git svn clone -s "$svnrepo"/project target && test -d target/.git/svn && test -e target/foo && rm -rf target - " + ' test_done diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh index 640bb066f3..3281cbd347 100755 --- a/t/t9118-git-svn-funky-branch-names.sh +++ b/t/t9118-git-svn-funky-branch-names.sh @@ -6,25 +6,25 @@ test_description='git-svn funky branch names' . ./lib-git-svn.sh -test_expect_success 'setup svnrepo' " +test_expect_success 'setup svnrepo' ' mkdir project project/trunk project/branches project/tags && echo foo > project/trunk/foo && - svn import -m '$test_description' project \"$svnrepo/pr ject\" && + svn import -m "$test_description" project "$svnrepo/pr ject" && rm -rf project && - svn cp -m 'fun' \"$svnrepo/pr ject/trunk\" \ - \"$svnrepo/pr ject/branches/fun plugin\" && - svn cp -m 'more fun!' \"$svnrepo/pr ject/branches/fun plugin\" \ - \"$svnrepo/pr ject/branches/more fun plugin!\" && + svn cp -m "fun" "$svnrepo/pr ject/trunk" \ + "$svnrepo/pr ject/branches/fun plugin" && + svn cp -m "more fun!" "$svnrepo/pr ject/branches/fun plugin" \ + "$svnrepo/pr ject/branches/more fun plugin!" && start_httpd - " + ' -test_expect_success 'test clone with funky branch names' " - git svn clone -s \"$svnrepo/pr ject\" project && +test_expect_success 'test clone with funky branch names' ' + git svn clone -s "$svnrepo/pr ject" project && cd project && - git rev-parse 'refs/remotes/fun%20plugin' && - git rev-parse 'refs/remotes/more%20fun%20plugin!' && + git rev-parse "refs/remotes/fun%20plugin" && + git rev-parse "refs/remotes/more%20fun%20plugin!" && cd .. - " + ' test_expect_success 'test dcommit to funky branch' " cd project && diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh index 9a4eabe523..5979e133b9 100755 --- a/t/t9120-git-svn-clone-with-percent-escapes.sh +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh @@ -6,13 +6,13 @@ test_description='git-svn clone with percent escapes' . ./lib-git-svn.sh -test_expect_success 'setup svnrepo' " +test_expect_success 'setup svnrepo' ' mkdir project project/trunk project/branches project/tags && echo foo > project/trunk/foo && - svn import -m '$test_description' project '$svnrepo/pr ject' && + svn import -m "$test_description" project "$svnrepo/pr ject" && rm -rf project && start_httpd -" +' if test "$SVN_HTTPD_PORT" = "" then diff --git a/t/t9121-git-svn-fetch-renamed-dir.sh b/t/t9121-git-svn-fetch-renamed-dir.sh index 5143ed6066..99230b0810 100755 --- a/t/t9121-git-svn-fetch-renamed-dir.sh +++ b/t/t9121-git-svn-fetch-renamed-dir.sh @@ -7,14 +7,14 @@ test_description='git-svn can fetch renamed directories' . ./lib-git-svn.sh -test_expect_success 'load repository with renamed directory' " - svnadmin load -q $rawsvnrepo < ../t9121/renamed-dir.dump - " +test_expect_success 'load repository with renamed directory' ' + svnadmin load -q "$rawsvnrepo" < ../t9121/renamed-dir.dump + ' -test_expect_success 'init and fetch repository' " - git svn init $svnrepo/newname && +test_expect_success 'init and fetch repository' ' + git svn init "$svnrepo/newname" && git svn fetch - " + ' test_done diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index 166b43f783..e97aaa6c2a 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -153,21 +153,21 @@ test_expect_success 'req_Root failure (conflicting roots)' \ tail log | grep "^error 1 Conflicting roots specified$"' test_expect_success 'req_Root (strict paths)' \ - 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 && + 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 && sed -ne \$p log | grep "^I LOVE YOU$"' test_expect_success 'req_Root failure (strict-paths)' ' ! cat request-anonymous | - git-cvsserver --strict-paths pserver $WORKDIR >log 2>&1 + git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1 ' test_expect_success 'req_Root (w/o strict-paths)' \ - 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 && + 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 && sed -ne \$p log | grep "^I LOVE YOU$"' test_expect_success 'req_Root failure (w/o strict-paths)' ' ! cat request-anonymous | - git-cvsserver pserver $WORKDIR/gitcvs >log 2>&1 + git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1 ' cat >request-base <<EOF @@ -180,25 +180,25 @@ Root /gitcvs.git EOF test_expect_success 'req_Root (base-path)' \ - 'cat request-base | git-cvsserver --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && + 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && sed -ne \$p log | grep "^I LOVE YOU$"' test_expect_success 'req_Root failure (base-path)' ' ! cat request-anonymous | - git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1 + git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1 ' 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 && + 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 && 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 && + '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$"' GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index 061a2596d3..ae7082be1d 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -10,6 +10,7 @@ commandline, and checks that it would not write any errors or warnings to log.' gitweb_init () { + safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')" cat >gitweb_config.perl <<EOF #!/usr/bin/perl @@ -17,16 +18,16 @@ gitweb_init () { our \$version = "current"; our \$GIT = "git"; -our \$projectroot = "$(pwd)"; +our \$projectroot = "$safe_pwd"; our \$project_maxdepth = 8; our \$home_link_str = "projects"; our \$site_name = "[localhost]"; our \$site_header = ""; our \$site_footer = ""; our \$home_text = "indextext.html"; -our @stylesheets = ("file:///$(pwd)/../../gitweb/gitweb.css"); -our \$logo = "file:///$(pwd)/../../gitweb/git-logo.png"; -our \$favicon = "file:///$(pwd)/../../gitweb/git-favicon.png"; +our @stylesheets = ("file:///$safe_pwd/../../gitweb/gitweb.css"); +our \$logo = "file:///$safe_pwd/../../gitweb/git-logo.png"; +our \$favicon = "file:///$safe_pwd/../../gitweb/git-favicon.png"; our \$projects_list = ""; our \$export_ok = ""; our \$strict_export = ""; @@ -39,19 +40,21 @@ EOF } gitweb_run () { - export GATEWAY_INTERFACE="CGI/1.1" - export HTTP_ACCEPT="*/*" - export REQUEST_METHOD="GET" - export QUERY_STRING=""$1"" - export PATH_INFO=""$2"" + GATEWAY_INTERFACE="CGI/1.1" + HTTP_ACCEPT="*/*" + REQUEST_METHOD="GET" + QUERY_STRING=""$1"" + PATH_INFO=""$2"" + export GATEWAY_INTERFACE HTTP_ACCEPT REQUEST_METHOD QUERY_STRING PATH_INFO - export GITWEB_CONFIG=$(pwd)/gitweb_config.perl + GITWEB_CONFIG=$(pwd)/gitweb_config.perl + export GITWEB_CONFIG # some of git commands write to STDERR on error, but this is not # written to web server logs, so we are not interested in that: # we are interested only in properly formatted errors/warnings rm -f gitweb.log && - perl -- $(pwd)/../../gitweb/gitweb.perl \ + perl -- "$(pwd)/../../gitweb/gitweb.perl" \ >/dev/null 2>gitweb.log && if grep -q -s "^[[]" gitweb.log >/dev/null; then false; else true; fi diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index 00a74ee738..0b115a17ab 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -36,7 +36,7 @@ test_expect_success 'setup cvsroot' 'cvs init' test_expect_success 'setup a cvs module' ' - mkdir $CVSROOT/module && + mkdir "$CVSROOT/module" && cvs co -d module-cvs module && cd module-cvs && cat <<EOF >o_fortuna && diff --git a/t/test-lib.sh b/t/test-lib.sh index 7c2a8ba77d..5002fb04b5 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -160,6 +160,22 @@ die () { trap 'die' exit +# The semantics of the editor variables are that of invoking +# sh -c "$EDITOR \"$@\"" files ... +# +# If our trash directory contains shell metacharacters, they will be +# interpreted if we just set $EDITOR directly, so do a little dance with +# environment variables to work around this. +# +# In particular, quoting isn't enough, as the path may contain the same quote +# that we're using. +test_set_editor () { + FAKE_EDITOR="$1" + export FAKE_EDITOR + VISUAL='"$FAKE_EDITOR"' + export VISUAL +} + test_tick () { if test -z "${test_tick+set}" then @@ -329,7 +345,7 @@ test_create_repo () { repo="$1" mkdir "$repo" cd "$repo" || error "Cannot setup test environment" - "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 || + "$GIT_EXEC_PATH/git" init "--template=$GIT_EXEC_PATH/templates/blt/" >/dev/null 2>&1 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled cd "$owd" @@ -395,14 +411,14 @@ fi . ../GIT-BUILD-OPTIONS # Test repository -test=trash +test="trash directory" rm -fr "$test" || { trap - exit echo >&5 "FATAL: Cannot prepare test area" exit 1 } -test_create_repo $test +test_create_repo "$test" cd "$test" this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$') |