From fd4ec4f2bb980ce07bb28d5823a95610f251d00b Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Mon, 6 Sep 2010 20:39:54 +0200 Subject: [PATCH 1/7] Several tests: cd inside subshell instead of around Fixed all places where it was a straightforward change from cd'ing into a directory and back via "cd .." to a cd inside a subshell. Found these places with "git grep -w "cd \.\.". Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 6 +- t/t1302-repo-version.sh | 6 +- t/t2101-update-index-reupdate.sh | 6 +- t/t3060-ls-files-with-tree.sh | 4 +- t/t3409-rebase-preserve-merges.sh | 12 +- t/t3903-stash.sh | 6 +- t/t4041-diff-submodule-option.sh | 6 +- t/t5510-fetch.sh | 18 +-- t/t6050-replace.sh | 22 +-- t/t7400-submodule-basic.sh | 6 +- t/t7401-submodule-summary.sh | 6 +- t/t9100-git-svn-basic.sh | 6 +- t/t9101-git-svn-props.sh | 16 +-- t/t9102-git-svn-deep-rmdir.sh | 6 +- t/t9104-git-svn-follow-parent.sh | 30 ++--- t/t9105-git-svn-commit-diff.sh | 6 +- t/t9106-git-svn-commit-diff-clobber.sh | 24 ++-- t/t9107-git-svn-migrate.sh | 4 +- t/t9114-git-svn-dcommit-merge.sh | 6 +- t/t9115-git-svn-dcommit-funky-renames.sh | 6 +- t/t9116-git-svn-log.sh | 4 +- t/t9119-git-svn-info.sh | 126 +++++++++--------- t/t9120-git-svn-clone-with-percent-escapes.sh | 6 +- t/t9123-git-svn-rebuild-with-rewriteroot.sh | 4 +- t/t9125-git-svn-multi-glob-branch-names.sh | 12 +- t/t9127-git-svn-partial-rebuild.sh | 30 ++--- t/t9128-git-svn-cmd-branch.sh | 18 +-- t/t9137-git-svn-dcommit-clobber-series.sh | 12 +- t/t9300-fast-import.sh | 5 +- t/t9401-git-cvsserver-crlf.sh | 53 ++++---- t/t9600-cvsimport.sh | 38 +++--- t/t9603-cvsimport-patchsets.sh | 6 +- 32 files changed, 256 insertions(+), 260 deletions(-) diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 56874996a6..c36157a896 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' ' one) echo pass one ;; *) echo bad one; exit 1 ;; esac && - cd dir && + (cd dir && git update-index --add two && case "`git ls-files`" in two) echo pass two ;; *) echo bad two; exit 1 ;; - esac && - cd .. && + esac + ) && case "`git ls-files`" in dir/two"$LF"one) echo pass both ;; *) echo bad; exit 1 ;; diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index 8d305b4372..c948719931 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -32,9 +32,9 @@ test_expect_success 'gitdir selection on unsupported repo' ' test "$(git config core.repositoryformatversion)" = 99)' test_expect_success 'gitdir not required mode' ' - (git apply --stat test.patch && - cd test && git apply --stat ../test.patch && - cd ../test2 && git apply --stat ../test.patch)' + git apply --stat test.patch && + (cd test && git apply --stat ../test.patch) && + (cd test2 && git apply --stat ../test.patch)' test_expect_success 'gitdir required mode on normal repos' ' (git apply --check --index test.patch && diff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh index 648184fd98..76ad7c344c 100755 --- a/t/t2101-update-index-reupdate.sh +++ b/t/t2101-update-index-reupdate.sh @@ -63,10 +63,10 @@ cat > expected <<\EOF EOF test_expect_success 'update-index --update from subdir' \ 'echo not so happy >file2 && - cd dir1 && + (cd dir1 && cat ../file2 >file3 && - git update-index --again && - cd .. && + git update-index --again + ) && git ls-files -s >current && cmp current expected' diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh index 3ce501bb97..25afb4faeb 100755 --- a/t/t3060-ls-files-with-tree.sh +++ b/t/t3060-ls-files-with-tree.sh @@ -55,15 +55,13 @@ test_expect_success setup ' # We have to run from a sub-directory to trigger prune_path # Then we finally get to run our --with-tree test -cd sub test_expect_success 'git -ls-files --with-tree should succeed from subdir' ' - git ls-files --with-tree=HEAD~1 >../output + (cd sub && git ls-files --with-tree=HEAD~1 >../output) ' -cd .. test_expect_success \ 'git -ls-files --with-tree should add entries from named tree.' \ 'test_cmp expected output' diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 8f785e7957..1a362d231a 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -42,23 +42,23 @@ test_expect_success 'setup for merge-preserving rebase' \ git commit -a -m "Modify A2" && git clone ./. clone1 && - cd clone1 && + (cd clone1 && git checkout -b topic origin/topic && - git merge origin/master && - cd .. && + git merge origin/master + ) && echo Fifth > B && git add B && git commit -m "Add different B" && git clone ./. clone2 && - cd clone2 && + (cd clone2 && git checkout -b topic origin/topic && test_must_fail git merge origin/master && echo Resolved > B && git add B && - git commit -m "Merge origin/master into topic" && - cd .. && + git commit -m "Merge origin/master into topic" + ) && git checkout topic && echo Fourth >> B && diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 62e208aadd..3f430122c2 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -69,9 +69,9 @@ test_expect_success 'apply stashed changes (including index)' ' test_expect_success 'unstashing in a subdirectory' ' git reset --hard HEAD && mkdir subdir && - cd subdir && - git stash apply && - cd .. + (cd subdir && + git stash apply + ) ' test_expect_success 'drop top stash' ' diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 8e391cf9a7..737c3d93ff 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -85,10 +85,10 @@ EOF " commit_file sm1 && -cd sm1 && +head3=$(cd sm1 && git reset --hard HEAD~2 >/dev/null && -head3=$(git rev-parse --verify HEAD | cut -c1-7) && -cd .. +git rev-parse --verify HEAD | cut -c1-7 +) test_expect_success 'modified submodule(backward)' " git diff-index -p --submodule=log HEAD >actual && diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 4eb10f602f..34d59d5766 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -21,18 +21,18 @@ test_expect_success setup ' test_expect_success "clone and setup child repos" ' git clone . one && - cd one && + (cd one && echo >file updated by one && - git commit -a -m "updated by one" && - cd .. && + git commit -a -m "updated by one" + ) && git clone . two && - cd two && + (cd two && git config branch.master.remote one && git config remote.one.url ../one/.git/ && - git config remote.one.fetch refs/heads/master:refs/heads/one && - cd .. && + git config remote.one.fetch refs/heads/master:refs/heads/one + ) && git clone . three && - cd three && + (cd three && git config branch.master.remote two && git config branch.master.merge refs/heads/one && mkdir -p .git/remotes && @@ -40,8 +40,8 @@ test_expect_success "clone and setup child repos" ' echo "URL: ../two/.git/" echo "Pull: refs/heads/master:refs/heads/two" echo "Pull: refs/heads/one:refs/heads/one" - } >.git/remotes/two && - cd .. && + } >.git/remotes/two + ) && git clone . bundle && git clone . seven ' diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index 4185b7ca1d..01dfa51f09 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -104,7 +104,7 @@ test_expect_success '"git fsck" works' ' test_expect_success 'repack, clone and fetch work' ' git repack -a -d && git clone --no-hardlinks . clone_dir && - cd clone_dir && + (cd clone_dir && git show HEAD~5 | grep "A U Thor" && git show $HASH2 | grep "A U Thor" && git cat-file commit $R && @@ -113,8 +113,8 @@ test_expect_success 'repack, clone and fetch work' ' git fetch ../ "refs/replace/*:refs/replace/*" && git show HEAD~5 | grep "O Thor" && git show $HASH2 | grep "O Thor" && - git cat-file commit $R && - cd .. + git cat-file commit $R + ) ' test_expect_success '"git replace" listing and deleting' ' @@ -177,10 +177,10 @@ test_expect_success 'create parallel branch without the bug' ' test_expect_success 'push to cloned repo' ' git push cloned $HASH6^:refs/heads/parallel && - cd clone_dir && + (cd clone_dir && git checkout parallel && - git log --pretty=oneline | grep $PARA2 && - cd .. + git log --pretty=oneline | grep $PARA2 + ) ' test_expect_success 'push branch with replacement' ' @@ -191,20 +191,20 @@ test_expect_success 'push branch with replacement' ' git show $HASH6~2 | grep "O Thor" && git show $PARA3 | grep "O Thor" && git push cloned $HASH6^:refs/heads/parallel2 && - cd clone_dir && + (cd clone_dir && git checkout parallel2 && git log --pretty=oneline | grep $PARA3 && - git show $PARA3 | grep "A U Thor" && - cd .. + git show $PARA3 | grep "A U Thor" + ) ' test_expect_success 'fetch branch with replacement' ' git branch tofetch $HASH6 && - cd clone_dir && + (cd clone_dir && git fetch origin refs/heads/tofetch:refs/heads/parallel3 git log --pretty=oneline parallel3 | grep $PARA3 git show $PARA3 | grep "A U Thor" - cd .. + ) ' test_expect_success 'bisect and replacements' ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 9bda970584..21b08395ce 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -413,12 +413,12 @@ test_expect_success 'submodule warns' ' test_expect_success 'add submodules without specifying an explicit path' ' mkdir repo && - cd repo && + (cd repo && git init && echo r >r && git add r && - git commit -m "repo commit 1" && - cd .. && + git commit -m "repo commit 1" + ) && git clone --bare repo/ bare.git && cd addtest && git submodule add "$submodurl/repo" && diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index cee319da0a..b5ad45f447 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -66,10 +66,10 @@ EOF " commit_file sm1 && -cd sm1 && +head3=$(cd sm1 && git reset --hard HEAD~2 >/dev/null && -head3=$(git rev-parse --verify HEAD | cut -c1-7) && -cd .. +git rev-parse --verify HEAD | cut -c1-7 +) test_expect_success 'modified submodule(backward)' " git submodule summary >actual && diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 13766ab160..75388f3f07 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -22,7 +22,7 @@ esac test_expect_success \ 'initialize git svn' ' mkdir import && - cd import && + (cd import && echo foo > foo && ln -s foo foo.link mkdir -p dir/a/b/c/d/e && @@ -31,8 +31,8 @@ test_expect_success \ echo "zzz" > bar/zzz && echo "#!/bin/sh" > exec.sh && chmod +x exec.sh && - svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null && - cd .. && + svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null + ) && rm -rf import && git svn init "$svnrepo"' diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index 929499e996..f53a1a9ea6 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -54,7 +54,7 @@ cd .. rm -rf import test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc' test_expect_success 'setup some commits to svn' \ - 'cd test_wc && + '(cd test_wc && echo Greetings >> kw.c && poke kw.c && svn_cmd commit -m "Not yet an Id" && @@ -63,8 +63,8 @@ test_expect_success 'setup some commits to svn' \ svn_cmd commit -m "Modified file, but still not yet an Id" && svn_cmd propset svn:keywords Id kw.c && poke kw.c && - svn_cmd commit -m "Propset Id" && - cd ..' + svn_cmd commit -m "Propset Id" + )' test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' test_expect_success 'fetch revisions from svn' 'git svn fetch' @@ -82,12 +82,12 @@ got="`sed -ne 2p kw.c`" test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" test_expect_success "propset CR on crlf files" \ - 'cd test_wc && + '(cd test_wc && svn_cmd propset svn:eol-style CR empty && svn_cmd propset svn:eol-style CR crlf && svn_cmd propset svn:eol-style CR ne_crlf && - svn_cmd commit -m "propset CR on crlf files" && - cd ..' + svn_cmd commit -m "propset CR on crlf files" + )' test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ 'git svn fetch && @@ -137,7 +137,7 @@ cat > show-ignore.expect <<\EOF EOF test_expect_success 'test show-ignore' " - cd test_wc && + (cd test_wc && mkdir -p deeply/nested/directory && touch deeply/nested/directory/.keep && svn_cmd add deeply && @@ -146,7 +146,7 @@ test_expect_success 'test show-ignore' " no-such-file* ' . svn_cmd commit -m 'propset svn:ignore' - cd .. && + ) && git svn show-ignore > show-ignore.got && cmp show-ignore.expect show-ignore.got " diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index 028fb19e09..d60a8efac2 100755 --- a/t/t9102-git-svn-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh @@ -4,13 +4,13 @@ test_description='git svn rmdir' test_expect_success 'initialize repo' ' mkdir import && - cd 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_cmd import -m "import for git svn" . "$svnrepo" && - cd .. + svn_cmd import -m "import for git svn" . "$svnrepo" + ) ' test_expect_success 'mirror via git svn' ' diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index bbfd7f4793..236e7de9a9 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -8,13 +8,13 @@ test_description='git svn fetching' test_expect_success 'initialize repo' ' mkdir import && - cd import && + (cd import && mkdir -p trunk && echo hello > trunk/readme && - svn_cmd import -m "initial" . "$svnrepo" && - cd .. && + svn_cmd import -m "initial" . "$svnrepo" + ) && svn_cmd co "$svnrepo" wc && - cd wc && + (cd wc && echo world >> trunk/readme && poke trunk/readme && svn_cmd commit -m "another commit" && @@ -22,8 +22,8 @@ test_expect_success 'initialize repo' ' svn_cmd mv trunk thunk && echo goodbye >> thunk/readme && poke thunk/readme && - svn_cmd commit -m "bye now" && - cd .. + svn_cmd commit -m "bye now" + ) ' test_expect_success 'init and fetch a moved directory' ' @@ -85,11 +85,11 @@ test_expect_success 'follow larger parent' ' test_expect_success 'follow higher-level parent' ' svn mkdir -m "follow higher-level parent" "$svnrepo"/blob && svn co "$svnrepo"/blob blob && - cd blob && + (cd blob && echo hi > hi && svn add hi && - svn commit -m "hihi" && - cd .. + svn commit -m "hihi" + ) && 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 && @@ -117,18 +117,18 @@ test_expect_success 'follow-parent avoids deleting relevant info' ' import/trunk/subversion/bindings/swig/perl/t/larger-parent && echo "bad delete test 2" > \ import/trunk/subversion/bindings/swig/perl/another-larger && - cd import && - svn import -m "r9270 test" . "$svnrepo"/r9270 && - cd .. && + (cd import && + svn import -m "r9270 test" . "$svnrepo"/r9270 + ) && svn_cmd co "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl r9270 && - cd 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 && echo z >> native/t/c.t && poke native/t/c.t && - svn commit -m "reorg test" && - cd .. && + svn commit -m "reorg test" + ) && git svn init --minimize-url -i r9270-t \ "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && git svn fetch -i r9270-t && diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index dd48e9cba8..d432d835ae 100755 --- a/t/t9105-git-svn-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh @@ -6,10 +6,10 @@ test_description='git svn commit-diff' test_expect_success 'initialize repo' ' mkdir import && - cd import && + (cd import && echo hello > readme && - svn_cmd import -m "initial" . "$svnrepo" && - cd .. && + svn_cmd import -m "initial" . "$svnrepo" + ) && echo hello > readme && git update-index --add readme && git commit -a -m "initial" && diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh index 12f21b700e..af367a1814 100755 --- a/t/t9106-git-svn-commit-diff-clobber.sh +++ b/t/t9106-git-svn-commit-diff-clobber.sh @@ -6,21 +6,21 @@ test_description='git svn commit-diff clobber' test_expect_success 'initialize repo' ' mkdir import && - cd import && + (cd import && echo initial > file && - svn_cmd import -m "initial" . "$svnrepo" && - cd .. && + svn_cmd import -m "initial" . "$svnrepo" + ) && echo initial > file && git update-index --add file && git commit -a -m "initial" ' test_expect_success 'commit change from svn side' ' svn_cmd co "$svnrepo" t.svn && - cd t.svn && + (cd t.svn && echo second line from svn >> file && poke file && - svn_cmd commit -m "second line from svn" && - cd .. && + svn_cmd commit -m "second line from svn" + ) && rm -rf t.svn ' @@ -44,11 +44,11 @@ test_expect_success 'dcommit fails to commit because of conflict' ' git svn fetch && git reset --hard refs/${remotes_git_svn} && svn_cmd co "$svnrepo" t.svn && - cd t.svn && + (cd t.svn && echo fourth line from svn >> file && poke file && - svn_cmd commit -m "fourth line from svn" && - cd .. && + svn_cmd commit -m "fourth line from svn" + ) && rm -rf t.svn && echo "fourth line from git" >> file && git commit -a -m "fourth line from git" && @@ -68,11 +68,11 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' " test_expect_success 'commit another change from svn side' ' svn_cmd co "$svnrepo" t.svn && - cd t.svn && + (cd t.svn && echo third line from svn >> file && poke file && - svn_cmd commit -m "third line from svn" && - cd .. && + svn_cmd commit -m "third line from svn" + ) && rm -rf t.svn ' diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index 901b8e09fb..f60b30699b 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -6,14 +6,14 @@ test_description='git svn metadata migrations from previous versions' test_expect_success 'setup old-looking metadata' ' cp "$GIT_DIR"/config "$GIT_DIR"/config-old-git-svn && mkdir import && - cd 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 done && \ svn_cmd import -m test . "$svnrepo" - cd .. && + ) && git svn init "$svnrepo" && git svn fetch && rm -rf "$GIT_DIR"/svn && diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index 84f7c9b4bb..a7d0c7d99e 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -37,11 +37,11 @@ EOF test_expect_success 'setup svn repository' ' svn_cmd co "$svnrepo" mysvnwork && mkdir -p mysvnwork/trunk && - cd mysvnwork && + (cd mysvnwork && big_text_block >> trunk/README && svn_cmd add trunk && - svn_cmd ci -m "first commit" trunk && - cd .. + svn_cmd ci -m "first commit" trunk + ) ' test_expect_success 'setup git mirror and merge' ' diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh index 767799e7a7..9fdbc9bc95 100755 --- a/t/t9115-git-svn-dcommit-funky-renames.sh +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@ -61,11 +61,11 @@ test_expect_success 'add a file with plus signs' ' test_expect_success 'clone the repository to test rebase' ' git svn clone "$svnrepo" test-rebase && - cd test-rebase && + (cd test-rebase && echo test-rebase > test-rebase && git add test-rebase && - git commit -m test-rebase && - cd .. + git commit -m test-rebase + ) ' test_expect_success 'make a commit to test rebase' ' diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh index 0374a7476b..244b5cd3cf 100755 --- a/t/t9116-git-svn-log.sh +++ b/t/t9116-git-svn-log.sh @@ -8,14 +8,14 @@ test_description='git svn log tests' test_expect_success 'setup repository and import' ' mkdir import && - cd 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 done && \ svn_cmd import -m test . "$svnrepo" - cd .. && + ) && git svn init "$svnrepo" -T trunk -b branches -t tags && git svn fetch && git reset --hard trunk && diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh index 5fb94fb3d6..e3f08c448e 100755 --- a/t/t9119-git-svn-info.sh +++ b/t/t9119-git-svn-info.sh @@ -39,27 +39,27 @@ quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')" test_expect_success 'setup repository and import' ' mkdir info && - cd info && + (cd info && echo FIRST > A && echo one > file && ln -s file symlink-file && mkdir directory && touch directory/.placeholder && ln -s directory symlink-directory && - svn_cmd import -m "initial" . "$svnrepo" && - cd .. && + svn_cmd import -m "initial" . "$svnrepo" + ) && svn_cmd co "$svnrepo" svnwc && - cd svnwc && + (cd svnwc && echo foo > foo && svn_cmd add foo && svn_cmd commit -m "change outside directory" && - svn_cmd update && - cd .. && + svn_cmd update + ) && mkdir gitwc && - cd gitwc && + (cd gitwc && git svn init "$svnrepo" && - git svn fetch && - cd .. && + git svn fetch + ) && ptouch gitwc/file svnwc/file && ptouch gitwc/directory svnwc/directory && ptouch gitwc/symlink-file svnwc/symlink-file && @@ -138,14 +138,14 @@ test_expect_success 'info --url symlink-directory' ' test_expect_success 'info added-file' " echo two > gitwc/added-file && - cd gitwc && - git add added-file && - cd .. && + (cd gitwc && + git add added-file + ) && cp gitwc/added-file svnwc/added-file && ptouch gitwc/added-file svnwc/added-file && - cd svnwc && - svn_cmd add added-file > /dev/null && - cd .. && + (cd svnwc && + svn_cmd add added-file > /dev/null + ) && (cd svnwc; svn info added-file) > expected.info-added-file && (cd gitwc; git svn info added-file) > actual.info-added-file && test_cmp expected.info-added-file actual.info-added-file @@ -160,12 +160,12 @@ test_expect_success 'info added-directory' " mkdir gitwc/added-directory svnwc/added-directory && ptouch gitwc/added-directory svnwc/added-directory && touch gitwc/added-directory/.placeholder && - cd svnwc && - svn_cmd add added-directory > /dev/null && - cd .. && - cd gitwc && - git add added-directory && - cd .. && + (cd svnwc && + svn_cmd add added-directory > /dev/null + ) && + (cd gitwc && + git add added-directory + ) && (cd svnwc; svn info added-directory) \ > expected.info-added-directory && (cd gitwc; git svn info added-directory) \ @@ -179,14 +179,14 @@ test_expect_success 'info --url added-directory' ' ' test_expect_success 'info added-symlink-file' " - cd gitwc && + (cd gitwc && ln -s added-file added-symlink-file && - git add added-symlink-file && - cd .. && - cd svnwc && + git add added-symlink-file + ) && + (cd svnwc && ln -s added-file added-symlink-file && - svn_cmd add added-symlink-file > /dev/null && - cd .. && + svn_cmd add added-symlink-file > /dev/null + ) && ptouch gitwc/added-symlink-file svnwc/added-symlink-file && (cd svnwc; svn info added-symlink-file) \ > expected.info-added-symlink-file && @@ -202,14 +202,14 @@ test_expect_success 'info --url added-symlink-file' ' ' test_expect_success 'info added-symlink-directory' " - cd gitwc && + (cd gitwc && ln -s added-directory added-symlink-directory && - git add added-symlink-directory && - cd .. && - cd svnwc && + git add added-symlink-directory + ) && + (cd svnwc && ln -s added-directory added-symlink-directory && - svn_cmd add added-symlink-directory > /dev/null && - cd .. && + svn_cmd add added-symlink-directory > /dev/null + ) && ptouch gitwc/added-symlink-directory svnwc/added-symlink-directory && (cd svnwc; svn info added-symlink-directory) \ > expected.info-added-symlink-directory && @@ -230,12 +230,12 @@ test_expect_success 'info --url added-symlink-directory' ' # simply reuses the Last Changed Date. test_expect_success 'info deleted-file' " - cd gitwc && - git rm -f file > /dev/null && - cd .. && - cd svnwc && - svn_cmd rm --force file > /dev/null && - cd .. && + (cd gitwc && + git rm -f file > /dev/null + ) && + (cd svnwc && + svn_cmd rm --force file > /dev/null + ) && (cd svnwc; svn info file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-file && @@ -251,12 +251,12 @@ test_expect_success 'info --url file (deleted)' ' ' test_expect_success 'info deleted-directory' " - cd gitwc && - git rm -r -f directory > /dev/null && - cd .. && - cd svnwc && - svn_cmd rm --force directory > /dev/null && - cd .. && + (cd gitwc && + git rm -r -f directory > /dev/null + ) && + (cd svnwc && + svn_cmd rm --force directory > /dev/null + ) && (cd svnwc; svn info directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-directory && @@ -272,12 +272,12 @@ test_expect_success 'info --url directory (deleted)' ' ' test_expect_success 'info deleted-symlink-file' " - cd gitwc && - git rm -f symlink-file > /dev/null && - cd .. && - cd svnwc && - svn_cmd rm --force symlink-file > /dev/null && - cd .. && + (cd gitwc && + git rm -f symlink-file > /dev/null + ) && + (cd svnwc && + svn_cmd rm --force symlink-file > /dev/null + ) && (cd svnwc; svn info symlink-file) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-symlink-file && @@ -294,12 +294,12 @@ test_expect_success 'info --url symlink-file (deleted)' ' ' test_expect_success 'info deleted-symlink-directory' " - cd gitwc && - git rm -f symlink-directory > /dev/null && - cd .. && - cd svnwc && - svn_cmd rm --force symlink-directory > /dev/null && - cd .. && + (cd gitwc && + git rm -f symlink-directory > /dev/null + ) && + (cd svnwc && + svn_cmd rm --force symlink-directory > /dev/null + ) && (cd svnwc; svn info symlink-directory) | sed -e 's/^\(Text Last Updated:\).*/\1 TEXT-LAST-UPDATED-STRING/' \ > expected.info-deleted-symlink-directory && @@ -346,9 +346,9 @@ test_expect_success 'info --url unknown-directory' ' ' test_expect_success 'info unknown-symlink-file' " - cd gitwc && - ln -s unknown-file unknown-symlink-file && - cd .. && + (cd gitwc && + ln -s unknown-file unknown-symlink-file + ) && (cd gitwc; test_must_fail git svn info unknown-symlink-file) \ 2> actual.info-unknown-symlink-file && grep unknown-symlink-file actual.info-unknown-symlink-file @@ -361,9 +361,9 @@ test_expect_success 'info --url unknown-symlink-file' ' ' test_expect_success 'info unknown-symlink-directory' " - cd gitwc && - ln -s unknown-directory unknown-symlink-directory && - cd .. && + (cd gitwc && + ln -s unknown-directory unknown-symlink-directory + ) && (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \ 2> actual.info-unknown-symlink-directory && grep unknown-symlink-directory actual.info-unknown-symlink-directory diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh index 9d9ebd533c..cddb9d4fc4 100755 --- a/t/t9120-git-svn-clone-with-percent-escapes.sh +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh @@ -20,9 +20,9 @@ test_expect_success 'setup svnrepo' ' test_expect_success 'test clone with percent escapes' ' git svn clone "$svnrepo/pr%20ject" clone && - cd clone && - git rev-parse refs/${remotes_git_svn} && - cd .. + (cd clone && + git rev-parse refs/${remotes_git_svn} + ) ' # SVN works either way, so should we... diff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh index 045521615c..0ed90d982d 100755 --- a/t/t9123-git-svn-rebuild-with-rewriteroot.sh +++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh @@ -8,10 +8,10 @@ test_description='git svn respects rewriteRoot during rebuild' . ./lib-git-svn.sh mkdir import -cd import +(cd import touch foo svn_cmd import -m 'import for git svn' . "$svnrepo" >/dev/null -cd .. +) rm -rf import test_expect_success 'init, fetch and checkout repository' ' diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh index c19418614f..096abd1fe5 100755 --- a/t/t9125-git-svn-multi-glob-branch-names.sh +++ b/t/t9125-git-svn-multi-glob-branch-names.sh @@ -19,19 +19,19 @@ test_expect_success 'setup svnrepo' ' test_expect_success 'test clone with multi-glob in branch names' ' git svn clone -T trunk -b branches/*/* -t tags \ "$svnrepo/project" project && - cd project && + (cd project && git rev-parse "refs/remotes/v14.1/beta" && - git rev-parse "refs/remotes/v14.1/gold" && - cd .. + git rev-parse "refs/remotes/v14.1/gold" + ) ' test_expect_success 'test dcommit to multi-globbed branch' " - cd project && + (cd project && git reset --hard 'refs/remotes/v14.1/gold' && echo hello >> foo && git commit -m 'hello' -- foo && - git svn dcommit && - cd .. + git svn dcommit + ) " test_done diff --git a/t/t9127-git-svn-partial-rebuild.sh b/t/t9127-git-svn-partial-rebuild.sh index 4aab8ecc14..2e4789d061 100755 --- a/t/t9127-git-svn-partial-rebuild.sh +++ b/t/t9127-git-svn-partial-rebuild.sh @@ -9,27 +9,27 @@ test_description='git svn partial-rebuild tests' test_expect_success 'initialize svnrepo' ' mkdir import && ( - cd import && + (cd import && mkdir trunk branches tags && - cd trunk && - echo foo > foo && - cd .. && + (cd trunk && + echo foo > foo + ) && svn_cmd import -m "import for git-svn" . "$svnrepo" >/dev/null && svn_cmd copy "$svnrepo"/trunk "$svnrepo"/branches/a \ - -m "created branch a" && - cd .. && + -m "created branch a" + ) && rm -rf import && svn_cmd co "$svnrepo"/trunk trunk && - cd trunk && + (cd trunk && echo bar >> foo && - svn_cmd ci -m "updated trunk" && - cd .. && + svn_cmd ci -m "updated trunk" + ) && svn_cmd co "$svnrepo"/branches/a a && - cd a && + (cd a && echo baz >> a && svn_cmd add a && - svn_cmd ci -m "updated a" && - cd .. && + svn_cmd ci -m "updated a" + ) && git svn init --stdlayout "$svnrepo" ) ' @@ -41,11 +41,11 @@ test_expect_success 'import an early SVN revision into git' ' test_expect_success 'make full git mirror of SVN' ' mkdir mirror && ( - cd mirror && + (cd mirror && git init && git svn init --stdlayout "$svnrepo" && - git svn fetch && - cd .. + git svn fetch + ) ) ' diff --git a/t/t9128-git-svn-cmd-branch.sh b/t/t9128-git-svn-cmd-branch.sh index 807e494a3a..4b034a67f3 100755 --- a/t/t9128-git-svn-cmd-branch.sh +++ b/t/t9128-git-svn-cmd-branch.sh @@ -9,19 +9,19 @@ test_description='git svn partial-rebuild tests' test_expect_success 'initialize svnrepo' ' mkdir import && ( - cd import && + (cd import && mkdir trunk branches tags && - cd trunk && - echo foo > foo && - cd .. && - svn_cmd import -m "import for git-svn" . "$svnrepo" >/dev/null && - cd .. && + (cd trunk && + echo foo > foo + ) && + svn_cmd import -m "import for git-svn" . "$svnrepo" >/dev/null + ) && rm -rf import && svn_cmd co "$svnrepo"/trunk trunk && - cd trunk && + (cd trunk && echo bar >> foo && - svn_cmd ci -m "updated trunk" && - cd .. && + svn_cmd ci -m "updated trunk" + ) && rm -rf trunk ) ' diff --git a/t/t9137-git-svn-dcommit-clobber-series.sh b/t/t9137-git-svn-dcommit-clobber-series.sh index 636ca0abb9..d60da63f7a 100755 --- a/t/t9137-git-svn-dcommit-clobber-series.sh +++ b/t/t9137-git-svn-dcommit-clobber-series.sh @@ -6,10 +6,10 @@ test_description='git svn dcommit clobber series' test_expect_success 'initialize repo' ' mkdir import && - cd import && + (cd import && awk "BEGIN { for (i = 1; i < 64; i++) { print i } }" > file - svn_cmd import -m "initial" . "$svnrepo" && - cd .. && + svn_cmd import -m "initial" . "$svnrepo" + ) && git svn init "$svnrepo" && git svn fetch && test -e file @@ -19,14 +19,14 @@ 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_cmd co "$svnrepo" tmp && - cd tmp && + (cd tmp && perl -i.bak -p -e "s/^58$/5588/" file && perl -i.bak -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_cmd commit -m "58 => 5588, 61 => 6611" && - cd .. + svn_cmd commit -m "58 => 5588, 61 => 6611" + ) ' test_expect_success 'some unrelated changes to git' " diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 2aeed7bd06..1a205a4d5a 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -1056,11 +1056,10 @@ test_expect_success \ 'P: supermodule & submodule mix' \ 'git fast-import src.c && GIT_CONFIG="$git_config" cvs -Q add src.c >cvs.log 2>&1 && marked_as . src.c "" && - echo "psuedo-binary" > temp.bin && - cd .. && + echo "psuedo-binary" > temp.bin + ) && GIT_CONFIG="$git_config" cvs -Q add subdir/temp.bin >cvs.log 2>&1 && marked_as subdir temp.bin "-kb" && cd subdir && GIT_CONFIG="$git_config" cvs -Q ci -m "adding files" >cvs.log 2>&1 && marked_as . temp.bin "-kb" && marked_as . src.c "" + ) ' -cd "$WORKDIR" test_expect_success 'updating' ' git pull gitcvs.git && echo 'hi' > subdir/newfile.bin && @@ -153,9 +154,9 @@ test_expect_success 'updating' ' git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin && git commit -q -m "Add and change some files" && git push gitcvs.git >/dev/null && - cd cvswork && - GIT_CONFIG="$git_config" cvs -Q update && - cd .. && + (cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update + ) && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes "" && @@ -233,35 +234,35 @@ test_expect_success 'cvs co another copy (guess)' ' ' test_expect_success 'add text (guess)' ' - cd cvswork && + (cd cvswork && echo "simpleText" > simpleText.c && - GIT_CONFIG="$git_config" cvs -Q add simpleText.c && - cd .. && + GIT_CONFIG="$git_config" cvs -Q add simpleText.c + ) && marked_as cvswork simpleText.c "" ' test_expect_success 'add bin (guess)' ' - cd cvswork && + (cd cvswork && echo "simpleBin: NUL: Q <- there" | q_to_nul > simpleBin.bin && - GIT_CONFIG="$git_config" cvs -Q add simpleBin.bin && - cd .. && + GIT_CONFIG="$git_config" cvs -Q add simpleBin.bin + ) && marked_as cvswork simpleBin.bin -kb ' test_expect_success 'remove files (guess)' ' - cd cvswork && + (cd cvswork && GIT_CONFIG="$git_config" cvs -Q rm -f subdir/file.h && - cd subdir && - GIT_CONFIG="$git_config" cvs -Q rm -f withCr.bin && - cd ../.. && + (cd subdir && + GIT_CONFIG="$git_config" cvs -Q rm -f withCr.bin + )) && marked_as cvswork/subdir withCr.bin -kb && marked_as cvswork/subdir file.h "" ' test_expect_success 'cvs ci (guess)' ' - cd cvswork && - GIT_CONFIG="$git_config" cvs -Q ci -m "add/rm files" >cvs.log 2>&1 && - cd .. && + (cd cvswork && + GIT_CONFIG="$git_config" cvs -Q ci -m "add/rm files" >cvs.log 2>&1 + ) && marked_as cvswork textfile.c "" && marked_as cvswork binfile.bin -kb && marked_as cvswork .gitattributes "" && @@ -278,9 +279,9 @@ test_expect_success 'cvs ci (guess)' ' ' test_expect_success 'update subdir of other copy (guess)' ' - cd cvswork2/subdir && - GIT_CONFIG="$git_config" cvs -Q update && - cd ../.. && + (cd cvswork2/subdir && + GIT_CONFIG="$git_config" cvs -Q update + ) && marked_as cvswork2 textfile.c "" && marked_as cvswork2 binfile.bin -kb && marked_as cvswork2 .gitattributes "" && @@ -304,11 +305,11 @@ test_expect_success 'update/merge full other copy (guess)' ' git add multilineTxt.c && git commit -q -m "modify multiline file" >> "${WORKDIR}/marked.log" && git push gitcvs.git >/dev/null && - cd cvswork2 && + (cd cvswork2 && sed "s/1/replaced_1/" < multilineTxt.c > ml.temp && mv ml.temp multilineTxt.c && - GIT_CONFIG="$git_config" cvs update > cvs.log 2>&1 && - cd .. && + GIT_CONFIG="$git_config" cvs update > cvs.log 2>&1 + ) && marked_as cvswork2 textfile.c "" && marked_as cvswork2 binfile.bin -kb && marked_as cvswork2 .gitattributes "" && diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index 2eff9cd68c..6ef1c34082 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -17,7 +17,7 @@ test_expect_success 'setup a cvs module' ' mkdir "$CVSROOT/module" && $CVS co -d module-cvs module && - cd module-cvs && + (cd module-cvs && cat <o_fortuna && O Fortuna velut luna @@ -41,8 +41,8 @@ add "O Fortuna" lyrics These public domain lyrics make an excellent sample text. EOF - $CVS commit -F message && - cd .. + $CVS commit -F message + ) ' test_expect_success 'import a trivial module' ' @@ -52,7 +52,7 @@ test_expect_success 'import a trivial module' ' ' -test_expect_success 'pack refs' 'cd module-git && git gc && cd ..' +test_expect_success 'pack refs' '(cd module-git && git gc)' test_expect_success 'initial import has correct .git/cvs-revisions' ' @@ -62,8 +62,7 @@ test_expect_success 'initial import has correct .git/cvs-revisions' ' ' test_expect_success 'update cvs module' ' - - cd module-cvs && + (cd module-cvs && cat <o_fortuna && O Fortune, like the moon @@ -86,16 +85,16 @@ translate to English My Latin is terrible. EOF - $CVS commit -F message && - cd .. + $CVS commit -F message + ) ' test_expect_success 'update git module' ' - cd module-git && + (cd module-git && git cvsimport -a -R -z 0 module && - git merge origin && - cd .. && + git merge origin + ) && test_cmp module-cvs/o_fortuna module-git/o_fortuna ' @@ -110,21 +109,20 @@ test_expect_success 'update has correct .git/cvs-revisions' ' test_expect_success 'update cvs module' ' - cd module-cvs && + (cd module-cvs && echo 1 >tick && $CVS add tick && $CVS commit -m 1 - cd .. - + ) ' test_expect_success 'cvsimport.module config works' ' - cd module-git && + (cd module-git && git config cvsimport.module module && git cvsimport -a -R -z0 && - git merge origin && - cd .. && + git merge origin + ) && test_cmp module-cvs/tick module-git/tick ' @@ -141,12 +139,12 @@ test_expect_success 'second update has correct .git/cvs-revisions' ' test_expect_success 'import from a CVS working tree' ' $CVS co -d import-from-wt module && - cd import-from-wt && + (cd import-from-wt && git cvsimport -a -z0 && echo 1 >expect && git log -1 --pretty=format:%s%n >actual && - test_cmp actual expect && - cd .. + test_cmp actual expect + ) ' diff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh index 958bdce4dd..2620780fd6 100755 --- a/t/t9603-cvsimport-patchsets.sh +++ b/t/t9603-cvsimport-patchsets.sh @@ -20,12 +20,12 @@ export CVSROOT test_expect_failure 'import with criss cross times on revisions' ' git cvsimport -p"-x" -C module-git module && - cd module-git && + (cd module-git && git log --pretty=format:%s > ../actual-master && git log A~2..A --pretty="format:%s %ad" -- > ../actual-A && echo "" >> ../actual-master && - echo "" >> ../actual-A && - cd .. && + echo "" >> ../actual-A + ) && echo "Rev 4 Rev 3 Rev 2 From 18a826924284339e2b637ab747f196235bee1939 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 6 Sep 2010 20:42:54 -0500 Subject: [PATCH 2/7] tests: subshell indentation stylefix Format the subshells introduced by the previous patch (Several tests: cd inside subshell instead of around, 2010-09-06) like so: ( cd subdir && ... ) && This is generally easier to read and has the nice side-effect that this patch will show what commands are used in the subshell, making it easier to check for lost environment variables and similar behavior changes. Cc: Jens Lehmann Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 13 ++-- t/t1302-repo-version.sh | 11 ++- t/t3060-ls-files-with-tree.sh | 12 ++-- t/t3409-rebase-preserve-merges.sh | 13 ++-- t/t3903-stash.sh | 5 +- t/t4041-diff-submodule-option.sh | 7 +- t/t5510-fetch.sh | 35 +++++----- t/t6050-replace.sh | 46 ++++++------ t/t7400-submodule-basic.sh | 11 +-- t/t7401-submodule-summary.sh | 7 +- t/t9100-git-svn-basic.sh | 21 +++--- t/t9101-git-svn-props.sh | 33 +++++---- t/t9102-git-svn-deep-rmdir.sh | 13 ++-- t/t9104-git-svn-follow-parent.sh | 70 +++++++++++-------- t/t9105-git-svn-commit-diff.sh | 7 +- t/t9106-git-svn-commit-diff-clobber.sh | 30 ++++---- t/t9107-git-svn-migrate.sh | 16 +++-- t/t9114-git-svn-dcommit-merge.sh | 7 +- t/t9115-git-svn-dcommit-funky-renames.sh | 7 +- t/t9116-git-svn-log.sh | 16 +++-- t/t9119-git-svn-info.sh | 69 +++++++++++------- t/t9120-git-svn-clone-with-percent-escapes.sh | 3 +- 22 files changed, 260 insertions(+), 192 deletions(-) diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index c36157a896..0d0da17eb8 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -27,12 +27,13 @@ test_expect_success 'update-index and ls-files' ' one) echo pass one ;; *) echo bad one; exit 1 ;; esac && - (cd dir && - git update-index --add two && - case "`git ls-files`" in - two) echo pass two ;; - *) echo bad two; exit 1 ;; - esac + ( + cd dir && + git update-index --add two && + case "`git ls-files`" in + two) echo pass two ;; + *) echo bad two; exit 1 ;; + esac ) && case "`git ls-files`" in dir/two"$LF"one) echo pass both ;; diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index c948719931..0da27997c2 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -33,8 +33,15 @@ test_expect_success 'gitdir selection on unsupported repo' ' test_expect_success 'gitdir not required mode' ' git apply --stat test.patch && - (cd test && git apply --stat ../test.patch) && - (cd test2 && git apply --stat ../test.patch)' + ( + cd test && + git apply --stat ../test.patch + ) && + ( + cd test2 && + git apply --stat ../test.patch + ) +' test_expect_success 'gitdir required mode on normal repos' ' (git apply --check --index test.patch && diff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh index 25afb4faeb..61c1f53d1b 100755 --- a/t/t3060-ls-files-with-tree.sh +++ b/t/t3060-ls-files-with-tree.sh @@ -53,13 +53,13 @@ test_expect_success setup ' git add . ' -# We have to run from a sub-directory to trigger prune_path -# Then we finally get to run our --with-tree test - test_expect_success 'git -ls-files --with-tree should succeed from subdir' ' - - (cd sub && git ls-files --with-tree=HEAD~1 >../output) - + # We have to run from a sub-directory to trigger prune_path + # Then we finally get to run our --with-tree test + ( + cd sub && + git ls-files --with-tree=HEAD~1 >../output + ) ' test_expect_success \ diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 1a362d231a..74161a42ec 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -52,12 +52,13 @@ test_expect_success 'setup for merge-preserving rebase' \ git commit -m "Add different B" && git clone ./. clone2 && - (cd clone2 && - git checkout -b topic origin/topic && - test_must_fail git merge origin/master && - echo Resolved > B && - git add B && - git commit -m "Merge origin/master into topic" + ( + cd clone2 && + git checkout -b topic origin/topic && + test_must_fail git merge origin/master && + echo Resolved >B && + git add B && + git commit -m "Merge origin/master into topic" ) && git checkout topic && diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 056bc2b248..a283dca25f 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -69,8 +69,9 @@ test_expect_success 'apply stashed changes (including index)' ' test_expect_success 'unstashing in a subdirectory' ' git reset --hard HEAD && mkdir subdir && - (cd subdir && - git stash apply + ( + cd subdir && + git stash apply ) ' diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index 737c3d93ff..995bdfafec 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -85,9 +85,10 @@ EOF " commit_file sm1 && -head3=$(cd sm1 && -git reset --hard HEAD~2 >/dev/null && -git rev-parse --verify HEAD | cut -c1-7 +head3=$( + cd sm1 && + git reset --hard HEAD~2 >/dev/null && + git rev-parse --verify HEAD | cut -c1-7 ) test_expect_success 'modified submodule(backward)' " diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 34d59d5766..7d1c866e13 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -21,26 +21,29 @@ test_expect_success setup ' test_expect_success "clone and setup child repos" ' git clone . one && - (cd one && - echo >file updated by one && - git commit -a -m "updated by one" + ( + cd one && + echo >file updated by one && + git commit -a -m "updated by one" ) && git clone . two && - (cd two && - git config branch.master.remote one && - git config remote.one.url ../one/.git/ && - git config remote.one.fetch refs/heads/master:refs/heads/one + ( + cd two && + git config branch.master.remote one && + git config remote.one.url ../one/.git/ && + git config remote.one.fetch refs/heads/master:refs/heads/one ) && git clone . three && - (cd three && - git config branch.master.remote two && - git config branch.master.merge refs/heads/one && - mkdir -p .git/remotes && - { - echo "URL: ../two/.git/" - echo "Pull: refs/heads/master:refs/heads/two" - echo "Pull: refs/heads/one:refs/heads/one" - } >.git/remotes/two + ( + cd three && + git config branch.master.remote two && + git config branch.master.merge refs/heads/one && + mkdir -p .git/remotes && + { + echo "URL: ../two/.git/" + echo "Pull: refs/heads/master:refs/heads/two" + echo "Pull: refs/heads/one:refs/heads/one" + } >.git/remotes/two ) && git clone . bundle && git clone . seven diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index 1911802355..c907523e7e 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -104,16 +104,17 @@ test_expect_success '"git fsck" works' ' test_expect_success 'repack, clone and fetch work' ' git repack -a -d && git clone --no-hardlinks . clone_dir && - (cd clone_dir && - git show HEAD~5 | grep "A U Thor" && - git show $HASH2 | grep "A U Thor" && - git cat-file commit $R && - git repack -a -d && - test_must_fail git cat-file commit $R && - git fetch ../ "refs/replace/*:refs/replace/*" && - git show HEAD~5 | grep "O Thor" && - git show $HASH2 | grep "O Thor" && - git cat-file commit $R + ( + cd clone_dir && + git show HEAD~5 | grep "A U Thor" && + git show $HASH2 | grep "A U Thor" && + git cat-file commit $R && + git repack -a -d && + test_must_fail git cat-file commit $R && + git fetch ../ "refs/replace/*:refs/replace/*" && + git show HEAD~5 | grep "O Thor" && + git show $HASH2 | grep "O Thor" && + git cat-file commit $R ) ' @@ -177,9 +178,10 @@ test_expect_success 'create parallel branch without the bug' ' test_expect_success 'push to cloned repo' ' git push cloned $HASH6^:refs/heads/parallel && - (cd clone_dir && - git checkout parallel && - git log --pretty=oneline | grep $PARA2 + ( + cd clone_dir && + git checkout parallel && + git log --pretty=oneline | grep $PARA2 ) ' @@ -191,19 +193,21 @@ test_expect_success 'push branch with replacement' ' git show $HASH6~2 | grep "O Thor" && git show $PARA3 | grep "O Thor" && git push cloned $HASH6^:refs/heads/parallel2 && - (cd clone_dir && - git checkout parallel2 && - git log --pretty=oneline | grep $PARA3 && - git show $PARA3 | grep "A U Thor" + ( + cd clone_dir && + git checkout parallel2 && + git log --pretty=oneline | grep $PARA3 && + git show $PARA3 | grep "A U Thor" ) ' test_expect_success 'fetch branch with replacement' ' git branch tofetch $HASH6 && - (cd clone_dir && - git fetch origin refs/heads/tofetch:refs/heads/parallel3 - git log --pretty=oneline parallel3 | grep $PARA3 - git show $PARA3 | grep "A U Thor" + ( + cd clone_dir && + git fetch origin refs/heads/tofetch:refs/heads/parallel3 + git log --pretty=oneline parallel3 | grep $PARA3 + git show $PARA3 | grep "A U Thor" ) ' diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh index 21b08395ce..782b0a3ece 100755 --- a/t/t7400-submodule-basic.sh +++ b/t/t7400-submodule-basic.sh @@ -413,11 +413,12 @@ test_expect_success 'submodule warns' ' test_expect_success 'add submodules without specifying an explicit path' ' mkdir repo && - (cd repo && - git init && - echo r >r && - git add r && - git commit -m "repo commit 1" + ( + cd repo && + git init && + echo r >r && + git add r && + git commit -m "repo commit 1" ) && git clone --bare repo/ bare.git && cd addtest && diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index b5ad45f447..294584452b 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -66,9 +66,10 @@ EOF " commit_file sm1 && -head3=$(cd sm1 && -git reset --hard HEAD~2 >/dev/null && -git rev-parse --verify HEAD | cut -c1-7 +head3=$( + cd sm1 && + git reset --hard HEAD~2 >/dev/null && + git rev-parse --verify HEAD | cut -c1-7 ) test_expect_success 'modified submodule(backward)' " diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 34eb01797b..2f458f7a99 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -22,16 +22,17 @@ esac test_expect_success \ '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 && - mkdir bar && - echo "zzz" > bar/zzz && - echo "#!/bin/sh" > exec.sh && - chmod +x exec.sh && - svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null + ( + 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 && + mkdir bar && + echo "zzz" >bar/zzz && + echo "#!/bin/sh" >exec.sh && + chmod +x exec.sh && + svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null ) && rm -rf import && git svn init "$svnrepo"' diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index f53a1a9ea6..8869f5018e 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -53,8 +53,9 @@ cd .. rm -rf import test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc' -test_expect_success 'setup some commits to svn' \ - '(cd test_wc && +test_expect_success 'setup some commits to svn' ' + ( + cd test_wc && echo Greetings >> kw.c && poke kw.c && svn_cmd commit -m "Not yet an Id" && @@ -64,7 +65,8 @@ test_expect_success 'setup some commits to svn' \ svn_cmd propset svn:keywords Id kw.c && poke kw.c && svn_cmd commit -m "Propset Id" - )' + ) +' test_expect_success 'initialize git svn' 'git svn init "$svnrepo"' test_expect_success 'fetch revisions from svn' 'git svn fetch' @@ -81,13 +83,15 @@ expect='/* $Id$ */' got="`sed -ne 2p kw.c`" test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'" -test_expect_success "propset CR on crlf files" \ - '(cd test_wc && +test_expect_success "propset CR on crlf files" ' + ( + cd test_wc && svn_cmd propset svn:eol-style CR empty && svn_cmd propset svn:eol-style CR crlf && svn_cmd propset svn:eol-style CR ne_crlf && svn_cmd commit -m "propset CR on crlf files" - )' + ) +' test_expect_success 'fetch and pull latest from svn and checkout a new wc' \ 'git svn fetch && @@ -137,19 +141,20 @@ cat > show-ignore.expect <<\EOF EOF test_expect_success 'test show-ignore' " - (cd test_wc && - mkdir -p deeply/nested/directory && - touch deeply/nested/directory/.keep && - svn_cmd add deeply && - svn_cmd up && - svn_cmd propset -R svn:ignore ' + ( + cd test_wc && + mkdir -p deeply/nested/directory && + touch deeply/nested/directory/.keep && + svn_cmd add deeply && + svn_cmd up && + svn_cmd propset -R svn:ignore ' no-such-file* ' . - svn_cmd commit -m 'propset svn:ignore' + svn_cmd commit -m 'propset svn:ignore' ) && git svn show-ignore > show-ignore.got && cmp show-ignore.expect show-ignore.got - " +" cat >create-ignore.expect <<\EOF /no-such-file* diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh index d60a8efac2..eb70f4839c 100755 --- a/t/t9102-git-svn-deep-rmdir.sh +++ b/t/t9102-git-svn-deep-rmdir.sh @@ -4,12 +4,13 @@ test_description='git svn rmdir' 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_cmd import -m "import for git svn" . "$svnrepo" + ( + 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_cmd import -m "import for git svn" . "$svnrepo" ) ' diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 236e7de9a9..f7f3c5ab8e 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -8,21 +8,23 @@ test_description='git svn fetching' test_expect_success 'initialize repo' ' mkdir import && - (cd import && - mkdir -p trunk && - echo hello > trunk/readme && - svn_cmd import -m "initial" . "$svnrepo" + ( + cd import && + mkdir -p trunk && + echo hello >trunk/readme && + svn_cmd import -m "initial" . "$svnrepo" ) && svn_cmd co "$svnrepo" wc && - (cd wc && - echo world >> trunk/readme && - poke trunk/readme && - svn_cmd commit -m "another commit" && - svn_cmd up && - svn_cmd mv trunk thunk && - echo goodbye >> thunk/readme && - poke thunk/readme && - svn_cmd commit -m "bye now" + ( + cd wc && + echo world >>trunk/readme && + poke trunk/readme && + svn_cmd commit -m "another commit" && + svn_cmd up && + svn_cmd mv trunk thunk && + echo goodbye >>thunk/readme && + poke thunk/readme && + svn_cmd commit -m "bye now" ) ' @@ -83,16 +85,17 @@ test_expect_success 'follow larger parent' ' ' 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 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 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 ' @@ -117,17 +120,22 @@ test_expect_success 'follow-parent avoids deleting relevant info' ' import/trunk/subversion/bindings/swig/perl/t/larger-parent && echo "bad delete test 2" > \ import/trunk/subversion/bindings/swig/perl/another-larger && - (cd import && - svn import -m "r9270 test" . "$svnrepo"/r9270 + ( + cd import && + svn import -m "r9270 test" . "$svnrepo"/r9270 ) && svn_cmd 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 && - echo z >> native/t/c.t && - poke native/t/c.t && - svn commit -m "reorg test" + ( + 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 && + echo z >>native/t/c.t && + poke native/t/c.t && + svn commit -m "reorg test" ) && git svn init --minimize-url -i r9270-t \ "$svnrepo"/r9270/trunk/subversion/bindings/swig/perl/native/t && diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index d432d835ae..5d0afeae6c 100755 --- a/t/t9105-git-svn-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh @@ -6,9 +6,10 @@ test_description='git svn commit-diff' test_expect_success 'initialize repo' ' mkdir import && - (cd import && - echo hello > readme && - svn_cmd import -m "initial" . "$svnrepo" + ( + cd import && + echo hello >readme && + svn_cmd import -m "initial" . "$svnrepo" ) && echo hello > readme && git update-index --add readme && diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh index af367a1814..f6d7ac7c5f 100755 --- a/t/t9106-git-svn-commit-diff-clobber.sh +++ b/t/t9106-git-svn-commit-diff-clobber.sh @@ -6,9 +6,10 @@ test_description='git svn commit-diff clobber' test_expect_success 'initialize repo' ' mkdir import && - (cd import && - echo initial > file && - svn_cmd import -m "initial" . "$svnrepo" + ( + cd import && + echo initial >file && + svn_cmd import -m "initial" . "$svnrepo" ) && echo initial > file && git update-index --add file && @@ -16,10 +17,11 @@ test_expect_success 'initialize repo' ' ' test_expect_success 'commit change from svn side' ' svn_cmd co "$svnrepo" t.svn && - (cd t.svn && - echo second line from svn >> file && - poke file && - svn_cmd commit -m "second line from svn" + ( + cd t.svn && + echo second line from svn >>file && + poke file && + svn_cmd commit -m "second line from svn" ) && rm -rf t.svn ' @@ -44,10 +46,11 @@ test_expect_success 'dcommit fails to commit because of conflict' ' git svn fetch && git reset --hard refs/${remotes_git_svn} && svn_cmd co "$svnrepo" t.svn && - (cd t.svn && - echo fourth line from svn >> file && - poke file && - svn_cmd commit -m "fourth line from svn" + ( + cd t.svn && + echo fourth line from svn >>file && + poke file && + svn_cmd commit -m "fourth line from svn" ) && rm -rf t.svn && echo "fourth line from git" >> file && @@ -68,8 +71,9 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' " test_expect_success 'commit another change from svn side' ' svn_cmd co "$svnrepo" t.svn && - (cd t.svn && - echo third line from svn >> file && + ( + cd t.svn && + echo third line from svn >>file && poke file && svn_cmd commit -m "third line from svn" ) && diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh index f60b30699b..289fc313fb 100755 --- a/t/t9107-git-svn-migrate.sh +++ b/t/t9107-git-svn-migrate.sh @@ -6,14 +6,16 @@ test_description='git svn metadata migrations from previous versions' 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 - done && \ + ( + 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 + done && svn_cmd import -m test . "$svnrepo" - ) && + ) && git svn init "$svnrepo" && git svn fetch && rm -rf "$GIT_DIR"/svn && diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh index a7d0c7d99e..3077851015 100755 --- a/t/t9114-git-svn-dcommit-merge.sh +++ b/t/t9114-git-svn-dcommit-merge.sh @@ -37,11 +37,12 @@ EOF test_expect_success 'setup svn repository' ' svn_cmd co "$svnrepo" mysvnwork && mkdir -p mysvnwork/trunk && - (cd mysvnwork && - big_text_block >> trunk/README && + ( + cd mysvnwork && + big_text_block >>trunk/README && svn_cmd add trunk && svn_cmd ci -m "first commit" trunk - ) + ) ' test_expect_success 'setup git mirror and merge' ' diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh index 9fdbc9bc95..6a48e40429 100755 --- a/t/t9115-git-svn-dcommit-funky-renames.sh +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@ -61,11 +61,12 @@ test_expect_success 'add a file with plus signs' ' test_expect_success 'clone the repository to test rebase' ' git svn clone "$svnrepo" test-rebase && - (cd test-rebase && - echo test-rebase > test-rebase && + ( + cd test-rebase && + echo test-rebase >test-rebase && git add test-rebase && git commit -m test-rebase - ) + ) ' test_expect_success 'make a commit to test rebase' ' diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh index 244b5cd3cf..5d477e4bda 100755 --- a/t/t9116-git-svn-log.sh +++ b/t/t9116-git-svn-log.sh @@ -8,14 +8,16 @@ test_description='git svn log tests' 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 - done && \ + ( + 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 + done && svn_cmd import -m test . "$svnrepo" - ) && + ) && git svn init "$svnrepo" -T trunk -b branches -t tags && git svn fetch && git reset --hard trunk && diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh index e3f08c448e..f3f397cdda 100755 --- a/t/t9119-git-svn-info.sh +++ b/t/t9119-git-svn-info.sh @@ -39,9 +39,10 @@ quoted_svnrepo="$(echo $svnrepo | sed 's/ /%20/')" test_expect_success 'setup repository and import' ' mkdir info && - (cd info && - echo FIRST > A && - echo one > file && + ( + cd info && + echo FIRST >A && + echo one >file && ln -s file symlink-file && mkdir directory && touch directory/.placeholder && @@ -49,14 +50,16 @@ test_expect_success 'setup repository and import' ' svn_cmd import -m "initial" . "$svnrepo" ) && svn_cmd co "$svnrepo" svnwc && - (cd svnwc && - echo foo > foo && + ( + cd svnwc && + echo foo >foo && svn_cmd add foo && svn_cmd commit -m "change outside directory" && svn_cmd update ) && mkdir gitwc && - (cd gitwc && + ( + cd gitwc && git svn init "$svnrepo" && git svn fetch ) && @@ -138,12 +141,14 @@ test_expect_success 'info --url symlink-directory' ' test_expect_success 'info added-file' " echo two > gitwc/added-file && - (cd gitwc && + ( + cd gitwc && git add added-file ) && cp gitwc/added-file svnwc/added-file && ptouch gitwc/added-file svnwc/added-file && - (cd svnwc && + ( + cd svnwc && svn_cmd add added-file > /dev/null ) && (cd svnwc; svn info added-file) > expected.info-added-file && @@ -160,10 +165,12 @@ test_expect_success 'info added-directory' " mkdir gitwc/added-directory svnwc/added-directory && ptouch gitwc/added-directory svnwc/added-directory && touch gitwc/added-directory/.placeholder && - (cd svnwc && + ( + cd svnwc && svn_cmd add added-directory > /dev/null ) && - (cd gitwc && + ( + cd gitwc && git add added-directory ) && (cd svnwc; svn info added-directory) \ @@ -179,11 +186,13 @@ test_expect_success 'info --url added-directory' ' ' test_expect_success 'info added-symlink-file' " - (cd gitwc && + ( + cd gitwc && ln -s added-file added-symlink-file && git add added-symlink-file ) && - (cd svnwc && + ( + cd svnwc && ln -s added-file added-symlink-file && svn_cmd add added-symlink-file > /dev/null ) && @@ -202,11 +211,13 @@ test_expect_success 'info --url added-symlink-file' ' ' test_expect_success 'info added-symlink-directory' " - (cd gitwc && + ( + cd gitwc && ln -s added-directory added-symlink-directory && git add added-symlink-directory ) && - (cd svnwc && + ( + cd svnwc && ln -s added-directory added-symlink-directory && svn_cmd add added-symlink-directory > /dev/null ) && @@ -230,10 +241,12 @@ test_expect_success 'info --url added-symlink-directory' ' # simply reuses the Last Changed Date. test_expect_success 'info deleted-file' " - (cd gitwc && + ( + cd gitwc && git rm -f file > /dev/null ) && - (cd svnwc && + ( + cd svnwc && svn_cmd rm --force file > /dev/null ) && (cd svnwc; svn info file) | @@ -251,10 +264,12 @@ test_expect_success 'info --url file (deleted)' ' ' test_expect_success 'info deleted-directory' " - (cd gitwc && + ( + cd gitwc && git rm -r -f directory > /dev/null ) && - (cd svnwc && + ( + cd svnwc && svn_cmd rm --force directory > /dev/null ) && (cd svnwc; svn info directory) | @@ -272,10 +287,12 @@ test_expect_success 'info --url directory (deleted)' ' ' test_expect_success 'info deleted-symlink-file' " - (cd gitwc && + ( + cd gitwc && git rm -f symlink-file > /dev/null ) && - (cd svnwc && + ( + cd svnwc && svn_cmd rm --force symlink-file > /dev/null ) && (cd svnwc; svn info symlink-file) | @@ -294,10 +311,12 @@ test_expect_success 'info --url symlink-file (deleted)' ' ' test_expect_success 'info deleted-symlink-directory' " - (cd gitwc && + ( + cd gitwc && git rm -f symlink-directory > /dev/null ) && - (cd svnwc && + ( + cd svnwc && svn_cmd rm --force symlink-directory > /dev/null ) && (cd svnwc; svn info symlink-directory) | @@ -346,7 +365,8 @@ test_expect_success 'info --url unknown-directory' ' ' test_expect_success 'info unknown-symlink-file' " - (cd gitwc && + ( + cd gitwc && ln -s unknown-file unknown-symlink-file ) && (cd gitwc; test_must_fail git svn info unknown-symlink-file) \ @@ -361,7 +381,8 @@ test_expect_success 'info --url unknown-symlink-file' ' ' test_expect_success 'info unknown-symlink-directory' " - (cd gitwc && + ( + cd gitwc && ln -s unknown-directory unknown-symlink-directory ) && (cd gitwc; test_must_fail git svn info unknown-symlink-directory) \ diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh index cddb9d4fc4..1d92c05035 100755 --- a/t/t9120-git-svn-clone-with-percent-escapes.sh +++ b/t/t9120-git-svn-clone-with-percent-escapes.sh @@ -20,7 +20,8 @@ test_expect_success 'setup svnrepo' ' test_expect_success 'test clone with percent escapes' ' git svn clone "$svnrepo/pr%20ject" clone && - (cd clone && + ( + cd clone && git rev-parse refs/${remotes_git_svn} ) ' From dbedf8bf42f63847b096aeb7d6b96cf3a2233b7a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 6 Sep 2010 20:47:07 -0500 Subject: [PATCH 3/7] t1450 (fsck): remove dangling objects The fsck test is generally careful to remove the corrupt objects it inserts, but dangling objects are left behind due to some typos and omissions. It is better to clean up more completely, to simplify the addition of later tests. So: - guard setup and cleanup with test_expect_success to catch typos and errors; - check both stdout and stderr when checking for empty fsck output; - use test_cmp empty file in place of test $(wc -l Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1450-fsck.sh | 140 ++++++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 58 deletions(-) diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 759cf12e16..1be415e334 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -1,21 +1,23 @@ #!/bin/sh -test_description='git fsck random collection of tests' +test_description='git fsck random collection of tests + +* (HEAD) B +* (master) A +' . ./test-lib.sh test_expect_success setup ' + git config gc.auto 0 && git config i18n.commitencoding ISO-8859-1 && test_commit A fileA one && git config --unset i18n.commitencoding && git checkout HEAD^0 && test_commit B fileB two && git tag -d A B && - git reflog expire --expire=now --all -' - -test_expect_success 'HEAD is part of refs' ' - test 0 = $(git fsck | wc -l) + git reflog expire --expire=now --all && + >empty ' test_expect_success 'loose objects borrowed from alternate are not missing' ' @@ -25,110 +27,132 @@ test_expect_success 'loose objects borrowed from alternate are not missing' ' git init && echo ../../../.git/objects >.git/objects/info/alternates && test_commit C fileC one && - git fsck >out && - ! grep "missing blob" out - ) + git fsck >../out 2>&1 + ) && + { + grep -v dangling out >actual || + : + } && + test_cmp empty actual ' -test_expect_success 'valid objects appear valid' ' - { git fsck 2>out; true; } && - ! grep error out && - ! grep fatal out +test_expect_success 'HEAD is part of refs, valid objects appear valid' ' + git fsck >actual 2>&1 && + test_cmp empty actual ' # Corruption tests follow. Make sure to remove all traces of the # specific corruption you test afterwards, lest a later test trip over # it. +test_expect_success 'setup: helpers for corruption tests' ' + sha1_file() { + echo "$*" | sed "s#..#.git/objects/&/#" + } && + + remove_object() { + file=$(sha1_file "$*") && + test -e "$file" && + rm -f "$file" + } +' + test_expect_success 'object with bad sha1' ' sha=$(echo blob | git hash-object -w --stdin) && - echo $sha && old=$(echo $sha | sed "s+^..+&/+") && new=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff && sha="$(dirname $new)$(basename $new)" mv .git/objects/$old .git/objects/$new && + test_when_finished "remove_object $sha" && git update-index --add --cacheinfo 100644 $sha foo && + test_when_finished "git read-tree -u --reset HEAD" && tree=$(git write-tree) && + test_when_finished "remove_object $tree" && cmt=$(echo bogus | git commit-tree $tree) && + test_when_finished "remove_object $cmt" && git update-ref refs/heads/bogus $cmt && - (git fsck 2>out; true) && - grep "$sha.*corrupt" out && - rm -f .git/objects/$new && - git update-ref -d refs/heads/bogus && - git read-tree -u --reset HEAD + test_when_finished "git update-ref -d refs/heads/bogus" && + + test_might_fail git fsck 2>out && + cat out && + grep "$sha.*corrupt" out ' test_expect_success 'branch pointing to non-commit' ' - git rev-parse HEAD^{tree} > .git/refs/heads/invalid && + git rev-parse HEAD^{tree} >.git/refs/heads/invalid && + test_when_finished "git update-ref -d refs/heads/invalid" && git fsck 2>out && - grep "not a commit" out && - git update-ref -d refs/heads/invalid + cat out && + grep "not a commit" out ' -new=nothing test_expect_success 'email without @ is okay' ' git cat-file commit HEAD >basis && sed "s/@/AT/" basis >okay && new=$(git hash-object -t commit -w --stdin out && cat out && - ! grep "error in commit $new" out + ! grep "commit $new" out ' -git update-ref -d refs/heads/bogus -rm -f ".git/objects/$new" -new=nothing test_expect_success 'email with embedded > is not okay' ' git cat-file commit HEAD >basis && sed "s/@[a-z]/&>/" basis >bad-email && new=$(git hash-object -t commit -w --stdin out && cat out && grep "error in commit $new" out ' -git update-ref -d refs/heads/bogus -rm -f ".git/objects/$new" - -cat > invalid-tag < 1234567890 -0000 - -This is an invalid tag. -EOF test_expect_success 'tag pointing to nonexistent' ' - tag=$(git hash-object -t tag -w --stdin < invalid-tag) && - echo $tag > .git/refs/tags/invalid && + cat >invalid-tag <<-\EOF + object ffffffffffffffffffffffffffffffffffffffff + type commit + tag invalid + tagger T A Gger 1234567890 -0000 + + This is an invalid tag. + EOF + + tag=$(git hash-object -t tag -w --stdin .git/refs/tags/invalid && + test_when_finished "git update-ref -d refs/tags/invalid" && test_must_fail git fsck --tags >out && cat out && - grep "broken link" out && - rm .git/refs/tags/invalid + grep "broken link" out ' -cat > wrong-tag < 1234567890 -0000 - -This is an invalid tag. -EOF - test_expect_success 'tag pointing to something else than its type' ' - tag=$(git hash-object -t tag -w --stdin < wrong-tag) && - echo $tag > .git/refs/tags/wrong && + sha=$(echo blob | git hash-object -w --stdin) && + test_when_finished "remove_object $sha" && + cat >wrong-tag <<-EOF && + object $sha + type commit + tag wrong + tagger T A Gger 1234567890 -0000 + + This is an invalid tag. + EOF + + tag=$(git hash-object -t tag -w --stdin .git/refs/tags/wrong && + test_when_finished "git update-ref -d refs/tags/wrong" && test_must_fail git fsck --tags 2>out && cat out && - grep "error in tag.*broken links" out && - rm .git/refs/tags/wrong + grep "error in tag.*broken links" out ' - +test_expect_success 'cleaned up' ' + git fsck >actual 2>&1 && + test_cmp empty actual +' test_done From 76bbcd4382797dedb72a50387111a65d88230fa9 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 6 Sep 2010 20:49:10 -0500 Subject: [PATCH 4/7] t2105 (gitfile): add missing && Make sure early failures are not masked by later successes. Signed-off-by: Jonathan Nieder Acked-by: Brad King Signed-off-by: Junio C Hamano --- t/t2105-update-index-gitfile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t2105-update-index-gitfile.sh b/t/t2105-update-index-gitfile.sh index 641607d89a..a7f3d47aec 100755 --- a/t/t2105-update-index-gitfile.sh +++ b/t/t2105-update-index-gitfile.sh @@ -13,7 +13,7 @@ test_expect_success 'submodule with absolute .git file' ' (cd sub1 && git init && REAL="$(pwd)/.real" && - mv .git "$REAL" + mv .git "$REAL" && echo "gitdir: $REAL" >.git && test_commit first) ' From 8fe5aeddcbeb194ea0f6e23e1f7b4ac38809921b Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Mon, 6 Sep 2010 20:52:27 -0500 Subject: [PATCH 5/7] t1302 (core.repositoryversion): style tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test is from 2007, which is late enough for the style to be recognizably modern but still a while ago. Freshen it up to follow new best practices: - guard setup commands with test_expect_setup, so errors at that stage can be caught; - use <<\EOF in preference to < Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t1302-repo-version.sh | 64 +++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh index 0da27997c2..a6bf1bf4d6 100755 --- a/t/t1302-repo-version.sh +++ b/t/t1302-repo-version.sh @@ -7,29 +7,41 @@ test_description='Test repository version check' . ./test-lib.sh -cat >test.patch <test.patch <<-\EOF && + diff --git a/test.txt b/test.txt + new file mode 100644 + --- /dev/null + +++ b/test.txt + @@ -0,0 +1 @@ + +123 + EOF -test_create_repo "test" -test_create_repo "test2" - -GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 || exit 1 + test_create_repo "test" && + test_create_repo "test2" && + GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 +' test_expect_success 'gitdir selection on normal repos' ' - (test "$(git config core.repositoryformatversion)" = 0 && - cd test && - test "$(git config core.repositoryformatversion)" = 0)' + echo 0 >expect && + git config core.repositoryformatversion >actual && + ( + cd test && + git config core.repositoryformatversion >../actual2 + ) && + test_cmp expect actual && + test_cmp expect actual2 +' -# Make sure it would stop at test2, not trash test_expect_success 'gitdir selection on unsupported repo' ' - (cd test2 && - test "$(git config core.repositoryformatversion)" = 99)' + # Make sure it would stop at test2, not trash + echo 99 >expect && + ( + cd test2 && + git config core.repositoryformatversion >../actual + ) + test_cmp expect actual +' test_expect_success 'gitdir not required mode' ' git apply --stat test.patch && @@ -43,12 +55,16 @@ test_expect_success 'gitdir not required mode' ' ) ' -test_expect_success 'gitdir required mode on normal repos' ' - (git apply --check --index test.patch && - cd test && git apply --check --index ../test.patch)' - -test_expect_success 'gitdir required mode on unsupported repo' ' - (cd test2 && test_must_fail git apply --check --index ../test.patch) +test_expect_success 'gitdir required mode' ' + git apply --check --index test.patch && + ( + cd test && + git apply --check --index ../test.patch + ) && + ( + cd test2 && + test_must_fail git apply --check --index ../test.patch + ) ' test_done From a814615a6a1722839c69dcc998ed4fae9da08310 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 7 Sep 2010 03:22:53 -0500 Subject: [PATCH 6/7] t2016 (checkout -p): add missing && Although the set_state command is not likely to fail, it is best to stay in the habit of checking for failures. Cc: Thomas Rast Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- t/t2016-checkout-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh index 7657ec190c..a463b13b27 100755 --- a/t/t2016-checkout-patch.sh +++ b/t/t2016-checkout-patch.sh @@ -52,7 +52,7 @@ test_expect_success PERL 'git checkout -p HEAD with NO staged changes: apply' ' ' test_expect_success PERL 'git checkout -p HEAD with change already staged' ' - set_state dir/foo index index + set_state dir/foo index index && # the third n is to get out in case it mistakenly does not apply (echo n; echo y; echo n) | git checkout -p HEAD && verify_saved_state bar && From fd3c32c9815441ebbc3d46a3ff4ef862b3a9688c Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Tue, 7 Sep 2010 12:29:20 +0200 Subject: [PATCH 7/7] t1020: Get rid of 'cd "$HERE"' at the start of each test To achieve that, all cd commands which weren't inside a subshell had to be put into a new one. Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano --- t/t1020-subdirectory.sh | 91 ++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 0d0da17eb8..a3ac33801a 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -16,12 +16,10 @@ test_expect_success setup ' cp one original.one && cp dir/two original.two ' -HERE=`pwd` LF=' ' test_expect_success 'update-index and ls-files' ' - cd "$HERE" && git update-index --add one && case "`git ls-files`" in one) echo pass one ;; @@ -42,20 +40,20 @@ test_expect_success 'update-index and ls-files' ' ' test_expect_success 'cat-file' ' - cd "$HERE" && two=`git ls-files -s dir/two` && two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` && echo "$two" && git cat-file -p "$two" >actual && cmp dir/two actual && - cd dir && - git cat-file -p "$two" >actual && - cmp two actual + ( + cd dir && + git cat-file -p "$two" >actual && + cmp two actual + ) ' rm -f actual dir/actual test_expect_success 'diff-files' ' - cd "$HERE" && echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in @@ -63,77 +61,88 @@ test_expect_success 'diff-files' ' *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths - cd dir && - case "`git diff-files --name-only`" in - dir/two"$LF"one) echo pass subdir ;; - *) echo bad subdir; exit 1 ;; - esac && - case "`git diff-files --name-only .`" in - dir/two) echo pass subdir limited ;; - *) echo bad subdir limited; exit 1 ;; - esac + ( + cd dir && + case "`git diff-files --name-only`" in + dir/two"$LF"one) echo pass subdir ;; + *) echo bad subdir; exit 1 ;; + esac && + case "`git diff-files --name-only .`" in + dir/two) echo pass subdir limited ;; + *) echo bad subdir limited; exit 1 ;; + esac + ) ' test_expect_success 'write-tree' ' - cd "$HERE" && top=`git write-tree` && echo $top && - cd dir && - sub=`git write-tree` && - echo $sub && - test "z$top" = "z$sub" + ( + cd dir && + sub=`git write-tree` && + echo $sub && + test "z$top" = "z$sub" + ) ' test_expect_success 'checkout-index' ' - cd "$HERE" && git checkout-index -f -u one && cmp one original.one && - cd dir && - git checkout-index -f -u two && - cmp two ../original.two + ( + cd dir && + git checkout-index -f -u two && + cmp two ../original.two + ) ' test_expect_success 'read-tree' ' - cd "$HERE" && rm -f one dir/two && tree=`git write-tree` && git read-tree --reset -u "$tree" && cmp one original.one && cmp dir/two original.two && - cd dir && - rm -f two && - git read-tree --reset -u "$tree" && - cmp two ../original.two && - cmp ../one ../original.one + ( + cd dir && + rm -f two && + git read-tree --reset -u "$tree" && + cmp two ../original.two && + cmp ../one ../original.one + ) ' test_expect_success 'no file/rev ambiguity check inside .git' ' - cd "$HERE" && git commit -a -m 1 && - cd "$HERE"/.git && - git show -s HEAD + ( + cd .git && + git show -s HEAD + ) ' test_expect_success 'no file/rev ambiguity check inside a bare repo' ' - cd "$HERE" && git clone -s --bare .git foo.git && - cd foo.git && GIT_DIR=. git show -s HEAD + ( + 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" && git clone -s --bare .git foo.git && - cd foo.git && git show -s HEAD + ( + cd foo.git && + git show -s HEAD + ) ' test_expect_success SYMLINKS 'detection should not be fooled by a symlink' ' - cd "$HERE" && rm -fr foo.git && git clone -s .git another && ln -s another yetanother && - cd yetanother/.git && - git show -s HEAD + ( + cd yetanother/.git && + git show -s HEAD + ) ' test_done