{"thread":{"id":"25007","subject":"[PATCH] Several tests: cd inside subshell instead of around","startedAt":"2010-09-06T18:39:54Z","lastAt":"2010-09-07T23:45:16Z","messageCount":27,"participants":["Jens Lehmann","Jonathan Nieder","Junio C Hamano","Jeff King","Thomas Rast","Brad King","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"150107","messageId":"4C85357A.8090000@web.de","threadId":"25007","inReplyTo":null,"subject":"[PATCH] Several tests: cd inside subshell instead of around","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-09-06T18:39:54Z","receivedAt":"2010-09-06T18:39:54Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Fixed all places where it was a straightforward change from cd'ing into a\ndirectory and back via \"cd ..\" to a cd inside a subshell.\n\nFound these places with \"git grep -w \"cd \\.\\.\".\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nThis patch applies to maint.\n\n t/t1020-subdirectory.sh                       |    6 +-\n t/t1302-repo-version.sh                       |    6 +-\n t/t2101-update-index-reupdate.sh              |    6 +-\n t/t3060-ls-files-with-tree.sh                 |    4 +-\n t/t3409-rebase-preserve-merges.sh             |   12 +-\n t/t3903-stash.sh                              |    6 +-\n t/t4041-diff-submodule-option.sh              |    6 +-\n t/t5510-fetch.sh                              |   18 ++--\n t/t6050-replace.sh                            |   22 ++--\n t/t7400-submodule-basic.sh                    |    6 +-\n t/t7401-submodule-summary.sh                  |    6 +-\n t/t9100-git-svn-basic.sh                      |    6 +-\n t/t9101-git-svn-props.sh                      |   16 ++--\n t/t9102-git-svn-deep-rmdir.sh                 |    6 +-\n t/t9104-git-svn-follow-parent.sh              |   30 +++---\n t/t9105-git-svn-commit-diff.sh                |    6 +-\n t/t9106-git-svn-commit-diff-clobber.sh        |   24 +++---\n t/t9107-git-svn-migrate.sh                    |    4 +-\n t/t9114-git-svn-dcommit-merge.sh              |    6 +-\n t/t9115-git-svn-dcommit-funky-renames.sh      |    6 +-\n t/t9116-git-svn-log.sh                        |    4 +-\n t/t9119-git-svn-info.sh                       |  126 ++++++++++++------------\n t/t9120-git-svn-clone-with-percent-escapes.sh |    6 +-\n t/t9123-git-svn-rebuild-with-rewriteroot.sh   |    4 +-\n t/t9125-git-svn-multi-glob-branch-names.sh    |   12 +-\n t/t9127-git-svn-partial-rebuild.sh            |   30 +++---\n t/t9128-git-svn-cmd-branch.sh                 |   18 ++--\n t/t9137-git-svn-dcommit-clobber-series.sh     |   12 +-\n t/t9300-fast-import.sh                        |    5 +-\n t/t9401-git-cvsserver-crlf.sh                 |   53 +++++-----\n t/t9600-cvsimport.sh                          |   38 ++++----\n t/t9603-cvsimport-patchsets.sh                |    6 +-\n 32 files changed, 256 insertions(+), 260 deletions(-)\n\ndiff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh\nindex 5687499..c36157a 100755\n--- a/t/t1020-subdirectory.sh\n+++ b/t/t1020-subdirectory.sh\n@@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' '\n \tone) echo pass one ;;\n \t*) echo bad one; exit 1 ;;\n \tesac &&\n-\tcd dir &&\n+\t(cd dir &&\n \tgit update-index --add two &&\n \tcase \"`git ls-files`\" in\n \ttwo) echo pass two ;;\n \t*) echo bad two; exit 1 ;;\n-\tesac &&\n-\tcd .. &&\n+\tesac\n+\t) &&\n \tcase \"`git ls-files`\" in\n \tdir/two\"$LF\"one) echo pass both ;;\n \t*) echo bad; exit 1 ;;\ndiff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh\nindex 8d305b4..c948719 100755\n--- a/t/t1302-repo-version.sh\n+++ b/t/t1302-repo-version.sh\n@@ -32,9 +32,9 @@ test_expect_success 'gitdir selection on unsupported repo' '\n \ttest \"$(git config core.repositoryformatversion)\" = 99)'\n\n test_expect_success 'gitdir not required mode' '\n-\t(git apply --stat test.patch &&\n-\tcd test && git apply --stat ../test.patch &&\n-\tcd ../test2 && git apply --stat ../test.patch)'\n+\tgit apply --stat test.patch &&\n+\t(cd test && git apply --stat ../test.patch) &&\n+\t(cd test2 && git apply --stat ../test.patch)'\n\n test_expect_success 'gitdir required mode on normal repos' '\n \t(git apply --check --index test.patch &&\ndiff --git a/t/t2101-update-index-reupdate.sh b/t/t2101-update-index-reupdate.sh\nindex 648184f..76ad7c3 100755\n--- a/t/t2101-update-index-reupdate.sh\n+++ b/t/t2101-update-index-reupdate.sh\n@@ -63,10 +63,10 @@ cat > expected <<\\EOF\n EOF\n test_expect_success 'update-index --update from subdir' \\\n \t'echo not so happy >file2 &&\n-\tcd dir1 &&\n+\t(cd dir1 &&\n \tcat ../file2 >file3 &&\n-\tgit update-index --again &&\n-\tcd .. &&\n+\tgit update-index --again\n+\t) &&\n \tgit ls-files -s >current &&\n \tcmp current expected'\n\ndiff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh\nindex 3ce501b..25afb4f 100755\n--- a/t/t3060-ls-files-with-tree.sh\n+++ b/t/t3060-ls-files-with-tree.sh\n@@ -55,15 +55,13 @@ test_expect_success setup '\n\n # We have to run from a sub-directory to trigger prune_path\n # Then we finally get to run our --with-tree test\n-cd sub\n\n test_expect_success 'git -ls-files --with-tree should succeed from subdir' '\n\n-\tgit ls-files --with-tree=HEAD~1 >../output\n+\t(cd sub && git ls-files --with-tree=HEAD~1 >../output)\n\n '\n\n-cd ..\n test_expect_success \\\n     'git -ls-files --with-tree should add entries from named tree.' \\\n     'test_cmp expected output'\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 8f785e7..1a362d2 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -42,23 +42,23 @@ test_expect_success 'setup for merge-preserving rebase' \\\n \tgit commit -a -m \"Modify A2\" &&\n\n \tgit clone ./. clone1 &&\n-\tcd clone1 &&\n+\t(cd clone1 &&\n \tgit checkout -b topic origin/topic &&\n-\tgit merge origin/master &&\n-\tcd .. &&\n+\tgit merge origin/master\n+\t) &&\n\n \techo Fifth > B &&\n \tgit add B &&\n \tgit commit -m \"Add different B\" &&\n\n \tgit clone ./. clone2 &&\n-\tcd clone2 &&\n+\t(cd clone2 &&\n \tgit checkout -b topic origin/topic &&\n \ttest_must_fail git merge origin/master &&\n \techo Resolved > B &&\n \tgit add B &&\n-\tgit commit -m \"Merge origin/master into topic\" &&\n-\tcd .. &&\n+\tgit commit -m \"Merge origin/master into topic\"\n+\t) &&\n\n \tgit checkout topic &&\n \techo Fourth >> B &&\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 62e208a..3f43012 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -69,9 +69,9 @@ test_expect_success 'apply stashed changes (including index)' '\n test_expect_success 'unstashing in a subdirectory' '\n \tgit reset --hard HEAD &&\n \tmkdir subdir &&\n-\tcd subdir &&\n-\tgit stash apply &&\n-\tcd ..\n+\t(cd subdir &&\n+\tgit stash apply\n+\t)\n '\n\n test_expect_success 'drop top stash' '\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 8e391cf..737c3d9 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -85,10 +85,10 @@ EOF\n \"\n\n commit_file sm1 &&\n-cd sm1 &&\n+head3=$(cd sm1 &&\n git reset --hard HEAD~2 >/dev/null &&\n-head3=$(git rev-parse --verify HEAD | cut -c1-7) &&\n-cd ..\n+git rev-parse --verify HEAD | cut -c1-7\n+)\n\n test_expect_success 'modified submodule(backward)' \"\n \tgit diff-index -p --submodule=log HEAD >actual &&\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex 4eb10f6..34d59d5 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -21,18 +21,18 @@ test_expect_success setup '\n\n test_expect_success \"clone and setup child repos\" '\n \tgit clone . one &&\n-\tcd one &&\n+\t(cd one &&\n \techo >file updated by one &&\n-\tgit commit -a -m \"updated by one\" &&\n-\tcd .. &&\n+\tgit commit -a -m \"updated by one\"\n+\t) &&\n \tgit clone . two &&\n-\tcd two &&\n+\t(cd two &&\n \tgit config branch.master.remote one &&\n \tgit config remote.one.url ../one/.git/ &&\n-\tgit config remote.one.fetch refs/heads/master:refs/heads/one &&\n-\tcd .. &&\n+\tgit config remote.one.fetch refs/heads/master:refs/heads/one\n+\t) &&\n \tgit clone . three &&\n-\tcd three &&\n+\t(cd three &&\n \tgit config branch.master.remote two &&\n \tgit config branch.master.merge refs/heads/one &&\n \tmkdir -p .git/remotes &&\n@@ -40,8 +40,8 @@ test_expect_success \"clone and setup child repos\" '\n \t\techo \"URL: ../two/.git/\"\n \t\techo \"Pull: refs/heads/master:refs/heads/two\"\n \t\techo \"Pull: refs/heads/one:refs/heads/one\"\n-\t} >.git/remotes/two &&\n-\tcd .. &&\n+\t} >.git/remotes/two\n+\t) &&\n \tgit clone . bundle &&\n \tgit clone . seven\n '\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex 4185b7c..01dfa51 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -104,7 +104,7 @@ test_expect_success '\"git fsck\" works' '\n test_expect_success 'repack, clone and fetch work' '\n      git repack -a -d &&\n      git clone --no-hardlinks . clone_dir &&\n-     cd clone_dir &&\n+     (cd clone_dir &&\n      git show HEAD~5 | grep \"A U Thor\" &&\n      git show $HASH2 | grep \"A U Thor\" &&\n      git cat-file commit $R &&\n@@ -113,8 +113,8 @@ test_expect_success 'repack, clone and fetch work' '\n      git fetch ../ \"refs/replace/*:refs/replace/*\" &&\n      git show HEAD~5 | grep \"O Thor\" &&\n      git show $HASH2 | grep \"O Thor\" &&\n-     git cat-file commit $R &&\n-     cd ..\n+     git cat-file commit $R\n+     )\n '\n\n test_expect_success '\"git replace\" listing and deleting' '\n@@ -177,10 +177,10 @@ test_expect_success 'create parallel branch without the bug' '\n\n test_expect_success 'push to cloned repo' '\n      git push cloned $HASH6^:refs/heads/parallel &&\n-     cd clone_dir &&\n+     (cd clone_dir &&\n      git checkout parallel &&\n-     git log --pretty=oneline | grep $PARA2 &&\n-     cd ..\n+     git log --pretty=oneline | grep $PARA2\n+     )\n '\n\n test_expect_success 'push branch with replacement' '\n@@ -191,20 +191,20 @@ test_expect_success 'push branch with replacement' '\n      git show $HASH6~2 | grep \"O Thor\" &&\n      git show $PARA3 | grep \"O Thor\" &&\n      git push cloned $HASH6^:refs/heads/parallel2 &&\n-     cd clone_dir &&\n+     (cd clone_dir &&\n      git checkout parallel2 &&\n      git log --pretty=oneline | grep $PARA3 &&\n-     git show $PARA3 | grep \"A U Thor\" &&\n-     cd ..\n+     git show $PARA3 | grep \"A U Thor\"\n+     )\n '\n\n test_expect_success 'fetch branch with replacement' '\n      git branch tofetch $HASH6 &&\n-     cd clone_dir &&\n+     (cd clone_dir &&\n      git fetch origin refs/heads/tofetch:refs/heads/parallel3\n      git log --pretty=oneline parallel3 | grep $PARA3\n      git show $PARA3 | grep \"A U Thor\"\n-     cd ..\n+     )\n '\n\n test_expect_success 'bisect and replacements' '\ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 9bda970..21b0839 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -413,12 +413,12 @@ test_expect_success 'submodule <invalid-path> warns' '\n\n test_expect_success 'add submodules without specifying an explicit path' '\n \tmkdir repo &&\n-\tcd repo &&\n+\t(cd repo &&\n \tgit init &&\n \techo r >r &&\n \tgit add r &&\n-\tgit commit -m \"repo commit 1\" &&\n-\tcd .. &&\n+\tgit commit -m \"repo commit 1\"\n+\t) &&\n \tgit clone --bare repo/ bare.git &&\n \tcd addtest &&\n \tgit submodule add \"$submodurl/repo\" &&\ndiff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh\nindex cee319d..b5ad45f 100755\n--- a/t/t7401-submodule-summary.sh\n+++ b/t/t7401-submodule-summary.sh\n@@ -66,10 +66,10 @@ EOF\n \"\n\n commit_file sm1 &&\n-cd sm1 &&\n+head3=$(cd sm1 &&\n git reset --hard HEAD~2 >/dev/null &&\n-head3=$(git rev-parse --verify HEAD | cut -c1-7) &&\n-cd ..\n+git rev-parse --verify HEAD | cut -c1-7\n+)\n\n test_expect_success 'modified submodule(backward)' \"\n     git submodule summary >actual &&\ndiff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\nindex 13766ab..75388f3 100755\n--- a/t/t9100-git-svn-basic.sh\n+++ b/t/t9100-git-svn-basic.sh\n@@ -22,7 +22,7 @@ esac\n test_expect_success \\\n     'initialize git svn' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \techo foo > foo &&\n \tln -s foo foo.link\n \tmkdir -p dir/a/b/c/d/e &&\n@@ -31,8 +31,8 @@ test_expect_success \\\n \techo \"zzz\" > bar/zzz &&\n \techo \"#!/bin/sh\" > exec.sh &&\n \tchmod +x exec.sh &&\n-\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null &&\n-\tcd .. &&\n+\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null\n+\t) &&\n \trm -rf import &&\n \tgit svn init \"$svnrepo\"'\n\ndiff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh\nindex 929499e..f53a1a9 100755\n--- a/t/t9101-git-svn-props.sh\n+++ b/t/t9101-git-svn-props.sh\n@@ -54,7 +54,7 @@ cd ..\n rm -rf import\n test_expect_success 'checkout working copy from svn' 'svn co \"$svnrepo\" test_wc'\n test_expect_success 'setup some commits to svn' \\\n-\t'cd test_wc &&\n+\t'(cd test_wc &&\n \t\techo Greetings >> kw.c &&\n \t\tpoke kw.c &&\n \t\tsvn_cmd commit -m \"Not yet an Id\" &&\n@@ -63,8 +63,8 @@ test_expect_success 'setup some commits to svn' \\\n \t\tsvn_cmd commit -m \"Modified file, but still not yet an Id\" &&\n \t\tsvn_cmd propset svn:keywords Id kw.c &&\n \t\tpoke kw.c &&\n-\t\tsvn_cmd commit -m \"Propset Id\" &&\n-\tcd ..'\n+\t\tsvn_cmd commit -m \"Propset Id\"\n+\t)'\n\n test_expect_success 'initialize git svn' 'git svn init \"$svnrepo\"'\n test_expect_success 'fetch revisions from svn' 'git svn fetch'\n@@ -82,12 +82,12 @@ got=\"`sed -ne 2p kw.c`\"\n test_expect_success 'raw $Id$ found in kw.c' \"test '$expect' = '$got'\"\n\n test_expect_success \"propset CR on crlf files\" \\\n-\t'cd test_wc &&\n+\t'(cd test_wc &&\n \t\tsvn_cmd propset svn:eol-style CR empty &&\n \t\tsvn_cmd propset svn:eol-style CR crlf &&\n \t\tsvn_cmd propset svn:eol-style CR ne_crlf &&\n-\t\tsvn_cmd commit -m \"propset CR on crlf files\" &&\n-\t cd ..'\n+\t\tsvn_cmd commit -m \"propset CR on crlf files\"\n+\t )'\n\n test_expect_success 'fetch and pull latest from svn and checkout a new wc' \\\n \t'git svn fetch &&\n@@ -137,7 +137,7 @@ cat > show-ignore.expect <<\\EOF\n EOF\n\n test_expect_success 'test show-ignore' \"\n-\tcd test_wc &&\n+\t(cd test_wc &&\n \tmkdir -p deeply/nested/directory &&\n \ttouch deeply/nested/directory/.keep &&\n \tsvn_cmd add deeply &&\n@@ -146,7 +146,7 @@ test_expect_success 'test show-ignore' \"\n no-such-file*\n ' .\n \tsvn_cmd commit -m 'propset svn:ignore'\n-\tcd .. &&\n+\t) &&\n \tgit svn show-ignore > show-ignore.got &&\n \tcmp show-ignore.expect show-ignore.got\n \t\"\ndiff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh\nindex 028fb19..d60a8ef 100755\n--- a/t/t9102-git-svn-deep-rmdir.sh\n+++ b/t/t9102-git-svn-deep-rmdir.sh\n@@ -4,13 +4,13 @@ test_description='git svn rmdir'\n\n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \tmkdir -p deeply/nested/directory/number/1 &&\n \tmkdir -p deeply/nested/directory/number/2 &&\n \techo foo > deeply/nested/directory/number/1/file &&\n \techo foo > deeply/nested/directory/number/2/another &&\n-\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" &&\n-\tcd ..\n+\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\"\n+\t)\n \t'\n\n test_expect_success 'mirror via git svn' '\ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex bbfd7f4..d2f0e92 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -8,13 +8,13 @@ test_description='git svn fetching'\n\n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \tmkdir -p trunk &&\n \techo hello > trunk/readme &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\" &&\n-\tcd .. &&\n+\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t) &&\n \tsvn_cmd co \"$svnrepo\" wc &&\n-\tcd wc &&\n+\t(cd wc &&\n \techo world >> trunk/readme &&\n \tpoke trunk/readme &&\n \tsvn_cmd commit -m \"another commit\" &&\n@@ -22,8 +22,8 @@ test_expect_success 'initialize repo' '\n \tsvn_cmd mv trunk thunk &&\n \techo goodbye >> thunk/readme &&\n \tpoke thunk/readme &&\n-\tsvn_cmd commit -m \"bye now\" &&\n-\tcd ..\n+\tsvn_cmd commit -m \"bye now\"\n+\t)\n \t'\n\n test_expect_success 'init and fetch a moved directory' '\n@@ -85,11 +85,11 @@ test_expect_success 'follow larger parent' '\n test_expect_success 'follow higher-level parent' '\n         svn mkdir -m \"follow higher-level parent\" \"$svnrepo\"/blob &&\n         svn co \"$svnrepo\"/blob blob &&\n-        cd blob &&\n+        (cd blob &&\n                 echo hi > hi &&\n                 svn add hi &&\n-                svn commit -m \"hihi\" &&\n-                cd ..\n+                svn commit -m \"hihi\"\n+                ) &&\n         svn mkdir -m \"new glob at top level\" \"$svnrepo\"/glob &&\n         svn mv -m \"move blob down a level\" \"$svnrepo\"/blob \"$svnrepo\"/glob/blob &&\n         git svn init --minimize-url -i blob \"$svnrepo\"/glob/blob &&\n@@ -117,18 +117,18 @@ test_expect_success 'follow-parent avoids deleting relevant info' '\n \t   import/trunk/subversion/bindings/swig/perl/t/larger-parent &&\n \t  echo \"bad delete test 2\" > \\\n \t   import/trunk/subversion/bindings/swig/perl/another-larger &&\n-\tcd import &&\n-\t  svn import -m \"r9270 test\" . \"$svnrepo\"/r9270 &&\n-\tcd .. &&\n+\t(cd import &&\n+\t  svn import -m \"r9270 test\" . \"$svnrepo\"/r9270\n+\t) &&\n \tsvn_cmd co \"$svnrepo\"/r9270/trunk/subversion/bindings/swig/perl r9270 &&\n-\tcd r9270 &&\n+\t(cd r9270 &&\n \t  svn mkdir native &&\n \t  svn mv t native/t &&\n \t  for i in a b c; do svn mv $i.pm native/$i.pm; done &&\n \t  echo z >> native/t/c.t &&\n \t  poke native/t/c.t &&\n-\t  svn commit -m \"reorg test\" &&\n-\tcd .. &&\n+\t  svn commit -m \"reorg test\"\n+\t) &&\n \tgit svn init --minimize-url -i r9270-t \\\n \t  \"$svnrepo\"/r9270/trunk/subversion/bindings/swig/perl/native/t &&\n \tgit svn fetch -i r9270-t &&\ndiff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh\nindex dd48e9c..d432d83 100755\n--- a/t/t9105-git-svn-commit-diff.sh\n+++ b/t/t9105-git-svn-commit-diff.sh\n@@ -6,10 +6,10 @@ test_description='git svn commit-diff'\n\n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \techo hello > readme &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\" &&\n-\tcd .. &&\n+\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t) &&\n \techo hello > readme &&\n \tgit update-index --add readme &&\n \tgit commit -a -m \"initial\" &&\ndiff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh\nindex 12f21b7..af367a1 100755\n--- a/t/t9106-git-svn-commit-diff-clobber.sh\n+++ b/t/t9106-git-svn-commit-diff-clobber.sh\n@@ -6,21 +6,21 @@ test_description='git svn commit-diff clobber'\n\n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \techo initial > file &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\" &&\n-\tcd .. &&\n+\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t) &&\n \techo initial > file &&\n \tgit update-index --add file &&\n \tgit commit -a -m \"initial\"\n \t'\n test_expect_success 'commit change from svn side' '\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\tcd t.svn &&\n+\t(cd t.svn &&\n \techo second line from svn >> file &&\n \tpoke file &&\n-\tsvn_cmd commit -m \"second line from svn\" &&\n-\tcd .. &&\n+\tsvn_cmd commit -m \"second line from svn\"\n+\t) &&\n \trm -rf t.svn\n \t'\n\n@@ -44,11 +44,11 @@ test_expect_success 'dcommit fails to commit because of conflict' '\n \tgit svn fetch &&\n \tgit reset --hard refs/${remotes_git_svn} &&\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\tcd t.svn &&\n+\t(cd t.svn &&\n \techo fourth line from svn >> file &&\n \tpoke file &&\n-\tsvn_cmd commit -m \"fourth line from svn\" &&\n-\tcd .. &&\n+\tsvn_cmd commit -m \"fourth line from svn\"\n+\t) &&\n \trm -rf t.svn &&\n \techo \"fourth line from git\" >> file &&\n \tgit commit -a -m \"fourth line from git\" &&\n@@ -68,11 +68,11 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' \"\n\n test_expect_success 'commit another change from svn side' '\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\tcd t.svn &&\n+\t(cd t.svn &&\n \t\techo third line from svn >> file &&\n \t\tpoke file &&\n-\t\tsvn_cmd commit -m \"third line from svn\" &&\n-\tcd .. &&\n+\t\tsvn_cmd commit -m \"third line from svn\"\n+\t) &&\n \trm -rf t.svn\n \t'\n\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex 901b8e0..f60b306 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -6,14 +6,14 @@ test_description='git svn metadata migrations from previous versions'\n test_expect_success 'setup old-looking metadata' '\n \tcp \"$GIT_DIR\"/config \"$GIT_DIR\"/config-old-git-svn &&\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \t\tfor i in trunk branches/a branches/b \\\n \t\t         tags/0.1 tags/0.2 tags/0.3; do\n \t\t\tmkdir -p $i && \\\n \t\t\techo hello >> $i/README || exit 1\n \t\tdone && \\\n \t\tsvn_cmd import -m test . \"$svnrepo\"\n-\t\tcd .. &&\n+\t\t) &&\n \tgit svn init \"$svnrepo\" &&\n \tgit svn fetch &&\n \trm -rf \"$GIT_DIR\"/svn &&\ndiff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh\nindex 84f7c9b..a7d0c7d 100755\n--- a/t/t9114-git-svn-dcommit-merge.sh\n+++ b/t/t9114-git-svn-dcommit-merge.sh\n@@ -37,11 +37,11 @@ EOF\n test_expect_success 'setup svn repository' '\n \tsvn_cmd co \"$svnrepo\" mysvnwork &&\n \tmkdir -p mysvnwork/trunk &&\n-\tcd mysvnwork &&\n+\t(cd mysvnwork &&\n \t\tbig_text_block >> trunk/README &&\n \t\tsvn_cmd add trunk &&\n-\t\tsvn_cmd ci -m \"first commit\" trunk &&\n-\t\tcd ..\n+\t\tsvn_cmd ci -m \"first commit\" trunk\n+\t\t)\n \t'\n\n test_expect_success 'setup git mirror and merge' '\ndiff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh\nindex 767799e..9fdbc9b 100755\n--- a/t/t9115-git-svn-dcommit-funky-renames.sh\n+++ b/t/t9115-git-svn-dcommit-funky-renames.sh\n@@ -61,11 +61,11 @@ test_expect_success 'add a file with plus signs' '\n\n test_expect_success 'clone the repository to test rebase' '\n \tgit svn clone \"$svnrepo\" test-rebase &&\n-\tcd test-rebase &&\n+\t(cd test-rebase &&\n \t\techo test-rebase > test-rebase &&\n \t\tgit add test-rebase &&\n-\t\tgit commit -m test-rebase &&\n-\t\tcd ..\n+\t\tgit commit -m test-rebase\n+\t\t)\n \t'\n\n test_expect_success 'make a commit to test rebase' '\ndiff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh\nindex 0374a74..244b5cd 100755\n--- a/t/t9116-git-svn-log.sh\n+++ b/t/t9116-git-svn-log.sh\n@@ -8,14 +8,14 @@ test_description='git svn log tests'\n\n test_expect_success 'setup repository and import' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \t\tfor i in trunk branches/a branches/b \\\n \t\t         tags/0.1 tags/0.2 tags/0.3; do\n \t\t\tmkdir -p $i && \\\n \t\t\techo hello >> $i/README || exit 1\n \t\tdone && \\\n \t\tsvn_cmd import -m test . \"$svnrepo\"\n-\t\tcd .. &&\n+\t\t) &&\n \tgit svn init \"$svnrepo\" -T trunk -b branches -t tags &&\n \tgit svn fetch &&\n \tgit reset --hard trunk &&\ndiff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh\nindex 5fb94fb..e3f08c4 100755\n--- a/t/t9119-git-svn-info.sh\n+++ b/t/t9119-git-svn-info.sh\n@@ -39,27 +39,27 @@ quoted_svnrepo=\"$(echo $svnrepo | sed 's/ /%20/')\"\n\n test_expect_success 'setup repository and import' '\n \tmkdir info &&\n-\tcd info &&\n+\t(cd info &&\n \t\techo FIRST > A &&\n \t\techo one > file &&\n \t\tln -s file symlink-file &&\n \t\tmkdir directory &&\n \t\ttouch directory/.placeholder &&\n \t\tln -s directory symlink-directory &&\n-\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\" &&\n-\tcd .. &&\n+\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t) &&\n \tsvn_cmd co \"$svnrepo\" svnwc &&\n-\tcd svnwc &&\n+\t(cd svnwc &&\n \t\techo foo > foo &&\n \t\tsvn_cmd add foo &&\n \t\tsvn_cmd commit -m \"change outside directory\" &&\n-\t\tsvn_cmd update &&\n-\tcd .. &&\n+\t\tsvn_cmd update\n+\t) &&\n \tmkdir gitwc &&\n-\tcd gitwc &&\n+\t(cd gitwc &&\n \t\tgit svn init \"$svnrepo\" &&\n-\t\tgit svn fetch &&\n-\tcd .. &&\n+\t\tgit svn fetch\n+\t) &&\n \tptouch gitwc/file svnwc/file &&\n \tptouch gitwc/directory svnwc/directory &&\n \tptouch gitwc/symlink-file svnwc/symlink-file &&\n@@ -138,14 +138,14 @@ test_expect_success 'info --url symlink-directory' '\n\n test_expect_success 'info added-file' \"\n \techo two > gitwc/added-file &&\n-\tcd gitwc &&\n-\t\tgit add added-file &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tgit add added-file\n+\t) &&\n \tcp gitwc/added-file svnwc/added-file &&\n \tptouch gitwc/added-file svnwc/added-file &&\n-\tcd svnwc &&\n-\t\tsvn_cmd add added-file > /dev/null &&\n-\tcd .. &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd add added-file > /dev/null\n+\t) &&\n \t(cd svnwc; svn info added-file) > expected.info-added-file &&\n \t(cd gitwc; git svn info added-file) > actual.info-added-file &&\n \ttest_cmp expected.info-added-file actual.info-added-file\n@@ -160,12 +160,12 @@ test_expect_success 'info added-directory' \"\n \tmkdir gitwc/added-directory svnwc/added-directory &&\n \tptouch gitwc/added-directory svnwc/added-directory &&\n \ttouch gitwc/added-directory/.placeholder &&\n-\tcd svnwc &&\n-\t\tsvn_cmd add added-directory > /dev/null &&\n-\tcd .. &&\n-\tcd gitwc &&\n-\t\tgit add added-directory &&\n-\tcd .. &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd add added-directory > /dev/null\n+\t) &&\n+\t(cd gitwc &&\n+\t\tgit add added-directory\n+\t) &&\n \t(cd svnwc; svn info added-directory) \\\n \t\t> expected.info-added-directory &&\n \t(cd gitwc; git svn info added-directory) \\\n@@ -179,14 +179,14 @@ test_expect_success 'info --url added-directory' '\n \t'\n\n test_expect_success 'info added-symlink-file' \"\n-\tcd gitwc &&\n+\t(cd gitwc &&\n \t\tln -s added-file added-symlink-file &&\n-\t\tgit add added-symlink-file &&\n-\tcd .. &&\n-\tcd svnwc &&\n+\t\tgit add added-symlink-file\n+\t) &&\n+\t(cd svnwc &&\n \t\tln -s added-file added-symlink-file &&\n-\t\tsvn_cmd add added-symlink-file > /dev/null &&\n-\tcd .. &&\n+\t\tsvn_cmd add added-symlink-file > /dev/null\n+\t) &&\n \tptouch gitwc/added-symlink-file svnwc/added-symlink-file &&\n \t(cd svnwc; svn info added-symlink-file) \\\n \t\t> expected.info-added-symlink-file &&\n@@ -202,14 +202,14 @@ test_expect_success 'info --url added-symlink-file' '\n \t'\n\n test_expect_success 'info added-symlink-directory' \"\n-\tcd gitwc &&\n+\t(cd gitwc &&\n \t\tln -s added-directory added-symlink-directory &&\n-\t\tgit add added-symlink-directory &&\n-\tcd .. &&\n-\tcd svnwc &&\n+\t\tgit add added-symlink-directory\n+\t) &&\n+\t(cd svnwc &&\n \t\tln -s added-directory added-symlink-directory &&\n-\t\tsvn_cmd add added-symlink-directory > /dev/null &&\n-\tcd .. &&\n+\t\tsvn_cmd add added-symlink-directory > /dev/null\n+\t) &&\n \tptouch gitwc/added-symlink-directory svnwc/added-symlink-directory &&\n \t(cd svnwc; svn info added-symlink-directory) \\\n \t\t> expected.info-added-symlink-directory &&\n@@ -230,12 +230,12 @@ test_expect_success 'info --url added-symlink-directory' '\n # simply reuses the Last Changed Date.\n\n test_expect_success 'info deleted-file' \"\n-\tcd gitwc &&\n-\t\tgit rm -f file > /dev/null &&\n-\tcd .. &&\n-\tcd svnwc &&\n-\t\tsvn_cmd rm --force file > /dev/null &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tgit rm -f file > /dev/null\n+\t) &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd rm --force file > /dev/null\n+\t) &&\n \t(cd svnwc; svn info file) |\n \tsed -e 's/^\\(Text Last Updated:\\).*/\\1 TEXT-LAST-UPDATED-STRING/' \\\n \t\t> expected.info-deleted-file &&\n@@ -251,12 +251,12 @@ test_expect_success 'info --url file (deleted)' '\n \t'\n\n test_expect_success 'info deleted-directory' \"\n-\tcd gitwc &&\n-\t\tgit rm -r -f directory > /dev/null &&\n-\tcd .. &&\n-\tcd svnwc &&\n-\t\tsvn_cmd rm --force directory > /dev/null &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tgit rm -r -f directory > /dev/null\n+\t) &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd rm --force directory > /dev/null\n+\t) &&\n \t(cd svnwc; svn info directory) |\n \tsed -e 's/^\\(Text Last Updated:\\).*/\\1 TEXT-LAST-UPDATED-STRING/' \\\n \t\t> expected.info-deleted-directory &&\n@@ -272,12 +272,12 @@ test_expect_success 'info --url directory (deleted)' '\n \t'\n\n test_expect_success 'info deleted-symlink-file' \"\n-\tcd gitwc &&\n-\t\tgit rm -f symlink-file > /dev/null &&\n-\tcd .. &&\n-\tcd svnwc &&\n-\t\tsvn_cmd rm --force symlink-file > /dev/null &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tgit rm -f symlink-file > /dev/null\n+\t) &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd rm --force symlink-file > /dev/null\n+\t) &&\n \t(cd svnwc; svn info symlink-file) |\n \tsed -e 's/^\\(Text Last Updated:\\).*/\\1 TEXT-LAST-UPDATED-STRING/' \\\n \t\t> expected.info-deleted-symlink-file &&\n@@ -294,12 +294,12 @@ test_expect_success 'info --url symlink-file (deleted)' '\n \t'\n\n test_expect_success 'info deleted-symlink-directory' \"\n-\tcd gitwc &&\n-\t\tgit rm -f symlink-directory > /dev/null &&\n-\tcd .. &&\n-\tcd svnwc &&\n-\t\tsvn_cmd rm --force symlink-directory > /dev/null &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tgit rm -f symlink-directory > /dev/null\n+\t) &&\n+\t(cd svnwc &&\n+\t\tsvn_cmd rm --force symlink-directory > /dev/null\n+\t) &&\n \t(cd svnwc; svn info symlink-directory) |\n \tsed -e 's/^\\(Text Last Updated:\\).*/\\1 TEXT-LAST-UPDATED-STRING/' \\\n \t\t > expected.info-deleted-symlink-directory &&\n@@ -346,9 +346,9 @@ test_expect_success 'info --url unknown-directory' '\n \t'\n\n test_expect_success 'info unknown-symlink-file' \"\n-\tcd gitwc &&\n-\t\tln -s unknown-file unknown-symlink-file &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tln -s unknown-file unknown-symlink-file\n+\t) &&\n \t(cd gitwc; test_must_fail git svn info unknown-symlink-file) \\\n \t\t 2> actual.info-unknown-symlink-file &&\n \tgrep unknown-symlink-file actual.info-unknown-symlink-file\n@@ -361,9 +361,9 @@ test_expect_success 'info --url unknown-symlink-file' '\n \t'\n\n test_expect_success 'info unknown-symlink-directory' \"\n-\tcd gitwc &&\n-\t\tln -s unknown-directory unknown-symlink-directory &&\n-\tcd .. &&\n+\t(cd gitwc &&\n+\t\tln -s unknown-directory unknown-symlink-directory\n+\t) &&\n \t(cd gitwc; test_must_fail git svn info unknown-symlink-directory) \\\n \t\t 2> actual.info-unknown-symlink-directory &&\n \tgrep unknown-symlink-directory actual.info-unknown-symlink-directory\ndiff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh\nindex 9d9ebd5..cddb9d4 100755\n--- a/t/t9120-git-svn-clone-with-percent-escapes.sh\n+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh\n@@ -20,9 +20,9 @@ test_expect_success 'setup svnrepo' '\n\n test_expect_success 'test clone with percent escapes' '\n \tgit svn clone \"$svnrepo/pr%20ject\" clone &&\n-\tcd clone &&\n-\t\tgit rev-parse refs/${remotes_git_svn} &&\n-\tcd ..\n+\t(cd clone &&\n+\t\tgit rev-parse refs/${remotes_git_svn}\n+\t)\n '\n\n # SVN works either way, so should we...\ndiff --git a/t/t9123-git-svn-rebuild-with-rewriteroot.sh b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\nindex 0455216..0ed90d9 100755\n--- a/t/t9123-git-svn-rebuild-with-rewriteroot.sh\n+++ b/t/t9123-git-svn-rebuild-with-rewriteroot.sh\n@@ -8,10 +8,10 @@ test_description='git svn respects rewriteRoot during rebuild'\n . ./lib-git-svn.sh\n\n mkdir import\n-cd import\n+(cd import\n \ttouch foo\n \tsvn_cmd import -m 'import for git svn' . \"$svnrepo\" >/dev/null\n-cd ..\n+)\n rm -rf import\n\n test_expect_success 'init, fetch and checkout repository' '\ndiff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh\nindex c194186..096abd1 100755\n--- a/t/t9125-git-svn-multi-glob-branch-names.sh\n+++ b/t/t9125-git-svn-multi-glob-branch-names.sh\n@@ -19,19 +19,19 @@ test_expect_success 'setup svnrepo' '\n test_expect_success 'test clone with multi-glob in branch names' '\n \tgit svn clone -T trunk -b branches/*/* -t tags \\\n \t              \"$svnrepo/project\" project &&\n-\tcd project &&\n+\t(cd project &&\n \t\tgit rev-parse \"refs/remotes/v14.1/beta\" &&\n-\t\tgit rev-parse \"refs/remotes/v14.1/gold\" &&\n-\tcd ..\n+\t\tgit rev-parse \"refs/remotes/v14.1/gold\"\n+\t)\n \t'\n\n test_expect_success 'test dcommit to multi-globbed branch' \"\n-\tcd project &&\n+\t(cd project &&\n \tgit reset --hard 'refs/remotes/v14.1/gold' &&\n \techo hello >> foo &&\n \tgit commit -m 'hello' -- foo &&\n-\tgit svn dcommit &&\n-\tcd ..\n+\tgit svn dcommit\n+\t)\n \t\"\n\n test_done\ndiff --git a/t/t9127-git-svn-partial-rebuild.sh b/t/t9127-git-svn-partial-rebuild.sh\nindex 4aab8ec..2e4789d 100755\n--- a/t/t9127-git-svn-partial-rebuild.sh\n+++ b/t/t9127-git-svn-partial-rebuild.sh\n@@ -9,27 +9,27 @@ test_description='git svn partial-rebuild tests'\n test_expect_success 'initialize svnrepo' '\n \tmkdir import &&\n \t(\n-\t\tcd import &&\n+\t\t(cd import &&\n \t\tmkdir trunk branches tags &&\n-\t\tcd trunk &&\n-\t\techo foo > foo &&\n-\t\tcd .. &&\n+\t\t(cd trunk &&\n+\t\techo foo > foo\n+\t\t) &&\n \t\tsvn_cmd import -m \"import for git-svn\" . \"$svnrepo\" >/dev/null &&\n \t\tsvn_cmd copy \"$svnrepo\"/trunk \"$svnrepo\"/branches/a \\\n-\t\t\t-m \"created branch a\" &&\n-\t\tcd .. &&\n+\t\t\t-m \"created branch a\"\n+\t\t) &&\n \t\trm -rf import &&\n \t\tsvn_cmd co \"$svnrepo\"/trunk trunk &&\n-\t\tcd trunk &&\n+\t\t(cd trunk &&\n \t\techo bar >> foo &&\n-\t\tsvn_cmd ci -m \"updated trunk\" &&\n-\t\tcd .. &&\n+\t\tsvn_cmd ci -m \"updated trunk\"\n+\t\t) &&\n \t\tsvn_cmd co \"$svnrepo\"/branches/a a &&\n-\t\tcd a &&\n+\t\t(cd a &&\n \t\techo baz >> a &&\n \t\tsvn_cmd add a &&\n-\t\tsvn_cmd ci -m \"updated a\" &&\n-\t\tcd .. &&\n+\t\tsvn_cmd ci -m \"updated a\"\n+\t\t) &&\n \t\tgit svn init --stdlayout \"$svnrepo\"\n \t)\n '\n@@ -41,11 +41,11 @@ test_expect_success 'import an early SVN revision into git' '\n test_expect_success 'make full git mirror of SVN' '\n \tmkdir mirror &&\n \t(\n-\t\tcd mirror &&\n+\t\t(cd mirror &&\n \t\tgit init &&\n \t\tgit svn init --stdlayout \"$svnrepo\" &&\n-\t\tgit svn fetch &&\n-\t\tcd ..\n+\t\tgit svn fetch\n+\t\t)\n \t)\n '\n\ndiff --git a/t/t9128-git-svn-cmd-branch.sh b/t/t9128-git-svn-cmd-branch.sh\nindex 807e494..4b034a6 100755\n--- a/t/t9128-git-svn-cmd-branch.sh\n+++ b/t/t9128-git-svn-cmd-branch.sh\n@@ -9,19 +9,19 @@ test_description='git svn partial-rebuild tests'\n test_expect_success 'initialize svnrepo' '\n \tmkdir import &&\n \t(\n-\t\tcd import &&\n+\t\t(cd import &&\n \t\tmkdir trunk branches tags &&\n-\t\tcd trunk &&\n-\t\techo foo > foo &&\n-\t\tcd .. &&\n-\t\tsvn_cmd import -m \"import for git-svn\" . \"$svnrepo\" >/dev/null &&\n-\t\tcd .. &&\n+\t\t(cd trunk &&\n+\t\techo foo > foo\n+\t\t) &&\n+\t\tsvn_cmd import -m \"import for git-svn\" . \"$svnrepo\" >/dev/null\n+\t\t) &&\n \t\trm -rf import &&\n \t\tsvn_cmd co \"$svnrepo\"/trunk trunk &&\n-\t\tcd trunk &&\n+\t\t(cd trunk &&\n \t\techo bar >> foo &&\n-\t\tsvn_cmd ci -m \"updated trunk\" &&\n-\t\tcd .. &&\n+\t\tsvn_cmd ci -m \"updated trunk\"\n+\t\t) &&\n \t\trm -rf trunk\n \t)\n '\ndiff --git a/t/t9137-git-svn-dcommit-clobber-series.sh b/t/t9137-git-svn-dcommit-clobber-series.sh\nindex 636ca0a..d60da63 100755\n--- a/t/t9137-git-svn-dcommit-clobber-series.sh\n+++ b/t/t9137-git-svn-dcommit-clobber-series.sh\n@@ -6,10 +6,10 @@ test_description='git svn dcommit clobber series'\n\n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\tcd import &&\n+\t(cd import &&\n \tawk \"BEGIN { for (i = 1; i < 64; i++) { print i } }\" > file\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\" &&\n-\tcd .. &&\n+\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t) &&\n \tgit svn init \"$svnrepo\" &&\n \tgit svn fetch &&\n \ttest -e file\n@@ -19,14 +19,14 @@ test_expect_success '(supposedly) non-conflicting change from SVN' '\n \ttest x\"`sed -n -e 58p < file`\" = x58 &&\n \ttest x\"`sed -n -e 61p < file`\" = x61 &&\n \tsvn_cmd co \"$svnrepo\" tmp &&\n-\tcd tmp &&\n+\t(cd tmp &&\n \t\tperl -i.bak -p -e \"s/^58$/5588/\" file &&\n \t\tperl -i.bak -p -e \"s/^61$/6611/\" file &&\n \t\tpoke file &&\n \t\ttest x\"`sed -n -e 58p < file`\" = x5588 &&\n \t\ttest x\"`sed -n -e 61p < file`\" = x6611 &&\n-\t\tsvn_cmd commit -m \"58 => 5588, 61 => 6611\" &&\n-\t\tcd ..\n+\t\tsvn_cmd commit -m \"58 => 5588, 61 => 6611\"\n+\t)\n \t'\n\n test_expect_success 'some unrelated changes to git' \"\ndiff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh\nindex 2aeed7b..1a205a4 100755\n--- a/t/t9300-fast-import.sh\n+++ b/t/t9300-fast-import.sh\n@@ -1056,11 +1056,10 @@ test_expect_success \\\n \t'P: supermodule & submodule mix' \\\n \t'git fast-import <input &&\n \t git checkout subuse1 &&\n-\t rm -rf sub && mkdir sub && cd sub &&\n+\t rm -rf sub && mkdir sub && (cd sub &&\n \t git init &&\n \t git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&\n-\t git checkout master &&\n-\t cd .. &&\n+\t git checkout master) &&\n \t git submodule init &&\n \t git submodule update'\n\ndiff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh\nindex 925bd0f..1bbfd82 100755\n--- a/t/t9401-git-cvsserver-crlf.sh\n+++ b/t/t9401-git-cvsserver-crlf.sh\n@@ -129,21 +129,22 @@ test_expect_success 'cvs co (use attributes)' '\n '\n\n test_expect_success 'adding files' '\n-    cd cvswork/subdir &&\n+    (cd cvswork &&\n+    (cd subdir &&\n     echo \"more text\" > src.c &&\n     GIT_CONFIG=\"$git_config\" cvs -Q add src.c >cvs.log 2>&1 &&\n     marked_as . src.c \"\" &&\n-    echo \"psuedo-binary\" > temp.bin &&\n-    cd .. &&\n+    echo \"psuedo-binary\" > temp.bin\n+    ) &&\n     GIT_CONFIG=\"$git_config\" cvs -Q add subdir/temp.bin >cvs.log 2>&1 &&\n     marked_as subdir temp.bin \"-kb\" &&\n     cd subdir &&\n     GIT_CONFIG=\"$git_config\" cvs -Q ci -m \"adding files\" >cvs.log 2>&1 &&\n     marked_as . temp.bin \"-kb\" &&\n     marked_as . src.c \"\"\n+    )\n '\n\n-cd \"$WORKDIR\"\n test_expect_success 'updating' '\n     git pull gitcvs.git &&\n     echo 'hi' > subdir/newfile.bin &&\n@@ -153,9 +154,9 @@ test_expect_success 'updating' '\n     git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&\n     git commit -q -m \"Add and change some files\" &&\n     git push gitcvs.git >/dev/null &&\n-    cd cvswork &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q update &&\n-    cd .. &&\n+    (cd cvswork &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q update\n+    ) &&\n     marked_as cvswork textfile.c \"\" &&\n     marked_as cvswork binfile.bin -kb &&\n     marked_as cvswork .gitattributes \"\" &&\n@@ -233,35 +234,35 @@ test_expect_success 'cvs co another copy (guess)' '\n '\n\n test_expect_success 'add text (guess)' '\n-    cd cvswork &&\n+    (cd cvswork &&\n     echo \"simpleText\" > simpleText.c &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q add simpleText.c &&\n-    cd .. &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q add simpleText.c\n+    ) &&\n     marked_as cvswork simpleText.c \"\"\n '\n\n test_expect_success 'add bin (guess)' '\n-    cd cvswork &&\n+    (cd cvswork &&\n     echo \"simpleBin: NUL: Q <- there\" | q_to_nul > simpleBin.bin &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q add simpleBin.bin &&\n-    cd .. &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q add simpleBin.bin\n+    ) &&\n     marked_as cvswork simpleBin.bin -kb\n '\n\n test_expect_success 'remove files (guess)' '\n-    cd cvswork &&\n+    (cd cvswork &&\n     GIT_CONFIG=\"$git_config\" cvs -Q rm -f subdir/file.h &&\n-    cd subdir &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q rm -f withCr.bin &&\n-    cd ../.. &&\n+    (cd subdir &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q rm -f withCr.bin\n+    )) &&\n     marked_as cvswork/subdir withCr.bin -kb &&\n     marked_as cvswork/subdir file.h \"\"\n '\n\n test_expect_success 'cvs ci (guess)' '\n-    cd cvswork &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q ci -m \"add/rm files\" >cvs.log 2>&1 &&\n-    cd .. &&\n+    (cd cvswork &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q ci -m \"add/rm files\" >cvs.log 2>&1\n+    ) &&\n     marked_as cvswork textfile.c \"\" &&\n     marked_as cvswork binfile.bin -kb &&\n     marked_as cvswork .gitattributes \"\" &&\n@@ -278,9 +279,9 @@ test_expect_success 'cvs ci (guess)' '\n '\n\n test_expect_success 'update subdir of other copy (guess)' '\n-    cd cvswork2/subdir &&\n-    GIT_CONFIG=\"$git_config\" cvs -Q update &&\n-    cd ../.. &&\n+    (cd cvswork2/subdir &&\n+    GIT_CONFIG=\"$git_config\" cvs -Q update\n+    ) &&\n     marked_as cvswork2 textfile.c \"\" &&\n     marked_as cvswork2 binfile.bin -kb &&\n     marked_as cvswork2 .gitattributes \"\" &&\n@@ -304,11 +305,11 @@ test_expect_success 'update/merge full other copy (guess)' '\n     git add multilineTxt.c &&\n     git commit -q -m \"modify multiline file\" >> \"${WORKDIR}/marked.log\" &&\n     git push gitcvs.git >/dev/null &&\n-    cd cvswork2 &&\n+    (cd cvswork2 &&\n     sed \"s/1/replaced_1/\" < multilineTxt.c > ml.temp &&\n     mv ml.temp multilineTxt.c &&\n-    GIT_CONFIG=\"$git_config\" cvs update > cvs.log 2>&1 &&\n-    cd .. &&\n+    GIT_CONFIG=\"$git_config\" cvs update > cvs.log 2>&1\n+    ) &&\n     marked_as cvswork2 textfile.c \"\" &&\n     marked_as cvswork2 binfile.bin -kb &&\n     marked_as cvswork2 .gitattributes \"\" &&\ndiff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh\nindex 2eff9cd..6ef1c34 100755\n--- a/t/t9600-cvsimport.sh\n+++ b/t/t9600-cvsimport.sh\n@@ -17,7 +17,7 @@ test_expect_success 'setup a cvs module' '\n\n \tmkdir \"$CVSROOT/module\" &&\n \t$CVS co -d module-cvs module &&\n-\tcd module-cvs &&\n+\t(cd module-cvs &&\n \tcat <<EOF >o_fortuna &&\n O Fortuna\n velut luna\n@@ -41,8 +41,8 @@ add \"O Fortuna\" lyrics\n\n These public domain lyrics make an excellent sample text.\n EOF\n-\t$CVS commit -F message &&\n-\tcd ..\n+\t$CVS commit -F message\n+\t)\n '\n\n test_expect_success 'import a trivial module' '\n@@ -52,7 +52,7 @@ test_expect_success 'import a trivial module' '\n\n '\n\n-test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'\n+test_expect_success 'pack refs' '(cd module-git && git gc)'\n\n test_expect_success 'initial import has correct .git/cvs-revisions' '\n\n@@ -62,8 +62,7 @@ test_expect_success 'initial import has correct .git/cvs-revisions' '\n '\n\n test_expect_success 'update cvs module' '\n-\n-\tcd module-cvs &&\n+\t(cd module-cvs &&\n \tcat <<EOF >o_fortuna &&\n O Fortune,\n like the moon\n@@ -86,16 +85,16 @@ translate to English\n\n My Latin is terrible.\n EOF\n-\t$CVS commit -F message &&\n-\tcd ..\n+\t$CVS commit -F message\n+\t)\n '\n\n test_expect_success 'update git module' '\n\n-\tcd module-git &&\n+\t(cd module-git &&\n \tgit cvsimport -a -R -z 0 module &&\n-\tgit merge origin &&\n-\tcd .. &&\n+\tgit merge origin\n+\t) &&\n \ttest_cmp module-cvs/o_fortuna module-git/o_fortuna\n\n '\n@@ -110,21 +109,20 @@ test_expect_success 'update has correct .git/cvs-revisions' '\n\n test_expect_success 'update cvs module' '\n\n-\tcd module-cvs &&\n+\t(cd module-cvs &&\n \t\techo 1 >tick &&\n \t\t$CVS add tick &&\n \t\t$CVS commit -m 1\n-\tcd ..\n-\n+\t)\n '\n\n test_expect_success 'cvsimport.module config works' '\n\n-\tcd module-git &&\n+\t(cd module-git &&\n \t\tgit config cvsimport.module module &&\n \t\tgit cvsimport -a -R -z0 &&\n-\t\tgit merge origin &&\n-\tcd .. &&\n+\t\tgit merge origin\n+\t) &&\n \ttest_cmp module-cvs/tick module-git/tick\n\n '\n@@ -141,12 +139,12 @@ test_expect_success 'second update has correct .git/cvs-revisions' '\n test_expect_success 'import from a CVS working tree' '\n\n \t$CVS co -d import-from-wt module &&\n-\tcd import-from-wt &&\n+\t(cd import-from-wt &&\n \t\tgit cvsimport -a -z0 &&\n \t\techo 1 >expect &&\n \t\tgit log -1 --pretty=format:%s%n >actual &&\n-\t\ttest_cmp actual expect &&\n-\tcd ..\n+\t\ttest_cmp actual expect\n+\t)\n\n '\n\ndiff --git a/t/t9603-cvsimport-patchsets.sh b/t/t9603-cvsimport-patchsets.sh\nindex 958bdce..6733f0f 100755\n--- a/t/t9603-cvsimport-patchsets.sh\n+++ b/t/t9603-cvsimport-patchsets.sh\n@@ -20,12 +20,12 @@ export CVSROOT\n test_expect_failure 'import with criss cross times on revisions' '\n\n     git cvsimport -p\"-x\" -C module-git module &&\n-    cd module-git &&\n+    (cd module-git &&\n         git log --pretty=format:%s > ../actual-master &&\n         git log A~2..A --pretty=\"format:%s %ad\" -- > ../actual-A &&\n         echo \"\" >> ../actual-master &&\n-        echo \"\" >> ../actual-A &&\n-    cd .. &&\n+        echo \"\" >> ../actual-A\n+    ) &&\n     echo \"Rev 4\n Rev 3\n Rev 2\n-- \n1.7.3.rc0.181.g885f40\n"},{"id":"150113","messageId":"20100906190655.GG25426@burratino","threadId":"25007","inReplyTo":"4C85357A.8090000@web.de","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-06T19:06:55Z","receivedAt":"2010-09-06T19:06:55Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jens Lehmann wrote:\n\n> Fixed all places where it was a straightforward change from cd'ing into a\n> directory and back via \"cd ..\" to a cd inside a subshell.\n\nThanks, Jens.\n\n> Found these places with \"git grep -w \"cd \\.\\.\".\n\nI assume that \"sed\"-ing out all parentheses would make the diff very\nsmall and readable.\n\nDo you think it would be a bad idea if I send a follow-on patch that\nchanges code like this:\n\n\t(cd dir &&\n \tgit update-index --add two &&\n \tcase \"`git ls-files`\" in\n \ttwo) echo pass two ;;\n \t*) echo bad two; exit 1 ;;\n\tesac\n\t) &&\n\nto this:\n\n\t(\n\t\tcd dir &&\n\t\tgit update-index --add two &&\n\t\tcase \"`git ls-files`\" in\n\t\ttwo) echo pass two ;;\n\t\t*) echo bad two; exit 1 ;;\n\t\tesac\n\t)\n\nIt would have the benefit of touching all code in the subshell, so we\ncould see the effect on \"exit\" commands and whatnot.\n"},{"id":"150121","messageId":"4C854B36.6010606@web.de","threadId":"25007","inReplyTo":"20100906190655.GG25426@burratino","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-09-06T20:12:38Z","receivedAt":"2010-09-06T20:12:38Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 06.09.2010 21:06, schrieb Jonathan Nieder:\n> Do you think it would be a bad idea if I send a follow-on patch that\n> changes code like this:\n> \n> \t(cd dir &&\n>  \tgit update-index --add two &&\n>  \tcase \"`git ls-files`\" in\n>  \ttwo) echo pass two ;;\n>  \t*) echo bad two; exit 1 ;;\n> \tesac\n> \t) &&\n> \n> to this:\n> \n> \t(\n> \t\tcd dir &&\n> \t\tgit update-index --add two &&\n> \t\tcase \"`git ls-files`\" in\n> \t\ttwo) echo pass two ;;\n> \t\t*) echo bad two; exit 1 ;;\n> \t\tesac\n> \t)\n> \n> It would have the benefit of touching all code in the subshell, so we\n> could see the effect on \"exit\" commands and whatnot.\n\nI think that makes a lot of sense. I think you would not only end up\nchanging the indentation of many subshells (not only those that I\nadded), you will also have to deal with tests using spaces instead of\ntabs for indentation. But these issues have to be addressed anyway ...\n"},{"id":"150149","messageId":"7vhbi2tqd0.fsf@alter.siamese.dyndns.org","threadId":"25007","inReplyTo":"4C85357A.8090000@web.de","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-06T23:16:27Z","receivedAt":"2010-09-06T23:16:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> Fixed all places where it was a straightforward change from cd'ing into a\n> directory and back via \"cd ..\" to a cd inside a subshell.\n>\n> Found these places with \"git grep -w \"cd \\.\\.\".\n>\n> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n> ---\n\nThanks; that is a huge effort of cleaning things up.\n\n> diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh\n> index 5687499..c36157a 100755\n> --- a/t/t1020-subdirectory.sh\n> +++ b/t/t1020-subdirectory.sh\n> @@ -27,13 +27,13 @@ test_expect_success 'update-index and ls-files' '\n>  \tone) echo pass one ;;\n>  \t*) echo bad one; exit 1 ;;\n>  \tesac &&\n> -\tcd dir &&\n> +\t(cd dir &&\n>  \tgit update-index --add two &&\n>  \tcase \"`git ls-files`\" in\n>  \ttwo) echo pass two ;;\n>  \t*) echo bad two; exit 1 ;;\n> -\tesac &&\n> -\tcd .. &&\n> +\tesac\n> +\t) &&\n>  \tcase \"`git ls-files`\" in\n>  \tdir/two\"$LF\"one) echo pass both ;;\n>  \t*) echo bad; exit 1 ;;\n\nIf we were to do this, shouldn't we be able to lose 'cd \"$HERE\"' at the\nbeginning of each test?  The test after this one does \"cd dir\" without\neven coming back up and relies on the next one to go back itself,\nsuggesting that grepping for 'cd ..' may not be sufficient, depending on\nwhat we are trying to fix.\n\nIf we were to insist that no matter how an individual test fail, the test\nthat follows it must start in a known location (namely, $TRASH), then we\nmight want to use something like the attached patch.  On the other hand,\nwe might want to be lenient to a test suite whose one test moves around\nand the test that follows such a test knows that, and also anticipates\nthat the previous one _can_ fail and tries recover from that failure (e.g.\nuse of 'cd \"$HERE\"' in the test that follows the above one.\n\nThoughts?\n\n\n t/test-lib.sh |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 29fd720..f07f275 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -432,10 +432,14 @@ test_expect_success () {\n \terror \"bug in the test script: not 2 or 3 parameters to test-expect-success\"\n \tif ! test_skip \"$@\"\n \tthen\n+\t\ttest \",$TRASH_DIRECTORY\" = \",$(pwd)\" ||\n+\t\terror \"bug in the test script: starting from a different directory\"\n \t\tsay >&3 \"expecting success: $2\"\n \t\ttest_run_ \"$2\"\n \t\tif [ \"$?\" = 0 -a \"$eval_ret\" = 0 ]\n \t\tthen\n+\t\t\ttest \",$TRASH_DIRECTORY\" = \",$(pwd)\" ||\n+\t\t\terror \"bug in the test script: moved to a different directory\"\n \t\t\ttest_ok_ \"$1\"\n \t\telse\n \t\t\ttest_failure_ \"$@\"\n"},{"id":"150167","messageId":"20100907014135.GA1182@burratino","threadId":"25007","inReplyTo":"4C854B36.6010606@web.de","subject":"[PATCH 0/7] Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:41:35Z","receivedAt":"2010-09-07T01:41:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jens Lehmann wrote:\n\n> I think that makes a lot of sense. I think you would not only end up\n> changing the indentation of many subshells (not only those that I\n> added), you will also have to deal with tests using spaces instead of\n> tabs for indentation. But these issues have to be addressed anyway ...\n\nHmm, it seems there are quite a lot of strange uses of subshells in\ntests.  I have only started the task you describe.  But here are\na couple of patches of that kind.\n\nPatch 1 re-indents the subshells you introduced.  I have not checked\nthat those subshells are all semantically neutral (and in fact some\nseem not to be, but I think for the better); in fact, the main goal of\nthat patch is to help other people review yours.\n\nPatch 2 teaches the fsck tests to use test_when_finished.  This\ncauses some pointless subshells to be removed, and more importantly,\nit fixes the cleanup to actually work, so there are no dangling\nobjects by the end.\n\nPatch 3 adds a missing && in t2105 (.git file pointing to .git dir).  \nThe style cleanup for that file has been done locally but I do not\nthink it's worth sending yet.\n\nPatch 4 teaches the \"unwritable file\" error handling tests to use\ntest_when_finished.  This causes some pointless subshells to be\nremoved, and more importantly, it simplifies the script a lot.\n\nPatch 5 is a style cleanup for the core.repositoryversion tests\n(mostly to do with formatting of subshells, but there are other\nthings).\n\nPatch 6: likewise, for the git config tests.\n\nPatch 7 is perhaps iffy.  I find it easier to read\n\n\tprintf \"%s\\n\" some long list of lines\n\nthan\n\n\t(echo some; echo long; echo list; echo of; echo lines)\n\nbut others might disagree; anyway, this patch change the latter\nto the former (and adds a missing && while at it).\n\nI hope such mundane patches are not too painful to read.\n\nJonathan Nieder (7):\n  tests: subshell indentation stylefix\n  t1450 (fsck): remove dangling objects\n  t2105 (gitlink): add missing &&\n  t0004 (core): simplify error handling\n  t1302 (core.repositoryversion): style tweaks\n  t1303 (config): style tweaks\n  t2016 (checkout -p): use printf for multiline y/n input\n\n t/t0004-unwritable.sh                         |   52 +++-------\n t/t1020-subdirectory.sh                       |   13 ++-\n t/t1302-repo-version.sh                       |   75 +++++++++-----\n t/t1303-wacky-config.sh                       |   28 +++--\n t/t1450-fsck.sh                               |  138 ++++++++++++++----------\n t/t2016-checkout-patch.sh                     |   43 +++++---\n t/t2105-update-index-gitfile.sh               |    2 +-\n t/t3060-ls-files-with-tree.sh                 |   12 +-\n t/t3409-rebase-preserve-merges.sh             |   13 ++-\n t/t3903-stash.sh                              |    5 +-\n t/t4041-diff-submodule-option.sh              |    7 +-\n t/t5510-fetch.sh                              |   35 ++++---\n t/t6050-replace.sh                            |   46 +++++----\n t/t7400-submodule-basic.sh                    |   11 +-\n t/t7401-submodule-summary.sh                  |    7 +-\n t/t9100-git-svn-basic.sh                      |   21 ++--\n t/t9101-git-svn-props.sh                      |   33 ++++---\n t/t9102-git-svn-deep-rmdir.sh                 |   13 ++-\n t/t9104-git-svn-follow-parent.sh              |   56 ++++++-----\n t/t9105-git-svn-commit-diff.sh                |    7 +-\n t/t9106-git-svn-commit-diff-clobber.sh        |   30 +++---\n t/t9107-git-svn-migrate.sh                    |   16 ++--\n t/t9114-git-svn-dcommit-merge.sh              |    7 +-\n t/t9115-git-svn-dcommit-funky-renames.sh      |    7 +-\n t/t9116-git-svn-log.sh                        |   16 ++--\n t/t9119-git-svn-info.sh                       |   69 ++++++++-----\n t/t9120-git-svn-clone-with-percent-escapes.sh |    3 +-\n 27 files changed, 433 insertions(+), 332 deletions(-)\n\n-- \n1.7.2.3\n"},{"id":"150168","messageId":"20100907014254.GB1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 1/7] tests: subshell indentation stylefix","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:42:54Z","receivedAt":"2010-09-07T01:42:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Format the subshells introduced by the previous patch (Several tests:\ncd inside subshell instead of around, 2010-09-06) like so:\n\n\t(\n\t\tcd subdir &&\n\t\t...\n\t) &&\n\nThis is generally easier to read and has the nice side-effect that\nthis patch will show what commands are used in the subshell, making\nit easier to check for lost environment variables and similar\nbehavior changes.\n\nCc: Jens Lehmann <Jens.Lehmann@web.de>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t1020-subdirectory.sh                       |   13 +++--\n t/t1302-repo-version.sh                       |   11 +++-\n t/t3060-ls-files-with-tree.sh                 |   12 ++--\n t/t3409-rebase-preserve-merges.sh             |   13 +++--\n t/t3903-stash.sh                              |    5 +-\n t/t4041-diff-submodule-option.sh              |    7 ++-\n t/t5510-fetch.sh                              |   35 +++++++------\n t/t6050-replace.sh                            |   46 +++++++++--------\n t/t7400-submodule-basic.sh                    |   11 ++--\n t/t7401-submodule-summary.sh                  |    7 ++-\n t/t9100-git-svn-basic.sh                      |   21 ++++----\n t/t9101-git-svn-props.sh                      |   33 +++++++-----\n t/t9102-git-svn-deep-rmdir.sh                 |   13 +++--\n t/t9104-git-svn-follow-parent.sh              |   56 +++++++++++---------\n t/t9105-git-svn-commit-diff.sh                |    7 ++-\n t/t9106-git-svn-commit-diff-clobber.sh        |   30 ++++++-----\n t/t9107-git-svn-migrate.sh                    |   16 +++---\n t/t9114-git-svn-dcommit-merge.sh              |    7 ++-\n t/t9115-git-svn-dcommit-funky-renames.sh      |    7 ++-\n t/t9116-git-svn-log.sh                        |   16 +++---\n t/t9119-git-svn-info.sh                       |   69 ++++++++++++++++---------\n t/t9120-git-svn-clone-with-percent-escapes.sh |    3 +-\n 22 files changed, 253 insertions(+), 185 deletions(-)\n\ndiff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh\nindex c36157a..0d0da17 100755\n--- a/t/t1020-subdirectory.sh\n+++ b/t/t1020-subdirectory.sh\n@@ -27,12 +27,13 @@ test_expect_success 'update-index and ls-files' '\n \tone) echo pass one ;;\n \t*) echo bad one; exit 1 ;;\n \tesac &&\n-\t(cd dir &&\n-\tgit update-index --add two &&\n-\tcase \"`git ls-files`\" in\n-\ttwo) echo pass two ;;\n-\t*) echo bad two; exit 1 ;;\n-\tesac\n+\t(\n+\t\tcd dir &&\n+\t\tgit update-index --add two &&\n+\t\tcase \"`git ls-files`\" in\n+\t\ttwo) echo pass two ;;\n+\t\t*) echo bad two; exit 1 ;;\n+\t\tesac\n \t) &&\n \tcase \"`git ls-files`\" in\n \tdir/two\"$LF\"one) echo pass both ;;\ndiff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh\nindex c948719..0da2799 100755\n--- a/t/t1302-repo-version.sh\n+++ b/t/t1302-repo-version.sh\n@@ -33,8 +33,15 @@ test_expect_success 'gitdir selection on unsupported repo' '\n \n test_expect_success 'gitdir not required mode' '\n \tgit apply --stat test.patch &&\n-\t(cd test && git apply --stat ../test.patch) &&\n-\t(cd test2 && git apply --stat ../test.patch)'\n+\t(\n+\t\tcd test &&\n+\t\tgit apply --stat ../test.patch\n+\t) &&\n+\t(\n+\t\tcd test2 &&\n+\t\tgit apply --stat ../test.patch\n+\t)\n+'\n \n test_expect_success 'gitdir required mode on normal repos' '\n \t(git apply --check --index test.patch &&\ndiff --git a/t/t3060-ls-files-with-tree.sh b/t/t3060-ls-files-with-tree.sh\nindex 25afb4f..61c1f53 100755\n--- a/t/t3060-ls-files-with-tree.sh\n+++ b/t/t3060-ls-files-with-tree.sh\n@@ -53,13 +53,13 @@ test_expect_success setup '\n \tgit add .\n '\n \n-# We have to run from a sub-directory to trigger prune_path\n-# Then we finally get to run our --with-tree test\n-\n test_expect_success 'git -ls-files --with-tree should succeed from subdir' '\n-\n-\t(cd sub && git ls-files --with-tree=HEAD~1 >../output)\n-\n+\t# We have to run from a sub-directory to trigger prune_path\n+\t# Then we finally get to run our --with-tree test\n+\t(\n+\t\tcd sub &&\n+\t\tgit ls-files --with-tree=HEAD~1 >../output\n+\t)\n '\n \n test_expect_success \\\ndiff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh\nindex 1a362d2..74161a4 100755\n--- a/t/t3409-rebase-preserve-merges.sh\n+++ b/t/t3409-rebase-preserve-merges.sh\n@@ -52,12 +52,13 @@ test_expect_success 'setup for merge-preserving rebase' \\\n \tgit commit -m \"Add different B\" &&\n \n \tgit clone ./. clone2 &&\n-\t(cd clone2 &&\n-\tgit checkout -b topic origin/topic &&\n-\ttest_must_fail git merge origin/master &&\n-\techo Resolved > B &&\n-\tgit add B &&\n-\tgit commit -m \"Merge origin/master into topic\"\n+\t(\n+\t\tcd clone2 &&\n+\t\tgit checkout -b topic origin/topic &&\n+\t\ttest_must_fail git merge origin/master &&\n+\t\techo Resolved >B &&\n+\t\tgit add B &&\n+\t\tgit commit -m \"Merge origin/master into topic\"\n \t) &&\n \n \tgit checkout topic &&\ndiff --git a/t/t3903-stash.sh b/t/t3903-stash.sh\nindex 3f43012..bd4b288 100755\n--- a/t/t3903-stash.sh\n+++ b/t/t3903-stash.sh\n@@ -69,8 +69,9 @@ test_expect_success 'apply stashed changes (including index)' '\n test_expect_success 'unstashing in a subdirectory' '\n \tgit reset --hard HEAD &&\n \tmkdir subdir &&\n-\t(cd subdir &&\n-\tgit stash apply\n+\t(\n+\t\tcd subdir &&\n+\t\tgit stash apply\n \t)\n '\n \ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 737c3d9..995bdfa 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -85,9 +85,10 @@ EOF\n \"\n \n commit_file sm1 &&\n-head3=$(cd sm1 &&\n-git reset --hard HEAD~2 >/dev/null &&\n-git rev-parse --verify HEAD | cut -c1-7\n+head3=$(\n+\tcd sm1 &&\n+\tgit reset --hard HEAD~2 >/dev/null &&\n+\tgit rev-parse --verify HEAD | cut -c1-7\n )\n \n test_expect_success 'modified submodule(backward)' \"\ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex 34d59d5..7d1c866 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -21,26 +21,29 @@ test_expect_success setup '\n \n test_expect_success \"clone and setup child repos\" '\n \tgit clone . one &&\n-\t(cd one &&\n-\techo >file updated by one &&\n-\tgit commit -a -m \"updated by one\"\n+\t(\n+\t\tcd one &&\n+\t\techo >file updated by one &&\n+\t\tgit commit -a -m \"updated by one\"\n \t) &&\n \tgit clone . two &&\n-\t(cd two &&\n-\tgit config branch.master.remote one &&\n-\tgit config remote.one.url ../one/.git/ &&\n-\tgit config remote.one.fetch refs/heads/master:refs/heads/one\n+\t(\n+\t\tcd two &&\n+\t\tgit config branch.master.remote one &&\n+\t\tgit config remote.one.url ../one/.git/ &&\n+\t\tgit config remote.one.fetch refs/heads/master:refs/heads/one\n \t) &&\n \tgit clone . three &&\n-\t(cd three &&\n-\tgit config branch.master.remote two &&\n-\tgit config branch.master.merge refs/heads/one &&\n-\tmkdir -p .git/remotes &&\n-\t{\n-\t\techo \"URL: ../two/.git/\"\n-\t\techo \"Pull: refs/heads/master:refs/heads/two\"\n-\t\techo \"Pull: refs/heads/one:refs/heads/one\"\n-\t} >.git/remotes/two\n+\t(\n+\t\tcd three &&\n+\t\tgit config branch.master.remote two &&\n+\t\tgit config branch.master.merge refs/heads/one &&\n+\t\tmkdir -p .git/remotes &&\n+\t\t{\n+\t\t\techo \"URL: ../two/.git/\"\n+\t\t\techo \"Pull: refs/heads/master:refs/heads/two\"\n+\t\t\techo \"Pull: refs/heads/one:refs/heads/one\"\n+\t\t} >.git/remotes/two\n \t) &&\n \tgit clone . bundle &&\n \tgit clone . seven\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex 01dfa51..f5c3d7f 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -104,16 +104,17 @@ test_expect_success '\"git fsck\" works' '\n test_expect_success 'repack, clone and fetch work' '\n      git repack -a -d &&\n      git clone --no-hardlinks . clone_dir &&\n-     (cd clone_dir &&\n-     git show HEAD~5 | grep \"A U Thor\" &&\n-     git show $HASH2 | grep \"A U Thor\" &&\n-     git cat-file commit $R &&\n-     git repack -a -d &&\n-     test_must_fail git cat-file commit $R &&\n-     git fetch ../ \"refs/replace/*:refs/replace/*\" &&\n-     git show HEAD~5 | grep \"O Thor\" &&\n-     git show $HASH2 | grep \"O Thor\" &&\n-     git cat-file commit $R\n+     (\n+\t  cd clone_dir &&\n+\t  git show HEAD~5 | grep \"A U Thor\" &&\n+\t  git show $HASH2 | grep \"A U Thor\" &&\n+\t  git cat-file commit $R &&\n+\t  git repack -a -d &&\n+\t  test_must_fail git cat-file commit $R &&\n+\t  git fetch ../ \"refs/replace/*:refs/replace/*\" &&\n+\t  git show HEAD~5 | grep \"O Thor\" &&\n+\t  git show $HASH2 | grep \"O Thor\" &&\n+\t  git cat-file commit $R\n      )\n '\n \n@@ -177,9 +178,10 @@ test_expect_success 'create parallel branch without the bug' '\n \n test_expect_success 'push to cloned repo' '\n      git push cloned $HASH6^:refs/heads/parallel &&\n-     (cd clone_dir &&\n-     git checkout parallel &&\n-     git log --pretty=oneline | grep $PARA2\n+     (\n+\t  cd clone_dir &&\n+\t  git checkout parallel &&\n+\t  git log --pretty=oneline | grep $PARA2\n      )\n '\n \n@@ -191,19 +193,21 @@ test_expect_success 'push branch with replacement' '\n      git show $HASH6~2 | grep \"O Thor\" &&\n      git show $PARA3 | grep \"O Thor\" &&\n      git push cloned $HASH6^:refs/heads/parallel2 &&\n-     (cd clone_dir &&\n-     git checkout parallel2 &&\n-     git log --pretty=oneline | grep $PARA3 &&\n-     git show $PARA3 | grep \"A U Thor\"\n+     (\n+\t  cd clone_dir &&\n+\t  git checkout parallel2 &&\n+\t  git log --pretty=oneline | grep $PARA3 &&\n+\t  git show $PARA3 | grep \"A U Thor\"\n      )\n '\n \n test_expect_success 'fetch branch with replacement' '\n      git branch tofetch $HASH6 &&\n-     (cd clone_dir &&\n-     git fetch origin refs/heads/tofetch:refs/heads/parallel3\n-     git log --pretty=oneline parallel3 | grep $PARA3\n-     git show $PARA3 | grep \"A U Thor\"\n+     (\n+\t  cd clone_dir &&\n+\t  git fetch origin refs/heads/tofetch:refs/heads/parallel3\n+\t  git log --pretty=oneline parallel3 | grep $PARA3\n+\t  git show $PARA3 | grep \"A U Thor\"\n      )\n '\n \ndiff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh\nindex 21b0839..782b0a3 100755\n--- a/t/t7400-submodule-basic.sh\n+++ b/t/t7400-submodule-basic.sh\n@@ -413,11 +413,12 @@ test_expect_success 'submodule <invalid-path> warns' '\n \n test_expect_success 'add submodules without specifying an explicit path' '\n \tmkdir repo &&\n-\t(cd repo &&\n-\tgit init &&\n-\techo r >r &&\n-\tgit add r &&\n-\tgit commit -m \"repo commit 1\"\n+\t(\n+\t\tcd repo &&\n+\t\tgit init &&\n+\t\techo r >r &&\n+\t\tgit add r &&\n+\t\tgit commit -m \"repo commit 1\"\n \t) &&\n \tgit clone --bare repo/ bare.git &&\n \tcd addtest &&\ndiff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh\nindex b5ad45f..2945844 100755\n--- a/t/t7401-submodule-summary.sh\n+++ b/t/t7401-submodule-summary.sh\n@@ -66,9 +66,10 @@ EOF\n \"\n \n commit_file sm1 &&\n-head3=$(cd sm1 &&\n-git reset --hard HEAD~2 >/dev/null &&\n-git rev-parse --verify HEAD | cut -c1-7\n+head3=$(\n+\tcd sm1 &&\n+\tgit reset --hard HEAD~2 >/dev/null &&\n+\tgit rev-parse --verify HEAD | cut -c1-7\n )\n \n test_expect_success 'modified submodule(backward)' \"\ndiff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh\nindex 75388f3..a1e1d27 100755\n--- a/t/t9100-git-svn-basic.sh\n+++ b/t/t9100-git-svn-basic.sh\n@@ -22,16 +22,17 @@ esac\n test_expect_success \\\n     'initialize git svn' '\n \tmkdir import &&\n-\t(cd import &&\n-\techo foo > foo &&\n-\tln -s foo foo.link\n-\tmkdir -p dir/a/b/c/d/e &&\n-\techo \"deep dir\" > dir/a/b/c/d/e/file &&\n-\tmkdir bar &&\n-\techo \"zzz\" > bar/zzz &&\n-\techo \"#!/bin/sh\" > exec.sh &&\n-\tchmod +x exec.sh &&\n-\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null\n+\t(\n+\t\tcd import &&\n+\t\techo foo >foo &&\n+\t\tln -s foo foo.link\n+\t\tmkdir -p dir/a/b/c/d/e &&\n+\t\techo \"deep dir\" >dir/a/b/c/d/e/file &&\n+\t\tmkdir bar &&\n+\t\techo \"zzz\" >bar/zzz &&\n+\t\techo \"#!/bin/sh\" >exec.sh &&\n+\t\tchmod +x exec.sh &&\n+\t\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null\n \t) &&\n \trm -rf import &&\n \tgit svn init \"$svnrepo\"'\ndiff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh\nindex f53a1a9..8869f50 100755\n--- a/t/t9101-git-svn-props.sh\n+++ b/t/t9101-git-svn-props.sh\n@@ -53,8 +53,9 @@ cd ..\n \n rm -rf import\n test_expect_success 'checkout working copy from svn' 'svn co \"$svnrepo\" test_wc'\n-test_expect_success 'setup some commits to svn' \\\n-\t'(cd test_wc &&\n+test_expect_success 'setup some commits to svn' '\n+\t(\n+\t\tcd test_wc &&\n \t\techo Greetings >> kw.c &&\n \t\tpoke kw.c &&\n \t\tsvn_cmd commit -m \"Not yet an Id\" &&\n@@ -64,7 +65,8 @@ test_expect_success 'setup some commits to svn' \\\n \t\tsvn_cmd propset svn:keywords Id kw.c &&\n \t\tpoke kw.c &&\n \t\tsvn_cmd commit -m \"Propset Id\"\n-\t)'\n+\t)\n+'\n \n test_expect_success 'initialize git svn' 'git svn init \"$svnrepo\"'\n test_expect_success 'fetch revisions from svn' 'git svn fetch'\n@@ -81,13 +83,15 @@ expect='/* $Id$ */'\n got=\"`sed -ne 2p kw.c`\"\n test_expect_success 'raw $Id$ found in kw.c' \"test '$expect' = '$got'\"\n \n-test_expect_success \"propset CR on crlf files\" \\\n-\t'(cd test_wc &&\n+test_expect_success \"propset CR on crlf files\" '\n+\t(\n+\t\tcd test_wc &&\n \t\tsvn_cmd propset svn:eol-style CR empty &&\n \t\tsvn_cmd propset svn:eol-style CR crlf &&\n \t\tsvn_cmd propset svn:eol-style CR ne_crlf &&\n \t\tsvn_cmd commit -m \"propset CR on crlf files\"\n-\t )'\n+\t )\n+'\n \n test_expect_success 'fetch and pull latest from svn and checkout a new wc' \\\n \t'git svn fetch &&\n@@ -137,19 +141,20 @@ cat > show-ignore.expect <<\\EOF\n EOF\n \n test_expect_success 'test show-ignore' \"\n-\t(cd test_wc &&\n-\tmkdir -p deeply/nested/directory &&\n-\ttouch deeply/nested/directory/.keep &&\n-\tsvn_cmd add deeply &&\n-\tsvn_cmd up &&\n-\tsvn_cmd propset -R svn:ignore '\n+\t(\n+\t\tcd test_wc &&\n+\t\tmkdir -p deeply/nested/directory &&\n+\t\ttouch deeply/nested/directory/.keep &&\n+\t\tsvn_cmd add deeply &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd propset -R svn:ignore '\n no-such-file*\n ' .\n-\tsvn_cmd commit -m 'propset svn:ignore'\n+\t\tsvn_cmd commit -m 'propset svn:ignore'\n \t) &&\n \tgit svn show-ignore > show-ignore.got &&\n \tcmp show-ignore.expect show-ignore.got\n-\t\"\n+\"\n \n cat >create-ignore.expect <<\\EOF\n /no-such-file*\ndiff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh\nindex d60a8ef..eb70f48 100755\n--- a/t/t9102-git-svn-deep-rmdir.sh\n+++ b/t/t9102-git-svn-deep-rmdir.sh\n@@ -4,12 +4,13 @@ test_description='git svn rmdir'\n \n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\t(cd import &&\n-\tmkdir -p deeply/nested/directory/number/1 &&\n-\tmkdir -p deeply/nested/directory/number/2 &&\n-\techo foo > deeply/nested/directory/number/1/file &&\n-\techo foo > deeply/nested/directory/number/2/another &&\n-\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\"\n+\t(\n+\t\tcd import &&\n+\t\tmkdir -p deeply/nested/directory/number/1 &&\n+\t\tmkdir -p deeply/nested/directory/number/2 &&\n+\t\techo foo >deeply/nested/directory/number/1/file &&\n+\t\techo foo >deeply/nested/directory/number/2/another &&\n+\t\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\"\n \t)\n \t'\n \ndiff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh\nindex d2f0e92..1e5217a 100755\n--- a/t/t9104-git-svn-follow-parent.sh\n+++ b/t/t9104-git-svn-follow-parent.sh\n@@ -8,21 +8,23 @@ test_description='git svn fetching'\n \n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\t(cd import &&\n-\tmkdir -p trunk &&\n-\techo hello > trunk/readme &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t(\n+\t\tcd import &&\n+\t\tmkdir -p trunk &&\n+\t\techo hello >trunk/readme &&\n+\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n \t) &&\n \tsvn_cmd co \"$svnrepo\" wc &&\n-\t(cd wc &&\n-\techo world >> trunk/readme &&\n-\tpoke trunk/readme &&\n-\tsvn_cmd commit -m \"another commit\" &&\n-\tsvn_cmd up &&\n-\tsvn_cmd mv trunk thunk &&\n-\techo goodbye >> thunk/readme &&\n-\tpoke thunk/readme &&\n-\tsvn_cmd commit -m \"bye now\"\n+\t(\n+\t\tcd wc &&\n+\t\techo world >>trunk/readme &&\n+\t\tpoke trunk/readme &&\n+\t\tsvn_cmd commit -m \"another commit\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd mv trunk thunk &&\n+\t\techo goodbye >>thunk/readme &&\n+\t\tpoke thunk/readme &&\n+\t\tsvn_cmd commit -m \"bye now\"\n \t)\n \t'\n \n@@ -85,11 +87,12 @@ test_expect_success 'follow larger parent' '\n test_expect_success 'follow higher-level parent' '\n         svn mkdir -m \"follow higher-level parent\" \"$svnrepo\"/blob &&\n         svn co \"$svnrepo\"/blob blob &&\n-        (cd blob &&\n+        (\n+                cd blob &&\n                 echo hi > hi &&\n                 svn add hi &&\n                 svn commit -m \"hihi\"\n-                ) &&\n+        ) &&\n         svn mkdir -m \"new glob at top level\" \"$svnrepo\"/glob &&\n         svn mv -m \"move blob down a level\" \"$svnrepo\"/blob \"$svnrepo\"/glob/blob &&\n         git svn init --minimize-url -i blob \"$svnrepo\"/glob/blob &&\n@@ -117,17 +120,22 @@ test_expect_success 'follow-parent avoids deleting relevant info' '\n \t   import/trunk/subversion/bindings/swig/perl/t/larger-parent &&\n \t  echo \"bad delete test 2\" > \\\n \t   import/trunk/subversion/bindings/swig/perl/another-larger &&\n-\t(cd import &&\n-\t  svn import -m \"r9270 test\" . \"$svnrepo\"/r9270\n+\t(\n+\t\tcd import &&\n+\t\tsvn import -m \"r9270 test\" . \"$svnrepo\"/r9270\n \t) &&\n \tsvn_cmd co \"$svnrepo\"/r9270/trunk/subversion/bindings/swig/perl r9270 &&\n-\t(cd r9270 &&\n-\t  svn mkdir native &&\n-\t  svn mv t native/t &&\n-\t  for i in a b c; do svn mv $i.pm native/$i.pm; done &&\n-\t  echo z >> native/t/c.t &&\n-\t  poke native/t/c.t &&\n-\t  svn commit -m \"reorg test\"\n+\t(\n+\t\tcd r9270 &&\n+\t\tsvn mkdir native &&\n+\t\tsvn mv t native/t &&\n+\t\tfor i in a b c\n+\t\tdo\n+\t\t\tsvn mv $i.pm native/$i.pm\n+\t\tdone &&\n+\t\techo z >>native/t/c.t &&\n+\t\tpoke native/t/c.t &&\n+\t\tsvn commit -m \"reorg test\"\n \t) &&\n \tgit svn init --minimize-url -i r9270-t \\\n \t  \"$svnrepo\"/r9270/trunk/subversion/bindings/swig/perl/native/t &&\ndiff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh\nindex d432d83..5d0afea 100755\n--- a/t/t9105-git-svn-commit-diff.sh\n+++ b/t/t9105-git-svn-commit-diff.sh\n@@ -6,9 +6,10 @@ test_description='git svn commit-diff'\n \n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\t(cd import &&\n-\techo hello > readme &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t(\n+\t\tcd import &&\n+\t\techo hello >readme &&\n+\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n \t) &&\n \techo hello > readme &&\n \tgit update-index --add readme &&\ndiff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh\nindex af367a1..f6d7ac7 100755\n--- a/t/t9106-git-svn-commit-diff-clobber.sh\n+++ b/t/t9106-git-svn-commit-diff-clobber.sh\n@@ -6,9 +6,10 @@ test_description='git svn commit-diff clobber'\n \n test_expect_success 'initialize repo' '\n \tmkdir import &&\n-\t(cd import &&\n-\techo initial > file &&\n-\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n+\t(\n+\t\tcd import &&\n+\t\techo initial >file &&\n+\t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n \t) &&\n \techo initial > file &&\n \tgit update-index --add file &&\n@@ -16,10 +17,11 @@ test_expect_success 'initialize repo' '\n \t'\n test_expect_success 'commit change from svn side' '\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\t(cd t.svn &&\n-\techo second line from svn >> file &&\n-\tpoke file &&\n-\tsvn_cmd commit -m \"second line from svn\"\n+\t(\n+\t\tcd t.svn &&\n+\t\techo second line from svn >>file &&\n+\t\tpoke file &&\n+\t\tsvn_cmd commit -m \"second line from svn\"\n \t) &&\n \trm -rf t.svn\n \t'\n@@ -44,10 +46,11 @@ test_expect_success 'dcommit fails to commit because of conflict' '\n \tgit svn fetch &&\n \tgit reset --hard refs/${remotes_git_svn} &&\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\t(cd t.svn &&\n-\techo fourth line from svn >> file &&\n-\tpoke file &&\n-\tsvn_cmd commit -m \"fourth line from svn\"\n+\t(\n+\t\tcd t.svn &&\n+\t\techo fourth line from svn >>file &&\n+\t\tpoke file &&\n+\t\tsvn_cmd commit -m \"fourth line from svn\"\n \t) &&\n \trm -rf t.svn &&\n \techo \"fourth line from git\" >> file &&\n@@ -68,8 +71,9 @@ test_expect_success 'dcommit does the svn equivalent of an index merge' \"\n \n test_expect_success 'commit another change from svn side' '\n \tsvn_cmd co \"$svnrepo\" t.svn &&\n-\t(cd t.svn &&\n-\t\techo third line from svn >> file &&\n+\t(\n+\t\tcd t.svn &&\n+\t\techo third line from svn >>file &&\n \t\tpoke file &&\n \t\tsvn_cmd commit -m \"third line from svn\"\n \t) &&\ndiff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh\nindex f60b306..289fc31 100755\n--- a/t/t9107-git-svn-migrate.sh\n+++ b/t/t9107-git-svn-migrate.sh\n@@ -6,14 +6,16 @@ test_description='git svn metadata migrations from previous versions'\n test_expect_success 'setup old-looking metadata' '\n \tcp \"$GIT_DIR\"/config \"$GIT_DIR\"/config-old-git-svn &&\n \tmkdir import &&\n-\t(cd import &&\n-\t\tfor i in trunk branches/a branches/b \\\n-\t\t         tags/0.1 tags/0.2 tags/0.3; do\n-\t\t\tmkdir -p $i && \\\n-\t\t\techo hello >> $i/README || exit 1\n-\t\tdone && \\\n+\t(\n+\t\tcd import &&\n+\t\tfor i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3\n+\t\tdo\n+\t\t\tmkdir -p $i &&\n+\t\t\techo hello >>$i/README ||\n+\t\t\texit 1\n+\t\tdone &&\n \t\tsvn_cmd import -m test . \"$svnrepo\"\n-\t\t) &&\n+\t) &&\n \tgit svn init \"$svnrepo\" &&\n \tgit svn fetch &&\n \trm -rf \"$GIT_DIR\"/svn &&\ndiff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh\nindex a7d0c7d..3077851 100755\n--- a/t/t9114-git-svn-dcommit-merge.sh\n+++ b/t/t9114-git-svn-dcommit-merge.sh\n@@ -37,11 +37,12 @@ EOF\n test_expect_success 'setup svn repository' '\n \tsvn_cmd co \"$svnrepo\" mysvnwork &&\n \tmkdir -p mysvnwork/trunk &&\n-\t(cd mysvnwork &&\n-\t\tbig_text_block >> trunk/README &&\n+\t(\n+\t\tcd mysvnwork &&\n+\t\tbig_text_block >>trunk/README &&\n \t\tsvn_cmd add trunk &&\n \t\tsvn_cmd ci -m \"first commit\" trunk\n-\t\t)\n+\t)\n \t'\n \n test_expect_success 'setup git mirror and merge' '\ndiff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh\nindex 9fdbc9b..6a48e40 100755\n--- a/t/t9115-git-svn-dcommit-funky-renames.sh\n+++ b/t/t9115-git-svn-dcommit-funky-renames.sh\n@@ -61,11 +61,12 @@ test_expect_success 'add a file with plus signs' '\n \n test_expect_success 'clone the repository to test rebase' '\n \tgit svn clone \"$svnrepo\" test-rebase &&\n-\t(cd test-rebase &&\n-\t\techo test-rebase > test-rebase &&\n+\t(\n+\t\tcd test-rebase &&\n+\t\techo test-rebase >test-rebase &&\n \t\tgit add test-rebase &&\n \t\tgit commit -m test-rebase\n-\t\t)\n+\t)\n \t'\n \n test_expect_success 'make a commit to test rebase' '\ndiff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh\nindex 244b5cd..5d477e4 100755\n--- a/t/t9116-git-svn-log.sh\n+++ b/t/t9116-git-svn-log.sh\n@@ -8,14 +8,16 @@ test_description='git svn log tests'\n \n test_expect_success 'setup repository and import' '\n \tmkdir import &&\n-\t(cd import &&\n-\t\tfor i in trunk branches/a branches/b \\\n-\t\t         tags/0.1 tags/0.2 tags/0.3; do\n-\t\t\tmkdir -p $i && \\\n-\t\t\techo hello >> $i/README || exit 1\n-\t\tdone && \\\n+\t(\n+\t\tcd import &&\n+\t\tfor i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3\n+\t\tdo\n+\t\t\tmkdir -p $i &&\n+\t\t\techo hello >>$i/README ||\n+\t\t\texit 1\n+\t\tdone &&\n \t\tsvn_cmd import -m test . \"$svnrepo\"\n-\t\t) &&\n+\t) &&\n \tgit svn init \"$svnrepo\" -T trunk -b branches -t tags &&\n \tgit svn fetch &&\n \tgit reset --hard trunk &&\ndiff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh\nindex e3f08c4..f3f397c 100755\n--- a/t/t9119-git-svn-info.sh\n+++ b/t/t9119-git-svn-info.sh\n@@ -39,9 +39,10 @@ quoted_svnrepo=\"$(echo $svnrepo | sed 's/ /%20/')\"\n \n test_expect_success 'setup repository and import' '\n \tmkdir info &&\n-\t(cd info &&\n-\t\techo FIRST > A &&\n-\t\techo one > file &&\n+\t(\n+\t\tcd info &&\n+\t\techo FIRST >A &&\n+\t\techo one >file &&\n \t\tln -s file symlink-file &&\n \t\tmkdir directory &&\n \t\ttouch directory/.placeholder &&\n@@ -49,14 +50,16 @@ test_expect_success 'setup repository and import' '\n \t\tsvn_cmd import -m \"initial\" . \"$svnrepo\"\n \t) &&\n \tsvn_cmd co \"$svnrepo\" svnwc &&\n-\t(cd svnwc &&\n-\t\techo foo > foo &&\n+\t(\n+\t\tcd svnwc &&\n+\t\techo foo >foo &&\n \t\tsvn_cmd add foo &&\n \t\tsvn_cmd commit -m \"change outside directory\" &&\n \t\tsvn_cmd update\n \t) &&\n \tmkdir gitwc &&\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit svn init \"$svnrepo\" &&\n \t\tgit svn fetch\n \t) &&\n@@ -138,12 +141,14 @@ test_expect_success 'info --url symlink-directory' '\n \n test_expect_success 'info added-file' \"\n \techo two > gitwc/added-file &&\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit add added-file\n \t) &&\n \tcp gitwc/added-file svnwc/added-file &&\n \tptouch gitwc/added-file svnwc/added-file &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd add added-file > /dev/null\n \t) &&\n \t(cd svnwc; svn info added-file) > expected.info-added-file &&\n@@ -160,10 +165,12 @@ test_expect_success 'info added-directory' \"\n \tmkdir gitwc/added-directory svnwc/added-directory &&\n \tptouch gitwc/added-directory svnwc/added-directory &&\n \ttouch gitwc/added-directory/.placeholder &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd add added-directory > /dev/null\n \t) &&\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit add added-directory\n \t) &&\n \t(cd svnwc; svn info added-directory) \\\n@@ -179,11 +186,13 @@ test_expect_success 'info --url added-directory' '\n \t'\n \n test_expect_success 'info added-symlink-file' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tln -s added-file added-symlink-file &&\n \t\tgit add added-symlink-file\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tln -s added-file added-symlink-file &&\n \t\tsvn_cmd add added-symlink-file > /dev/null\n \t) &&\n@@ -202,11 +211,13 @@ test_expect_success 'info --url added-symlink-file' '\n \t'\n \n test_expect_success 'info added-symlink-directory' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tln -s added-directory added-symlink-directory &&\n \t\tgit add added-symlink-directory\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tln -s added-directory added-symlink-directory &&\n \t\tsvn_cmd add added-symlink-directory > /dev/null\n \t) &&\n@@ -230,10 +241,12 @@ test_expect_success 'info --url added-symlink-directory' '\n # simply reuses the Last Changed Date.\n \n test_expect_success 'info deleted-file' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit rm -f file > /dev/null\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd rm --force file > /dev/null\n \t) &&\n \t(cd svnwc; svn info file) |\n@@ -251,10 +264,12 @@ test_expect_success 'info --url file (deleted)' '\n \t'\n \n test_expect_success 'info deleted-directory' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit rm -r -f directory > /dev/null\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd rm --force directory > /dev/null\n \t) &&\n \t(cd svnwc; svn info directory) |\n@@ -272,10 +287,12 @@ test_expect_success 'info --url directory (deleted)' '\n \t'\n \n test_expect_success 'info deleted-symlink-file' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit rm -f symlink-file > /dev/null\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd rm --force symlink-file > /dev/null\n \t) &&\n \t(cd svnwc; svn info symlink-file) |\n@@ -294,10 +311,12 @@ test_expect_success 'info --url symlink-file (deleted)' '\n \t'\n \n test_expect_success 'info deleted-symlink-directory' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tgit rm -f symlink-directory > /dev/null\n \t) &&\n-\t(cd svnwc &&\n+\t(\n+\t\tcd svnwc &&\n \t\tsvn_cmd rm --force symlink-directory > /dev/null\n \t) &&\n \t(cd svnwc; svn info symlink-directory) |\n@@ -346,7 +365,8 @@ test_expect_success 'info --url unknown-directory' '\n \t'\n \n test_expect_success 'info unknown-symlink-file' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tln -s unknown-file unknown-symlink-file\n \t) &&\n \t(cd gitwc; test_must_fail git svn info unknown-symlink-file) \\\n@@ -361,7 +381,8 @@ test_expect_success 'info --url unknown-symlink-file' '\n \t'\n \n test_expect_success 'info unknown-symlink-directory' \"\n-\t(cd gitwc &&\n+\t(\n+\t\tcd gitwc &&\n \t\tln -s unknown-directory unknown-symlink-directory\n \t) &&\n \t(cd gitwc; test_must_fail git svn info unknown-symlink-directory) \\\ndiff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh\nindex cddb9d4..1d92c05 100755\n--- a/t/t9120-git-svn-clone-with-percent-escapes.sh\n+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh\n@@ -20,7 +20,8 @@ test_expect_success 'setup svnrepo' '\n \n test_expect_success 'test clone with percent escapes' '\n \tgit svn clone \"$svnrepo/pr%20ject\" clone &&\n-\t(cd clone &&\n+\t(\n+\t\tcd clone &&\n \t\tgit rev-parse refs/${remotes_git_svn}\n \t)\n '\n-- \n1.7.2.3\n"},{"id":"150169","messageId":"20100907014707.GC1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 2/7] t1450 (fsck): remove dangling objects","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:47:07Z","receivedAt":"2010-09-07T01:47:07Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The fsck test is generally careful to remove the corrupt objects\nit inserts, but dangling objects are left behind due to some typos\nand omissions.  It is better to clean up more completely, to\nsimplify the addition of later tests.  So:\n\n - guard setup and cleanup with test_expect_success to catch\n   typos and errors;\n - check both stdout and stderr when checking for empty fsck\n   output;\n - use test_cmp empty file in place of test $(wc -l <file) = 0,\n   for better debugging output when running tests with -v;\n - add a remove_object () helper and use it to replace broken\n   object removal code that forgot about the fanout in\n   .git/objects;\n - disable gc.auto, to avoid tripping up object removal if the\n   number of objects ever reaches that threshold.\n - use test_when_finished to ensure cleanup tasks are run and\n   succeed when tests fail;\n - add a new final test that no breakage or dangling objects\n   was left behind.\n\nWhile at it, add a brief description to test_description of the\nhistory that is expected to persist between tests.\n\nPart of a campaign to clean up subshell usage in tests.\n\nCc: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t1450-fsck.sh |  140 ++++++++++++++++++++++++++++++++-----------------------\n 1 files changed, 82 insertions(+), 58 deletions(-)\n\ndiff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh\nindex 759cf12..1be415e 100755\n--- a/t/t1450-fsck.sh\n+++ b/t/t1450-fsck.sh\n@@ -1,21 +1,23 @@\n #!/bin/sh\n \n-test_description='git fsck random collection of tests'\n+test_description='git fsck random collection of tests\n+\n+* (HEAD) B\n+* (master) A\n+'\n \n . ./test-lib.sh\n \n test_expect_success setup '\n+\tgit config gc.auto 0 &&\n \tgit config i18n.commitencoding ISO-8859-1 &&\n \ttest_commit A fileA one &&\n \tgit config --unset i18n.commitencoding &&\n \tgit checkout HEAD^0 &&\n \ttest_commit B fileB two &&\n \tgit tag -d A B &&\n-\tgit reflog expire --expire=now --all\n-'\n-\n-test_expect_success 'HEAD is part of refs' '\n-\ttest 0 = $(git fsck | wc -l)\n+\tgit reflog expire --expire=now --all &&\n+\t>empty\n '\n \n test_expect_success 'loose objects borrowed from alternate are not missing' '\n@@ -25,110 +27,132 @@ test_expect_success 'loose objects borrowed from alternate are not missing' '\n \t\tgit init &&\n \t\techo ../../../.git/objects >.git/objects/info/alternates &&\n \t\ttest_commit C fileC one &&\n-\t\tgit fsck >out &&\n-\t\t! grep \"missing blob\" out\n-\t)\n+\t\tgit fsck >../out 2>&1\n+\t) &&\n+\t{\n+\t\tgrep -v dangling out >actual ||\n+\t\t:\n+\t} &&\n+\ttest_cmp empty actual\n '\n \n-test_expect_success 'valid objects appear valid' '\n-\t{ git fsck 2>out; true; } &&\n-\t! grep error out &&\n-\t! grep fatal out\n+test_expect_success 'HEAD is part of refs, valid objects appear valid' '\n+\tgit fsck >actual 2>&1 &&\n+\ttest_cmp empty actual\n '\n \n # Corruption tests follow.  Make sure to remove all traces of the\n # specific corruption you test afterwards, lest a later test trip over\n # it.\n \n+test_expect_success 'setup: helpers for corruption tests' '\n+\tsha1_file() {\n+\t\techo \"$*\" | sed \"s#..#.git/objects/&/#\"\n+\t} &&\n+\n+\tremove_object() {\n+\t\tfile=$(sha1_file \"$*\") &&\n+\t\ttest -e \"$file\" &&\n+\t\trm -f \"$file\"\n+\t}\n+'\n+\n test_expect_success 'object with bad sha1' '\n \tsha=$(echo blob | git hash-object -w --stdin) &&\n-\techo $sha &&\n \told=$(echo $sha | sed \"s+^..+&/+\") &&\n \tnew=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&\n \tsha=\"$(dirname $new)$(basename $new)\"\n \tmv .git/objects/$old .git/objects/$new &&\n+\ttest_when_finished \"remove_object $sha\" &&\n \tgit update-index --add --cacheinfo 100644 $sha foo &&\n+\ttest_when_finished \"git read-tree -u --reset HEAD\" &&\n \ttree=$(git write-tree) &&\n+\ttest_when_finished \"remove_object $tree\" &&\n \tcmt=$(echo bogus | git commit-tree $tree) &&\n+\ttest_when_finished \"remove_object $cmt\" &&\n \tgit update-ref refs/heads/bogus $cmt &&\n-\t(git fsck 2>out; true) &&\n-\tgrep \"$sha.*corrupt\" out &&\n-\trm -f .git/objects/$new &&\n-\tgit update-ref -d refs/heads/bogus &&\n-\tgit read-tree -u --reset HEAD\n+\ttest_when_finished \"git update-ref -d refs/heads/bogus\" &&\n+\n+\ttest_might_fail git fsck 2>out &&\n+\tcat out &&\n+\tgrep \"$sha.*corrupt\" out\n '\n \n test_expect_success 'branch pointing to non-commit' '\n-\tgit rev-parse HEAD^{tree} > .git/refs/heads/invalid &&\n+\tgit rev-parse HEAD^{tree} >.git/refs/heads/invalid &&\n+\ttest_when_finished \"git update-ref -d refs/heads/invalid\" &&\n \tgit fsck 2>out &&\n-\tgrep \"not a commit\" out &&\n-\tgit update-ref -d refs/heads/invalid\n+\tcat out &&\n+\tgrep \"not a commit\" out\n '\n \n-new=nothing\n test_expect_success 'email without @ is okay' '\n \tgit cat-file commit HEAD >basis &&\n \tsed \"s/@/AT/\" basis >okay &&\n \tnew=$(git hash-object -t commit -w --stdin <okay) &&\n-\techo \"$new\" &&\n+\ttest_when_finished \"remove_object $new\" &&\n \tgit update-ref refs/heads/bogus \"$new\" &&\n+\ttest_when_finished \"git update-ref -d refs/heads/bogus\" &&\n \tgit fsck 2>out &&\n \tcat out &&\n-\t! grep \"error in commit $new\" out\n+\t! grep \"commit $new\" out\n '\n-git update-ref -d refs/heads/bogus\n-rm -f \".git/objects/$new\"\n \n-new=nothing\n test_expect_success 'email with embedded > is not okay' '\n \tgit cat-file commit HEAD >basis &&\n \tsed \"s/@[a-z]/&>/\" basis >bad-email &&\n \tnew=$(git hash-object -t commit -w --stdin <bad-email) &&\n-\techo \"$new\" &&\n+\ttest_when_finished \"remove_object $new\" &&\n \tgit update-ref refs/heads/bogus \"$new\" &&\n+\ttest_when_finished \"git update-ref -d refs/heads/bogus\" &&\n \tgit fsck 2>out &&\n \tcat out &&\n \tgrep \"error in commit $new\" out\n '\n-git update-ref -d refs/heads/bogus\n-rm -f \".git/objects/$new\"\n-\n-cat > invalid-tag <<EOF\n-object ffffffffffffffffffffffffffffffffffffffff\n-type commit\n-tag invalid\n-tagger T A Gger <tagger@example.com> 1234567890 -0000\n-\n-This is an invalid tag.\n-EOF\n \n test_expect_success 'tag pointing to nonexistent' '\n-\ttag=$(git hash-object -t tag -w --stdin < invalid-tag) &&\n-\techo $tag > .git/refs/tags/invalid &&\n+\tcat >invalid-tag <<-\\EOF\n+\tobject ffffffffffffffffffffffffffffffffffffffff\n+\ttype commit\n+\ttag invalid\n+\ttagger T A Gger <tagger@example.com> 1234567890 -0000\n+\n+\tThis is an invalid tag.\n+\tEOF\n+\n+\ttag=$(git hash-object -t tag -w --stdin <invalid-tag) &&\n+\ttest_when_finished \"remove_object $tag\" &&\n+\techo $tag >.git/refs/tags/invalid &&\n+\ttest_when_finished \"git update-ref -d refs/tags/invalid\" &&\n \ttest_must_fail git fsck --tags >out &&\n \tcat out &&\n-\tgrep \"broken link\" out &&\n-\trm .git/refs/tags/invalid\n+\tgrep \"broken link\" out\n '\n \n-cat > wrong-tag <<EOF\n-object $(echo blob | git hash-object -w --stdin)\n-type commit\n-tag wrong\n-tagger T A Gger <tagger@example.com> 1234567890 -0000\n-\n-This is an invalid tag.\n-EOF\n-\n test_expect_success 'tag pointing to something else than its type' '\n-\ttag=$(git hash-object -t tag -w --stdin < wrong-tag) &&\n-\techo $tag > .git/refs/tags/wrong &&\n+\tsha=$(echo blob | git hash-object -w --stdin) &&\n+\ttest_when_finished \"remove_object $sha\" &&\n+\tcat >wrong-tag <<-EOF &&\n+\tobject $sha\n+\ttype commit\n+\ttag wrong\n+\ttagger T A Gger <tagger@example.com> 1234567890 -0000\n+\n+\tThis is an invalid tag.\n+\tEOF\n+\n+\ttag=$(git hash-object -t tag -w --stdin <wrong-tag) &&\n+\ttest_when_finished \"remove_object $tag\" &&\n+\techo $tag >.git/refs/tags/wrong &&\n+\ttest_when_finished \"git update-ref -d refs/tags/wrong\" &&\n \ttest_must_fail git fsck --tags 2>out &&\n \tcat out &&\n-\tgrep \"error in tag.*broken links\" out &&\n-\trm .git/refs/tags/wrong\n+\tgrep \"error in tag.*broken links\" out\n '\n \n-\n+test_expect_success 'cleaned up' '\n+\tgit fsck >actual 2>&1 &&\n+\ttest_cmp empty actual\n+'\n \n test_done\n-- \n1.7.2.3\n"},{"id":"150170","messageId":"20100907014910.GD1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 3/7] t2105 (gitfile): add missing &&","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:49:10Z","receivedAt":"2010-09-07T01:49:10Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Make sure early failures are not masked by later successes.\n\nCc: Brad King <brad.king@kitware.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t2105-update-index-gitfile.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t2105-update-index-gitfile.sh b/t/t2105-update-index-gitfile.sh\nindex 641607d..a7f3d47 100755\n--- a/t/t2105-update-index-gitfile.sh\n+++ b/t/t2105-update-index-gitfile.sh\n@@ -13,7 +13,7 @@ test_expect_success 'submodule with absolute .git file' '\n \t(cd sub1 &&\n \t git init &&\n \t REAL=\"$(pwd)/.real\" &&\n-\t mv .git \"$REAL\"\n+\t mv .git \"$REAL\" &&\n \t echo \"gitdir: $REAL\" >.git &&\n \t test_commit first)\n '\n-- \n1.7.2.3\n"},{"id":"150172","messageId":"20100907015017.GE1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 4/7] t0004 (unwritable files): simplify error handling","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:50:17Z","receivedAt":"2010-09-07T01:50:17Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Instead of\n\n\t... normal test script ...\n\tstatus=$?\n\t... cleanup ...\n\t(exit $status)\n\nset up cleanup commands with test_when_finished.  This makes the\ntest script a little shorter, and more importantly, it ensures errors\nduring cleanup are reported.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t0004-unwritable.sh |   52 +++++++++++++-----------------------------------\n 1 files changed, 14 insertions(+), 38 deletions(-)\n\ndiff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh\nindex 2342ac5..3e6a334 100755\n--- a/t/t0004-unwritable.sh\n+++ b/t/t0004-unwritable.sh\n@@ -16,53 +16,29 @@ test_expect_success setup '\n '\n \n test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '\n-\n-\t(\n-\t\tchmod a-w .git/objects .git/objects/?? &&\n-\t\ttest_must_fail git write-tree\n-\t)\n-\tstatus=$?\n-\tchmod 775 .git/objects .git/objects/??\n-\t(exit $status)\n-\n+\ttest_when_finished \"chmod 775 .git/objects .git/objects/??\" &&\n+\tchmod a-w .git/objects .git/objects/?? &&\n+\ttest_must_fail git write-tree\n '\n \n test_expect_success POSIXPERM 'commit should notice unwritable repository' '\n-\n-\t(\n-\t\tchmod a-w .git/objects .git/objects/?? &&\n-\t\ttest_must_fail git commit -m second\n-\t)\n-\tstatus=$?\n-\tchmod 775 .git/objects .git/objects/??\n-\t(exit $status)\n-\n+\ttest_when_finished \"chmod 775 .git/objects .git/objects/??\" &&\n+\tchmod a-w .git/objects .git/objects/?? &&\n+\ttest_must_fail git commit -m second\n '\n \n test_expect_success POSIXPERM 'update-index should notice unwritable repository' '\n-\n-\t(\n-\t\techo 6O >file &&\n-\t\tchmod a-w .git/objects .git/objects/?? &&\n-\t\ttest_must_fail git update-index file\n-\t)\n-\tstatus=$?\n-\tchmod 775 .git/objects .git/objects/??\n-\t(exit $status)\n-\n+\ttest_when_finished \"chmod 775 .git/objects .git/objects/??\" &&\n+\techo 6O >file &&\n+\tchmod a-w .git/objects .git/objects/?? &&\n+\ttest_must_fail git update-index file\n '\n \n test_expect_success POSIXPERM 'add should notice unwritable repository' '\n-\n-\t(\n-\t\techo b >file &&\n-\t\tchmod a-w .git/objects .git/objects/?? &&\n-\t\ttest_must_fail git add file\n-\t)\n-\tstatus=$?\n-\tchmod 775 .git/objects .git/objects/??\n-\t(exit $status)\n-\n+\ttest_when_finished \"chmod 775 .git/objects .git/objects/??\" &&\n+\techo b >file &&\n+\tchmod a-w .git/objects .git/objects/?? &&\n+\ttest_must_fail git add file\n '\n \n test_done\n-- \n1.7.2.3\n"},{"id":"150173","messageId":"20100907015227.GF1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 5/7] t1302 (core.repositoryversion): style tweaks","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:52:27Z","receivedAt":"2010-09-07T01:52:27Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"This test is from 2007, which is late enough for the style to be\nrecognizably modern but still a while ago.  Freshen it up to\nfollow new best practices:\n\n - guard setup commands with test_expect_setup, so errors at\n   that stage can be caught;\n - use <<\\EOF in preference to <<EOF, to save reviewers the\n   trouble of looking for variable interpolations;\n - use test_cmp instead of test \"$foo\" = \"$bar\", for better\n   output with -v on failure;\n - indent commands in subshells and let them span multiple lines;\n - combine the two \"gitdir required mode\" tests that do not make\n   as much sense alone.\n\nCc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t1302-repo-version.sh |   64 +++++++++++++++++++++++++++++-----------------\n 1 files changed, 40 insertions(+), 24 deletions(-)\n\ndiff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh\nindex 0da2799..a6bf1bf 100755\n--- a/t/t1302-repo-version.sh\n+++ b/t/t1302-repo-version.sh\n@@ -7,29 +7,41 @@ test_description='Test repository version check'\n \n . ./test-lib.sh\n \n-cat >test.patch <<EOF\n-diff --git a/test.txt b/test.txt\n-new file mode 100644\n---- /dev/null\n-+++ b/test.txt\n-@@ -0,0 +1 @@\n-+123\n-EOF\n+test_expect_success 'setup' '\n+\tcat >test.patch <<-\\EOF &&\n+\tdiff --git a/test.txt b/test.txt\n+\tnew file mode 100644\n+\t--- /dev/null\n+\t+++ b/test.txt\n+\t@@ -0,0 +1 @@\n+\t+123\n+\tEOF\n \n-test_create_repo \"test\"\n-test_create_repo \"test2\"\n-\n-GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 || exit 1\n+\ttest_create_repo \"test\" &&\n+\ttest_create_repo \"test2\" &&\n+\tGIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99\n+'\n \n test_expect_success 'gitdir selection on normal repos' '\n-\t(test \"$(git config core.repositoryformatversion)\" = 0 &&\n-\tcd test &&\n-\ttest \"$(git config core.repositoryformatversion)\" = 0)'\n+\techo 0 >expect &&\n+\tgit config core.repositoryformatversion >actual &&\n+\t(\n+\t\tcd test &&\n+\t\tgit config core.repositoryformatversion >../actual2\n+\t) &&\n+\ttest_cmp expect actual &&\n+\ttest_cmp expect actual2\n+'\n \n-# Make sure it would stop at test2, not trash\n test_expect_success 'gitdir selection on unsupported repo' '\n-\t(cd test2 &&\n-\ttest \"$(git config core.repositoryformatversion)\" = 99)'\n+\t# Make sure it would stop at test2, not trash\n+\techo 99 >expect &&\n+\t(\n+\t\tcd test2 &&\n+\t\tgit config core.repositoryformatversion >../actual\n+\t)\n+\ttest_cmp expect actual\n+'\n \n test_expect_success 'gitdir not required mode' '\n \tgit apply --stat test.patch &&\n@@ -43,12 +55,16 @@ test_expect_success 'gitdir not required mode' '\n \t)\n '\n \n-test_expect_success 'gitdir required mode on normal repos' '\n-\t(git apply --check --index test.patch &&\n-\tcd test && git apply --check --index ../test.patch)'\n-\n-test_expect_success 'gitdir required mode on unsupported repo' '\n-\t(cd test2 && test_must_fail git apply --check --index ../test.patch)\n+test_expect_success 'gitdir required mode' '\n+\tgit apply --check --index test.patch &&\n+\t(\n+\t\tcd test &&\n+\t\tgit apply --check --index ../test.patch\n+\t) &&\n+\t(\n+\t\tcd test2 &&\n+\t\ttest_must_fail git apply --check --index ../test.patch\n+\t)\n '\n \n test_done\n-- \n1.7.2.3\n"},{"id":"150174","messageId":"20100907015317.GG1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH 6/7] t1303 (config): style tweaks","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:53:18Z","receivedAt":"2010-09-07T01:53:18Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"This test already has impeccable style, with one exception: there\nis an unnecessary use of a subshell.  Use a {} block instead.\nWhile at it:\n\n - guard setup commands with test_expect_success, so the commands\n   are printed when the test is run with \"-v\" and errors in setup\n   can be caught;\n - use echo instead of printf to print simple text ending with a\n   newline, so the later use of printf stands out more;\n - put a single space before () in function definitions, for\n   consistency with other shell scripts in git;\n - reorder arguments to test_cmp as \"test_cmp expected actual\".\n\nCc: Jeff King <peff@peff.net>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t1303-wacky-config.sh |   28 ++++++++++++++++------------\n 1 files changed, 16 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t1303-wacky-config.sh b/t/t1303-wacky-config.sh\nindex 080117c..ce7ce1c 100755\n--- a/t/t1303-wacky-config.sh\n+++ b/t/t1303-wacky-config.sh\n@@ -3,16 +3,20 @@\n test_description='Test wacky input to git config'\n . ./test-lib.sh\n \n-setup() {\n-\t(printf \"[section]\\n\" &&\n-\tprintf \"  key = foo\") >.git/config\n-}\n-\n-check() {\n-\techo \"$2\" >expected\n-\tgit config --get \"$1\" >actual 2>&1\n-\ttest_cmp actual expected\n-}\n+test_expect_success 'setup: helper functions' '\n+\tsetup () {\n+\t\t{\n+\t\t\techo \"[section]\" &&\n+\t\t\tprintf \"  key = foo\"\n+\t\t} >.git/config\n+\t} &&\n+\n+\tcheck () {\n+\t\techo \"$2\" >expected\n+\t\tgit config --get \"$1\" >actual 2>&1\n+\t\ttest_cmp expected actual\n+\t}\n+'\n \n test_expect_success 'modify same key' '\n \tsetup &&\n@@ -34,14 +38,14 @@ test_expect_success 'add key in different section' '\n \tcheck section2.key bar\n '\n \n-SECTION=\"test.q\\\"s\\\\sq'sp e.key\"\n test_expect_success 'make sure git config escapes section names properly' '\n+\tSECTION=\"test.q\\\"s\\\\sq'\\''sp e.key\" &&\n \tgit config \"$SECTION\" bar &&\n \tcheck \"$SECTION\" bar\n '\n \n-LONG_VALUE=$(printf \"x%01021dx a\" 7)\n test_expect_success 'do not crash on special long config line' '\n+\tLONG_VALUE=$(printf \"x%01021dx a\" 7) &&\n \tsetup &&\n \tgit config section.key \"$LONG_VALUE\" &&\n \tcheck section.key \"fatal: bad config file line 2 in .git/config\"\n-- \n1.7.2.3\n"},{"id":"150175","messageId":"20100907015509.GH1182@burratino","threadId":"25007","inReplyTo":"20100907014135.GA1182@burratino","subject":"[PATCH/RFC 7/7] t2016 (checkout -p): use printf for multiline y/n input","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T01:55:09Z","receivedAt":"2010-09-07T01:55:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Instead of\n\n\t(echo y; echo n; echo n) | git checkout -p HEAD^ -- dir\n\nwrite\n\n\tprintf \"%s\\n\" y n n |\n\tgit checkout -p HEAD^ -- dir\n\nwhich means the same thing but might be easier to read.\n\nWhile at it, add a missing && to the \"git checkout -p HEAD with change\nalready staged\" test.\n\nCc: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t2016-checkout-patch.sh |   43 +++++++++++++++++++++++++++++--------------\n 1 files changed, 29 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh\nindex 2144184..8cb7f46 100755\n--- a/t/t2016-checkout-patch.sh\n+++ b/t/t2016-checkout-patch.sh\n@@ -20,48 +20,55 @@ test_expect_success 'setup' '\n \n test_expect_success 'saying \"n\" does nothing' '\n \tset_and_save_state dir/foo work head &&\n-\t(echo n; echo n) | git checkout -p &&\n+\tprintf \"%s\\n\" n n |\n+\tgit checkout -p &&\n \tverify_saved_state bar &&\n \tverify_saved_state dir/foo\n '\n \n test_expect_success 'git checkout -p' '\n-\t(echo n; echo y) | git checkout -p &&\n+\tprintf \"%s\\n\" n y |\n+\tgit checkout -p &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n \n test_expect_success 'git checkout -p with staged changes' '\n-\tset_state dir/foo work index\n-\t(echo n; echo y) | git checkout -p &&\n+\tset_state dir/foo work index &&\n+\tprintf \"%s\\n\" n y |\n+\tgit checkout -p &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo index index\n '\n \n test_expect_success 'git checkout -p HEAD with NO staged changes: abort' '\n \tset_and_save_state dir/foo work head &&\n-\t(echo n; echo y; echo n) | git checkout -p HEAD &&\n+\tprintf \"%s\\n\" n y n |\n+\tgit checkout -p HEAD &&\n \tverify_saved_state bar &&\n \tverify_saved_state dir/foo\n '\n \n test_expect_success 'git checkout -p HEAD with NO staged changes: apply' '\n-\t(echo n; echo y; echo y) | git checkout -p HEAD &&\n+\tprintf \"%s\\n\" n y y |\n+\tgit checkout -p HEAD &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n \n test_expect_success 'git checkout -p HEAD with change already staged' '\n-\tset_state dir/foo index index\n+\tset_state dir/foo index index &&\n \t# the third n is to get out in case it mistakenly does not apply\n-\t(echo n; echo y; echo n) | git checkout -p HEAD &&\n+\tprintf \"%s\\n\" n y n |\n+\tgit checkout -p HEAD &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n \n test_expect_success 'git checkout -p HEAD^' '\n \t# the third n is to get out in case it mistakenly does not apply\n-\t(echo n; echo y; echo n) | git checkout -p HEAD^ &&\n+\tprintf \"%s\\n\" n y n |\n+\tgit checkout -p HEAD^ &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo parent parent\n '\n@@ -69,7 +76,8 @@ test_expect_success 'git checkout -p HEAD^' '\n test_expect_success 'git checkout -p handles deletion' '\n \tset_state dir/foo work index &&\n \trm dir/foo &&\n-\t(echo n; echo y) | git checkout -p &&\n+\tprintf \"%s\\n\" n y |\n+\tgit checkout -p &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo index index\n '\n@@ -81,21 +89,24 @@ test_expect_success 'git checkout -p handles deletion' '\n \n test_expect_success 'path limiting works: dir' '\n \tset_state dir/foo work head &&\n-\t(echo y; echo n) | git checkout -p dir &&\n+\tprintf \"%s\\n\" y n |\n+\tgit checkout -p dir &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n \n test_expect_success 'path limiting works: -- dir' '\n \tset_state dir/foo work head &&\n-\t(echo y; echo n) | git checkout -p -- dir &&\n+\tprintf \"%s\\n\" y n |\n+\tgit checkout -p -- dir &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n \n test_expect_success 'path limiting works: HEAD^ -- dir' '\n \t# the third n is to get out in case it mistakenly does not apply\n-\t(echo y; echo n; echo n) | git checkout -p HEAD^ -- dir &&\n+\tprintf \"%s\\n\" y n n |\n+\tgit checkout -p HEAD^ -- dir &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo parent parent\n '\n@@ -103,7 +114,11 @@ test_expect_success 'path limiting works: HEAD^ -- dir' '\n test_expect_success 'path limiting works: foo inside dir' '\n \tset_state dir/foo work head &&\n \t# the third n is to get out in case it mistakenly does not apply\n-\t(echo y; echo n; echo n) | (cd dir && git checkout -p foo) &&\n+\tprintf \"%s\\n\" y n n |\n+\t(\n+\t\tcd dir &&\n+\t\tgit checkout -p foo\n+\t) &&\n \tverify_saved_state bar &&\n \tverify_state dir/foo head head\n '\n-- \n1.7.2.3\n"},{"id":"150177","messageId":"20100907023713.GJ1182@burratino","threadId":"25007","inReplyTo":"7vhbi2tqd0.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T02:37:13Z","receivedAt":"2010-09-07T02:37:13Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> If we were to insist that no matter how an individual test fail, the test\n> that follows it must start in a known location (namely, $TRASH), then we\n> might want to use something like the attached patch.\n\nI like it.  Affected test scripts:\n\n  t0003-attributes.sh\t\tt0050-filesystem.sh\n  t1007-hash-object.sh\t\tt1020-subdirectory.sh\n  t1301-shared-repo.sh\t\tt1500-rev-parse.sh\n  t1501-worktree.sh\t\tt1504-ceiling-dirs.sh\n  t2050-git-dir-relative.sh\tt2300-cd-to-toplevel.sh\n  t3407-rebase-abort.sh\t\tt4119-apply-config.sh\n  t5300-pack-object.sh\t\tt5404-tracking-branches.sh\n  t5406-remote-rejects.sh\tt5510-fetch.sh\n  t5515-fetch-merge-logic.sh\tt5520-pull.sh\n  t5530-upload-pack-error.sh\tt5600-clone-fail-cleanup.sh\n  t5700-clone-reference.sh\tt5701-clone-local.sh\n  t5710-info-alternate.sh\tt6029-merge-subtree.sh\n  t7001-mv.sh\t\t\tt7103-reset-bare.sh\n  t7400-submodule-basic.sh\tt7401-submodule-summary.sh\n  t7408-submodule-reference.sh\tt7610-mergetool.sh\n  t9101-git-svn-props.sh\tt9103-git-svn-tracked-directory-removed.sh\n  t9113-git-svn-dcommit-new-file.sh\n  t9115-git-svn-dcommit-funky-renames.sh\n  t9117-git-svn-init-clone.sh\n  t9137-git-svn-dcommit-clobber-series.sh\n  t9400-git-cvsserver-server.sh\n\nand probably some others.\n\nWhat is the \",$(pwd)\" for?\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 29fd720..90ed4d9 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -370,6 +370,11 @@ test_debug () {\n }\n \n test_run_ () {\n+\tif test \",$(pwd)\" != \",$TRASH_DIRECTORY\"\n+\tthen\n+\t\terror \"bug in test script: starting from a different directory\"\n+\tfi\n+\n \ttest_cleanup=:\n \teval >&3 2>&4 \"$1\"\n \teval_ret=$?\n@@ -377,6 +382,11 @@ test_run_ () {\n \tif test \"$verbose\" = \"t\" && test -n \"$HARNESS_ACTIVE\"; then\n \t\techo \"\"\n \tfi\n+\n+\tif test \",$(pwd)\" != \",$TRASH_DIRECTORY\"\n+\tthen\n+\t\terror \"bug in test script: moved to a different directory\"\n+\tfi\n \treturn 0\n }\n \n-- \n"},{"id":"150180","messageId":"20100907034417.GL1182@burratino","threadId":"25007","inReplyTo":"20100907014254.GB1182@burratino","subject":"Re: [PATCH 1/7] tests: subshell indentation stylefix","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T03:44:17Z","receivedAt":"2010-09-07T03:44:17Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n\n> Format the subshells introduced by the previous patch (Several tests:\n> cd inside subshell instead of around, 2010-09-06)\n\nReview of said previous patch follows.  Sorry for the confusing diffs.\n\n> --- a/t/t1020-subdirectory.sh\n> +++ b/t/t1020-subdirectory.sh\n> @@ -27,12 +27,13 @@ test_expect_success 'update-index and ls-files' '\n>  \tone) echo pass one ;;\n>  \t*) echo bad one; exit 1 ;;\n>  \tesac &&\n> -\t(cd dir &&\n> -\tgit update-index --add two &&\n> -\tcase \"`git ls-files`\" in\n> -\ttwo) echo pass two ;;\n> -\t*) echo bad two; exit 1 ;;\n> -\tesac\n> +\t(\n> +\t\tcd dir &&\n> +\t\tgit update-index --add two &&\n> +\t\tcase \"`git ls-files`\" in\n> +\t\ttwo) echo pass two ;;\n> +\t\t*) echo bad two; exit 1 ;;\n> +\t\tesac\n>  \t) &&\n\nTrapping the \"exit\" in a subshell improves behavior.  I wonder why the\nscript does not use \"false\" or \"(exit 1)\"; the tests outside the\nsubshell have the same problem...\n\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -85,9 +85,10 @@ EOF\n>  \"\n>  \n>  commit_file sm1 &&\n> -head3=$(cd sm1 &&\n> -git reset --hard HEAD~2 >/dev/null &&\n> -git rev-parse --verify HEAD | cut -c1-7\n> +head3=$(\n> +\tcd sm1 &&\n> +\tgit reset --hard HEAD~2 >/dev/null &&\n> +\tgit rev-parse --verify HEAD | cut -c1-7\n\nUnrelated: the --verify here does not have much effect on the upstream\nof a pipeline.  Maybe \"git log -1 --abbrev=7 --format=%h\", or even\nbetter, \"git log -1 --format=%h\" (for DEFAULT_ABBREV) would do the\ntrick.\n\n> --- a/t/t9100-git-svn-basic.sh\n> +++ b/t/t9100-git-svn-basic.sh\n> @@ -22,16 +22,17 @@ esac\n>  test_expect_success \\\n>      'initialize git svn' '\n>  \tmkdir import &&\n> -\t(cd import &&\n> -\techo foo > foo &&\n> -\tln -s foo foo.link\n> -\tmkdir -p dir/a/b/c/d/e &&\n> -\techo \"deep dir\" > dir/a/b/c/d/e/file &&\n> -\tmkdir bar &&\n> -\techo \"zzz\" > bar/zzz &&\n> -\techo \"#!/bin/sh\" > exec.sh &&\n> -\tchmod +x exec.sh &&\n> -\tsvn_cmd import -m \"import for git svn\" . \"$svnrepo\" >/dev/null\n> +\t(\n> +\t\tcd import &&\n> +\t\techo foo >foo &&\n> +\t\tln -s foo foo.link\n\nMissing SYMLINKS prerequisite?\n\n> --- a/t/t9107-git-svn-migrate.sh\n> +++ b/t/t9107-git-svn-migrate.sh\n> @@ -6,14 +6,16 @@ test_description='git svn metadata migrations from previous versions'\n>  test_expect_success 'setup old-looking metadata' '\n>  \tcp \"$GIT_DIR\"/config \"$GIT_DIR\"/config-old-git-svn &&\n>  \tmkdir import &&\n> -\t(cd import &&\n> -\t\tfor i in trunk branches/a branches/b \\\n> -\t\t         tags/0.1 tags/0.2 tags/0.3; do\n> -\t\t\tmkdir -p $i && \\\n> -\t\t\techo hello >> $i/README || exit 1\n> -\t\tdone && \\\n> +\t(\n> +\t\tcd import &&\n> +\t\tfor i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3\n> +\t\tdo\n> +\t\t\tmkdir -p $i &&\n> +\t\t\techo hello >>$i/README ||\n> +\t\t\texit 1\n\nAn \"exit\" to avoid wasting time after a failing setup test might seem\nappropriate, but I am happier to see it trapped by the subshell.\n\n> --- a/t/t9116-git-svn-log.sh\n> +++ b/t/t9116-git-svn-log.sh\n> @@ -8,14 +8,16 @@ test_description='git svn log tests'\n>  \n>  test_expect_success 'setup repository and import' '\n>  \tmkdir import &&\n> -\t(cd import &&\n> -\t\tfor i in trunk branches/a branches/b \\\n> -\t\t         tags/0.1 tags/0.2 tags/0.3; do\n> -\t\t\tmkdir -p $i && \\\n> -\t\t\techo hello >> $i/README || exit 1\n> -\t\tdone && \\\n> +\t(\n> +\t\tcd import &&\n> +\t\tfor i in trunk branches/a branches/b tags/0.1 tags/0.2 tags/0.3\n> +\t\tdo\n> +\t\t\tmkdir -p $i &&\n> +\t\t\techo hello >>$i/README ||\n> +\t\t\texit 1\n\nLikewise.\n\n> --- a/t/t9119-git-svn-info.sh\n> +++ b/t/t9119-git-svn-info.sh\n> @@ -179,11 +186,13 @@ test_expect_success 'info --url added-directory' '\n>  \t'\n>  \n>  test_expect_success 'info added-symlink-file' \"\n> -\t(cd gitwc &&\n> +\t(\n> +\t\tcd gitwc &&\n>  \t\tln -s added-file added-symlink-file &&\n>  \t\tgit add added-symlink-file\n>  \t) &&\n> -\t(cd svnwc &&\n> +\t(\n> +\t\tcd svnwc &&\n>  \t\tln -s added-file added-symlink-file &&\n\nMore missing SYMLINKS prerequisites.\n\nTo summarize, wherever you change behavior, it is improved.  Thanks.\n\nReviewed-by: Jonathan Nieder <jrnieder@gmail.com>\n"},{"id":"150181","messageId":"20100907043050.GA13291@sigill.intra.peff.net","threadId":"25007","inReplyTo":"20100907015317.GG1182@burratino","subject":"Re: [PATCH 6/7] t1303 (config): style tweaks","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-09-07T04:30:50Z","receivedAt":"2010-09-07T04:30:50Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Sep 06, 2010 at 08:53:18PM -0500, Jonathan Nieder wrote:\n\n> This test already has impeccable style,\n\nI don't think my style has ever been called impeccable...\n\n> with one exception: there is an unnecessary use of a subshell.  Use a\n> {} block instead.\n\nOK. Does this actually matter for anything? I know Windows has slow\nfork, but I doubt it is measurable here.\n\n> While at it:\n> \n>  - guard setup commands with test_expect_success, so the commands\n>    are printed when the test is run with \"-v\" and errors in setup\n>    can be caught;\n\nThis confuses me. The setup is _already_ run inside test_expect_success.\nIt is only the shell function definitions you are moving inside. Do we\nreally care about this? If so, aren't there a zillion other places where\nwe define shell functions in test scripts? Try \"git grep\n'^[a-z][a-z]* *('\".\n\nYou do move some variable definitions inside, too,, but IMO you are\nmaking at least one of them less readable, because you have to deal with\nthe extra quoting layer of test_expect_success. IOW:\n\n> -SECTION=\"test.q\\\"s\\\\sq'sp e.key\"\n>  test_expect_success 'make sure git config escapes section names properly' '\n> +       SECTION=\"test.q\\\"s\\\\sq'\\''sp e.key\" &&\n\nseems like a net loss to me.\n\n>  - use echo instead of printf to print simple text ending with a\n>    newline, so the later use of printf stands out more;\n\nNo complaint here.\n\n>  - put a single space before () in function definitions, for\n>    consistency with other shell scripts in git;\n\nAgain, I am not sure we care, but if we do, there are a ton of other\nplaces: git grep '^[a-z][a-z]*('.\n\n>  - reorder arguments to test_cmp as \"test_cmp expected actual\".\n\nYeah, I prefer it as \"test_cmp expected actual\". I'm surprised I ever\nwrote it the other way (actually, I think it is because my writing\npredates test_cmp, even).\n\nSo I dunno. Most of it I am fine with, though I question whether it is\nreally worth the effort. But I really don't want to be too draconian\nabout \"everything must go into test_expect_success\". Sure, if you are\nexecuting commands that might have output, or might be of interest to\nthe user, put them there. But I find this a lot more readable:\n\ncat >expect <<'EOF'\n... some expected output ...\nEOF\ntest_expect_success 'frob it' '\n        git frob &&\n        test_cmp expect actual\n'\n\nthan:\n\ntest_expect_success 'frob it' '\n        cat >expect <<\"EOF\" &&\n... some expected output ...\nEOF\n        git frob &&\n        test_cmp expect actual\n'\n\n-Peff\n"},{"id":"150183","messageId":"7vtym2p34e.fsf@alter.siamese.dyndns.org","threadId":"25007","inReplyTo":"20100907043050.GA13291@sigill.intra.peff.net","subject":"Re: [PATCH 6/7] t1303 (config): style tweaks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-07T04:52:01Z","receivedAt":"2010-09-07T04:52:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> ... But I really don't want to be too draconian\n> about \"everything must go into test_expect_success\". Sure, if you are\n> executing commands that might have output, or might be of interest to\n> the user, put them there. But I find this a lot more readable:\n>\n> cat >expect <<'EOF'\n> ... some expected output ...\n> EOF\n> test_expect_success 'frob it' '\n>         git frob &&\n>         test_cmp expect actual\n> '\n>\n> than:\n>\n> test_expect_success 'frob it' '\n>         cat >expect <<\"EOF\" &&\n> ... some expected output ...\n> EOF\n>         git frob &&\n>         test_cmp expect actual\n> '\n\nI agree.\n\nMy gut feeling has been that any set-up that uses \"git\" should never be\noutside test_expect_success, but things like cat <<HERE / echo to prepare\ntest vector are not expected to fail (we are not in the business of\ntesting the build platform) and can be at the top of the script between\nthe inclusion of test-lib.sh and the first test_expect_success.\n\nWhen you throw in tools that are platform dependent to the mix, however,\nthings get muddier.  Setup that use stuff like \"ln -s this that\" and\n\"setacl\" is easier to handle inside test_expect_success guarded by an\nappropriate prerequisite.  So even that \"anything git should be inside,\neverything else can go outside if it wants to\" rule of thumb is not so\nblack and white.\n"},{"id":"150184","messageId":"7vlj7ep2ch.fsf@alter.siamese.dyndns.org","threadId":"25007","inReplyTo":"20100907023713.GJ1182@burratino","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-07T05:08:46Z","receivedAt":"2010-09-07T05:08:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>> If we were to insist that no matter how an individual test fail, the test\n>> that follows it must start in a known location (namely, $TRASH), then we\n>> might want to use something like the attached patch.\n>\n> I like it.  Affected test scripts:\n> ... (many) ...\n> and probably some others.\n\nFor the record, I _do not_ like it at all.  Is it worth being that\ndraconian and say each test must start at $TRASH?  What do we gain by it?\n\nWe certainly do _not_ want any test to wander around, escape out of the\n$TRASH directory and running random \"git\" command, but as long as N+1th\ntest knows and expects Nth test might move to a subdirectory of $TRASH and\nis prepared to start, I personally do not think it is such a big deal.  It\ncertainly makes it harder to insert a new test between such a pair of\ntests, but like it or not, many of the tests already depend on the state\nof the repository that earlier tests left behind.  I think we could just\ndeclare that $cwd is just a small part of that initial state for\nindividual test that was left behind the earlier test.\n\nAfter we vet and apply Jens and your \"turn 'cd there && do this && cd ..'\ninto a subshell\" series, and the \"modernize indentation style\" series,\nperhaps we should stop and think?  In an ideal world, it would be really\nnice if each \"test_expect_success/failure\" in a single script were\nindependent from each other (if we did so, GIT_SKIP_TESTS=4321.4 starts to\nbe more useful), but realistically, I don't think it is worth the effort.\n\nSo it may be worth it to check $(pwd) against $TRASH and make sure we\ndidn't escape $TRASH by mistake at the beginning of each test in test_run_\nfunction, but to me, \"must be at $TRASH\" feels like a rule for the sake of\nit, without really helping us very much.\n"},{"id":"150185","messageId":"20100907051218.GO1182@burratino","threadId":"25007","inReplyTo":"20100907043050.GA13291@sigill.intra.peff.net","subject":"guarding everything with test_expect_success (Re: [PATCH 6/7] t1303 (config): style tweaks)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T05:12:18Z","receivedAt":"2010-09-07T05:12:18Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(+cc: Ævar in case he is interested)\n\nHi,\n\nJeff King wrote:\n\n> So I dunno. Most of it I am fine with, though I question whether it is\n> really worth the effort. But I really don't want to be too draconian\n> about \"everything must go into test_expect_success\".\n\nThanks for the comments; that is very useful.  I'm sure you won't\nbe surprised to hear that that is a part I am more attached to than\nthe () vs {}, say.  I think I did not explain it well.\n\nAs you mentioned, it is a big departure from the style of the existing\ntests.  So why push it?  A quick story:\n\n1. Long ago, when I first debugged a test script with -v, I was a bit\n   confused because the transcript did not tell the whole story\n   (because some commands are run outside test assertions).  No big\n   deal, but I remembered it.\n\n2. Sometimes the setup commands outside of test scripts produce\n   output.  This is annoying, so people silence it.\n\n3. Sometimes the setup commands outside of test scripts are broken.\n   Tests do not use \"set -e\" or check for errors outside of test\n   assertions, so simple typos can go undetected for a long time.\n\n4. What actually provoked me to care about it: when trying to add a\n   test to t9301-fast-import.sh, say, I found myself completely lost.\n   It is really hard to figure out what the state is supposed to be\n   at a particular point in the test script.  Sometimes I am tempted\n   to write a new test script when adding a new behavior, only\n   because I do not understand the existing one on a topic.  All the\n   tests can be well-behaved and follow sane invariants, but that\n   does not matter, because the invariants are not documented anywhere.\n\nHow to fix that?  I would like to see tests look roughly like this:\n\n test_description='description of purpose\n\n description of state maintained between tests\n '\n\n . ./test-lib.sh\n\n test_expect_success 'setup' '\n\t...\n '\n\n test_expect_success 'some good thing holds' '\n\t... commands that do not break global state ...\n '\n\n test_expect_success 'another good thing holds' '\n\t... more peaceful test commands ...\n '\n\n test_expect_success 'setup: update global state somehow' '\n\t...\n '\n ...\n test_done\n\nSome of my other puzzling patches (test_might_fail, test_when_finished)\nare also meant for this purpose.  Of course, it will take a while.\n\nThe result would be:\n\n - test commands all shown with \"-v\", output all suppressed without;\n - all commands pass at least the sanity check of exiting with 0\n   status;\n - easy to write a GIT_SKIP_TESTS specification.  Would be possible\n   to add the ability to try a single test (plus all setup tests in\n   that script that precede it);\n - as long as all the setup tests pass, the list of failed tests\n   from a test failure can be more informative;\n - state can be tracked by just reading the setup tests.\n\n> Sure, if you are\n> executing commands that might have output, or might be of interest to\n> the user, put them there. But I find this a lot more readable:\n> \n> cat >expect <<'EOF'\n> ... some expected output ...\n> EOF\n> test_expect_success 'frob it' '\n\nI don't know: I think\n\n\tcat >expect <<-\\EOF &&\n\t...\n\tEOF\n\nis pretty readable.  The problem with sticking to\n\ncat >expect <<\\EOF\n...\nEOF\n\nis that once someone wants to include a commit id, they change\nit to\n\ncat >expect <<EOF\n... $(git rev-parse ... )\n...\nEOF\n\nand we have nontrivial code outside the test now.\n\nOn the other hand:\n\n> , but IMO you are\n> making at least one of them less readable, because you have to deal with\n> the extra quoting layer of test_expect_success. IOW:\n>\n>> -SECTION=\"test.q\\\"s\\\\sq'sp e.key\"\n>>  test_expect_success 'make sure git config escapes section names properly' '\n>> +       SECTION=\"test.q\\\"s\\\\sq'\\''sp e.key\" &&\n>\n> seems like a net loss to me.\n\nI wholeheartedly agree, and maybe I should have done\n\n\tapos=\"'\\''\" &&\n\tSECTION=\"test.q\\\"s\\\\sq${apos}sp e.key\" &&\n\nor something; this detail of quoting has never brought much happiness\nto me.\n\nSorry for the ramble.  Thoughts welcome.\nJonathan\n"},{"id":"150186","messageId":"20100907051922.GP1182@burratino","threadId":"25007","inReplyTo":"7vlj7ep2ch.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Several tests: cd inside subshell instead of around","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T05:19:22Z","receivedAt":"2010-09-07T05:19:22Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n>> I like it.  Affected test scripts:\n>> ... (many) ...\n>> and probably some others.\n>\n> For the record, I _do not_ like it at all.  Is it worth being that\n> draconian and say each test must start at $TRASH?  What do we gain by it?\n\nTo clarify, what I meant was something like \"I like it, but reality\ndoes not seem to permit it now\".\n\n> After we vet and apply Jens and your \"turn 'cd there && do this && cd ..'\n> into a subshell\" series, and the \"modernize indentation style\" series,\n> perhaps we should stop and think?  In an ideal world, it would be really\n> nice if each \"test_expect_success/failure\" in a single script were\n> independent from each other (if we did so, GIT_SKIP_TESTS=4321.4 starts to\n> be more useful), but realistically, I don't think it is worth the effort.\n\nAh, our emails crossed.  I would rather that tests that affect the\nstate be marked as such, nothing more.  The \"always return to $TRASH\"\nrule is a lot stronger than that, unfortunately.  What I really liked\nabout your suggestion is that the \"tests must start and end in $TRASH\"\nrule could be checked with very little effort.  Unfortunately, as the\nlist of scripts illustrates, that rule doesn't describe what our\ncurrent tests do.\n"},{"id":"150187","messageId":"20100907052758.GQ1182@burratino","threadId":"25007","inReplyTo":"7vtym2p34e.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 6/7] t1303 (config): style tweaks","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T05:27:59Z","receivedAt":"2010-09-07T05:27:59Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> My gut feeling has been that any set-up that uses \"git\" should never be\n> outside test_expect_success, but things like cat <<HERE / echo to prepare\n> test vector are not expected to fail (we are not in the business of\n> testing the build platform) and can be at the top of the script between\n> the inclusion of test-lib.sh and the first test_expect_success.\n\nSuch a strategy sounds fine to me, for what it's worth.\n\n(so:\n\n\ttest_description=...\n\t. ./test-lib.sh\n\tcat\n\t...\n\tmkdir\n\tcat\n\t...\n\tcat\n\t...\n\ttest_expect_success\n\t...\n\ttest_expect_success\n\t...\n\ttest_expect_failure\n\t...\n\ttest_expect_success\n\t...\n\ttest_done\n)\n"},{"id":"150191","messageId":"20100907055636.GA30357@sigill.intra.peff.net","threadId":"25007","inReplyTo":"20100907051218.GO1182@burratino","subject":"Re: guarding everything with test_expect_success (Re: [PATCH 6/7] t1303 (config): style tweaks)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-09-07T05:56:37Z","receivedAt":"2010-09-07T05:56:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 07, 2010 at 12:12:18AM -0500, Jonathan Nieder wrote:\n\n> As you mentioned, it is a big departure from the style of the existing\n> tests.  So why push it?  A quick story:\n> \n> 1. Long ago, when I first debugged a test script with -v, I was a bit\n>    confused because the transcript did not tell the whole story\n>    (because some commands are run outside test assertions).  No big\n>    deal, but I remembered it.\n\nYeah, that can be frustrating. However, I have found (as I think you\nhave, from your point 4 below) that it is not just about seeing the\nwhole story with \"-v\", but rather about reaching some state in the test\nscript which may depend on prior tests. So yes, if everything were in\n\"-v\", you could in theory cut and paste it all into a terminal. But\nwould you necessarily _want_ to, if it is test 25 in the script?\n\nWhat I often end up doing is sticking \"&& bash\" into the test, running\nthe script, and exploring from that state. Perhaps we could have more\nsupport for that. E.g., something like:\n\n  $ ./t1303-wacky-config.sh --debug=2\n  expecting success:\n          setup &&\n          git config section.key bar &&\n          check section.key bar\n  ok 1 - modify same key\n\n  entering debug session for test 2; test text is:\n        setup &&\n        git config section2.key bar &&\n        check section.key foo &&\n        check section2.key bar\n\n  $ [now try running commands]\n\nThe obvious problem is that you're actually in a subshell, not the same\nshell. We would probably want to do some behind-the-scenes magic to\nimport variables and functions from the parent shell (unless you can\nthink of a clever way to suddenly turn the existing shell interactive).\n\n> 2. Sometimes the setup commands outside of test scripts produce\n>    output.  This is annoying, so people silence it.\n\nYeah, it is annoying. And I am totally in favor of things that might\nproduce output going into test_expect_success blocks. And...\n\n> 3. Sometimes the setup commands outside of test scripts are broken.\n>    Tests do not use \"set -e\" or check for errors outside of test\n>    assertions, so simple typos can go undetected for a long time.\n\nI agree here. And I'm totally in favor of things that might fail going\ninto test_expect_success blocks. I don't consider running \"printf\", or\ndumping a here-document into a file via cat to be likely to fail.\n\n> 4. What actually provoked me to care about it: when trying to add a\n>    test to t9301-fast-import.sh, say, I found myself completely lost.\n>    It is really hard to figure out what the state is supposed to be\n>    at a particular point in the test script.  Sometimes I am tempted\n>    to write a new test script when adding a new behavior, only\n>    because I do not understand the existing one on a topic.  All the\n>    tests can be well-behaved and follow sane invariants, but that\n>    does not matter, because the invariants are not documented anywhere.\n\nTo some degree, I addressed this above. But yeah, even with a nice\ndrop-to-shell debug support, undocumented invariants are going to be a\npain when debugging a test. But I don't think moving them into a\ntest_expect_success block is going to help that. The problem is subtle\nstate changes of the test directory.\n\nThings like test_when_finished help with that, and I hope people will\nuse them. But I fear that tests will always suffer from being somewhat\nmessier than actual code, and will always be written in a bit of a\nprocedural fashion. That is, I don't think we will ever achieve a level\nof modularity and orthogonality in writing tests that would mean you\ncould just run some tests in isolation. It's just not worth the effort\nmost of the time.\n\nStill, I encourage you to try to push in that direction by leading by\nexample. You obviously have some ideas. My only real complaint about\nyour patch was that I find the syntax uglier. And your suggestions are\nnot alone in that. We have tons of ugly quoting because of the need to\ndouble-quote in test_expect_success. Perhaps we could refactor it into a\nset of two functions that keep state? E.g., something like:\n\ntest_start 'setup'\ncat >expect <<EOF\n... whatever ...\nEOF\ntest_end success\n\ntest_start 'description'\ngit frob >actual &&\ntest_cmp expect actual\ntest_end success\n\nwhere test_start would set up >&3 and >&4 as usual, and test_end would\ncheck $? and report the status. The biggest problem I see is that we\nnever have the actual shell script snippet as a string, so we don't have\na way of printing it for \"-v\" (or on failure). Hmm.\n\n> The result would be:\n> \n>  - test commands all shown with \"-v\", output all suppressed without;\n>  - all commands pass at least the sanity check of exiting with 0\n>    status;\n>  - easy to write a GIT_SKIP_TESTS specification.  Would be possible\n>    to add the ability to try a single test (plus all setup tests in\n>    that script that precede it);\n>  - as long as all the setup tests pass, the list of failed tests\n>    from a test failure can be more informative;\n>  - state can be tracked by just reading the setup tests.\n\nAgain, I think these are great goals. I'm not sure we will ever reach\nthem, or whether we will find the work that goes into them to be worth\nthe effort (especially because it is so easy to break these properties\nwith new tests, and there is not a good test harness for testing how\nwell you have written your tests).\n\n> I don't know: I think\n> \n> \tcat >expect <<-\\EOF &&\n> \t...\n> \tEOF\n> \n> is pretty readable.  The problem with sticking to\n\nYeah, I almost mentioned that, but for some reason in the back of my\nmind <<- is not actually portable. Perhaps I am just thinking of the\nfact that perl does not support it.\n\n-Peff\n"},{"id":"150192","messageId":"20100907061213.GU1182@burratino","threadId":"25007","inReplyTo":"20100907055636.GA30357@sigill.intra.peff.net","subject":"Re: guarding everything with test_expect_success (Re: [PATCH 6/7] t1303 (config): style tweaks)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T06:12:13Z","receivedAt":"2010-09-07T06:12:13Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jeff King wrote:\n\n> Perhaps we could refactor it into a\n> set of two functions that keep state? E.g., something like:\n> \n> test_start 'setup'\n> cat >expect <<EOF\n> ... whatever ...\n> EOF\n> test_end success\n> \n> test_start 'description'\n> git frob >actual &&\n> test_cmp expect actual\n> test_end success\n> \n> where test_start would set up >&3 and >&4 as usual, and test_end would\n> check $? and report the status. The biggest problem I see is that we\n> never have the actual shell script snippet as a string, so we don't have\n> a way of printing it for \"-v\" (or on failure). Hmm.\n\nFWIW I don't mind this idea (to be used as an alternative to\ntest_expect_success when quoting issues get ugly).  Maybe the harness\ncould fetch the snippet by parsing $0?  (Sorry, couldn't resist.\nSomething simpler might be possible: e.g., a special\n\ntest_expect_success 'description' - <<\\test_end\ncat >expect <<EOF\n... whatever ...\nEOF\ntest_end\n\nsyntax.)\n\n>> I don't know: I think\n>> \n>> \tcat >expect <<-\\EOF &&\n>> \t...\n>> \tEOF\n>> \n>> is pretty readable.  The problem with sticking to\n>\n> Yeah, I almost mentioned that, but for some reason in the back of my\n> mind <<- is not actually portable. Perhaps I am just thinking of the\n> fact that perl does not support it.\n\nI seem to remember some language where the here documents would snip\nsome well determined constant amount of whitespace from the enclosed\nlines.  Unfortunately in the shell, that is not the rule: <<- just\ntrims out all the leading tabs.\n\nSo when expected output includes leading tabs, it is ugly again.\n\n\tq_to_tab <<-\\EOF\n\tLike this:\n\n\tQ1. indented line\n\tQ2. second indented line\n\tEOF\n"},{"id":"150195","messageId":"201009071006.27607.trast@student.ethz.ch","threadId":"25007","inReplyTo":"20100907015509.GH1182@burratino","subject":"Re: [PATCH/RFC 7/7] t2016 (checkout -p): use printf for multiline y/n input","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-09-07T08:06:27Z","receivedAt":"2010-09-07T08:06:27Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jonathan Nieder wrote:\n> Instead of\n> \n> \t(echo y; echo n; echo n) | git checkout -p HEAD^ -- dir\n> \n> write\n> \n> \tprintf \"%s\\n\" y n n |\n> \tgit checkout -p HEAD^ -- dir\n> \n> which means the same thing but might be easier to read.\n\nI'm indifferent about this.  It does save a process, but (maybe that's\njust me though) I had to look up a POSIX manpage to verify that the\nrepeating behaviour is guaranteed.\n\n> While at it, add a missing && to the \"git checkout -p HEAD with change\n> already staged\" test.\n\nGood catch.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"150197","messageId":"20100907082253.GY1182@burratino","threadId":"25007","inReplyTo":"201009071006.27607.trast@student.ethz.ch","subject":"Re: [PATCH/RFC 7/7] t2016 (checkout -p): use printf for multiline y/n input","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-09-07T08:22:53Z","receivedAt":"2010-09-07T08:22:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Thomas Rast wrote:\n\n> I'm indifferent about this.  It does save a process, but (maybe that's\n> just me though) I had to look up a POSIX manpage to verify that the\n> repeating behaviour is guaranteed.\n\nIf saving a process is the only benefit, let's forget it.\n\n>> While at it, add a missing && to the \"git checkout -p HEAD with change\n>> already staged\" test.\n>\n> Good catch.\n\nHere's a patch with just that.\n\n-- 8< --\nSubject: t2016 (checkout -p): add missing &&\n\nAlthough the set_state command is not likely to fail, it is best to\nstay in the habit of checking for failures.\n\nCc: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t2016-checkout-patch.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t2016-checkout-patch.sh b/t/t2016-checkout-patch.sh\nindex 7657ec1..a463b13 100755\n--- a/t/t2016-checkout-patch.sh\n+++ b/t/t2016-checkout-patch.sh\n@@ -52,7 +52,7 @@ test_expect_success PERL 'git checkout -p HEAD with NO staged changes: apply' '\n '\n \n test_expect_success PERL 'git checkout -p HEAD with change already staged' '\n-\tset_state dir/foo index index\n+\tset_state dir/foo index index &&\n \t# the third n is to get out in case it mistakenly does not apply\n \t(echo n; echo y; echo n) | git checkout -p HEAD &&\n \tverify_saved_state bar &&\n-- \n1.7.2.3\n"},{"id":"150202","messageId":"4C861400.2030901@web.de","threadId":"25007","inReplyTo":"7vhbi2tqd0.fsf@alter.siamese.dyndns.org","subject":"[PATCH] t1020: Get rid of 'cd \"$HERE\"' at the start of each test","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-09-07T10:29:20Z","receivedAt":"2010-09-07T10:29:20Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"To achieve that, all cd commands which weren't inside a subshell had to\nbe put into a new one.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n\nAm 07.09.2010 01:16, schrieb Junio C Hamano:\n> If we were to do this, shouldn't we be able to lose 'cd \"$HERE\"' at the\n> beginning of each test?  The test after this one does \"cd dir\" without\n> even coming back up and relies on the next one to go back itself,\n\nYou are right, patch included. I had to introduce some new subshells\nfor that and used the new formatting proposed by Jonathan (but I didn't\ntouch the one introduced by my earlier patch which is reformatted by\nJonathan's \"[PATCH 1/7] tests: subshell indentation stylefix\", so both\npatches won't conflict.\n\n\n> suggesting that grepping for 'cd ..' may not be sufficient, depending on\n> what we are trying to fix.\n\nYeah, I knew this would only show a part of the problems. But you have\nto start somewhere, no? :-)\n(My first intention was to systematically search for missing &&, as\nthose really can be nasty, but my script-fu was not up to that task)\n\n\n> If we were to insist that no matter how an individual test fail, the test\n> that follows it must start in a known location (namely, $TRASH), then we\n> might want to use something like the attached patch.  On the other hand,\n> we might want to be lenient to a test suite whose one test moves around\n> and the test that follows such a test knows that, and also anticipates\n> that the previous one _can_ fail and tries recover from that failure (e.g.\n> use of 'cd \"$HERE\"' in the test that follows the above one.\n\nI think we should force that each test finishes somewhere inside $TRASH,\nbut not necessarily at the top level.\n\n t/t1020-subdirectory.sh |   91 ++++++++++++++++++++++++++---------------------\n 1 files changed, 50 insertions(+), 41 deletions(-)\n\ndiff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh\nindex c36157a..0eb4488 100755\n--- a/t/t1020-subdirectory.sh\n+++ b/t/t1020-subdirectory.sh\n@@ -16,12 +16,10 @@ test_expect_success setup '\n \tcp one original.one &&\n \tcp dir/two original.two\n '\n-HERE=`pwd`\n LF='\n '\n\n test_expect_success 'update-index and ls-files' '\n-\tcd \"$HERE\" &&\n \tgit update-index --add one &&\n \tcase \"`git ls-files`\" in\n \tone) echo pass one ;;\n@@ -41,20 +39,20 @@ test_expect_success 'update-index and ls-files' '\n '\n\n test_expect_success 'cat-file' '\n-\tcd \"$HERE\" &&\n \ttwo=`git ls-files -s dir/two` &&\n \ttwo=`expr \"$two\" : \"[0-7]* \\\\([0-9a-f]*\\\\)\"` &&\n \techo \"$two\" &&\n \tgit cat-file -p \"$two\" >actual &&\n \tcmp dir/two actual &&\n-\tcd dir &&\n-\tgit cat-file -p \"$two\" >actual &&\n-\tcmp two actual\n+\t(\n+\t\tcd dir &&\n+\t\tgit cat-file -p \"$two\" >actual &&\n+\t\tcmp two actual\n+\t)\n '\n rm -f actual dir/actual\n\n test_expect_success 'diff-files' '\n-\tcd \"$HERE\" &&\n \techo a >>one &&\n \techo d >>dir/two &&\n \tcase \"`git diff-files --name-only`\" in\n@@ -62,77 +60,88 @@ test_expect_success 'diff-files' '\n \t*) echo bad top; exit 1 ;;\n \tesac &&\n \t# diff should not omit leading paths\n-\tcd dir &&\n-\tcase \"`git diff-files --name-only`\" in\n-\tdir/two\"$LF\"one) echo pass subdir ;;\n-\t*) echo bad subdir; exit 1 ;;\n-\tesac &&\n-\tcase \"`git diff-files --name-only .`\" in\n-\tdir/two) echo pass subdir limited ;;\n-\t*) echo bad subdir limited; exit 1 ;;\n-\tesac\n+\t(\n+\t\tcd dir &&\n+\t\tcase \"`git diff-files --name-only`\" in\n+\t\tdir/two\"$LF\"one) echo pass subdir ;;\n+\t\t*) echo bad subdir; exit 1 ;;\n+\t\tesac &&\n+\t\tcase \"`git diff-files --name-only .`\" in\n+\t\tdir/two) echo pass subdir limited ;;\n+\t\t*) echo bad subdir limited; exit 1 ;;\n+\t\tesac\n+\t)\n '\n\n test_expect_success 'write-tree' '\n-\tcd \"$HERE\" &&\n \ttop=`git write-tree` &&\n \techo $top &&\n-\tcd dir &&\n-\tsub=`git write-tree` &&\n-\techo $sub &&\n-\ttest \"z$top\" = \"z$sub\"\n+\t(\n+\t\tcd dir &&\n+\t\tsub=`git write-tree` &&\n+\t\techo $sub &&\n+\t\ttest \"z$top\" = \"z$sub\"\n+\t)\n '\n\n test_expect_success 'checkout-index' '\n-\tcd \"$HERE\" &&\n \tgit checkout-index -f -u one &&\n \tcmp one original.one &&\n-\tcd dir &&\n-\tgit checkout-index -f -u two &&\n-\tcmp two ../original.two\n+\t(\n+\t\tcd dir &&\n+\t\tgit checkout-index -f -u two &&\n+\t\tcmp two ../original.two\n+\t)\n '\n\n test_expect_success 'read-tree' '\n-\tcd \"$HERE\" &&\n \trm -f one dir/two &&\n \ttree=`git write-tree` &&\n \tgit read-tree --reset -u \"$tree\" &&\n \tcmp one original.one &&\n \tcmp dir/two original.two &&\n-\tcd dir &&\n-\trm -f two &&\n-\tgit read-tree --reset -u \"$tree\" &&\n-\tcmp two ../original.two &&\n-\tcmp ../one ../original.one\n+\t(\n+\t\tcd dir &&\n+\t\trm -f two &&\n+\t\tgit read-tree --reset -u \"$tree\" &&\n+\t\tcmp two ../original.two &&\n+\t\tcmp ../one ../original.one\n+\t)\n '\n\n test_expect_success 'no file/rev ambiguity check inside .git' '\n-\tcd \"$HERE\" &&\n \tgit commit -a -m 1 &&\n-\tcd \"$HERE\"/.git &&\n-\tgit show -s HEAD\n+\t(\n+\t\tcd .git &&\n+\t\tgit show -s HEAD\n+\t)\n '\n\n test_expect_success 'no file/rev ambiguity check inside a bare repo' '\n-\tcd \"$HERE\" &&\n \tgit clone -s --bare .git foo.git &&\n-\tcd foo.git && GIT_DIR=. git show -s HEAD\n+\t(\n+\t\tcd foo.git &&\n+\t\tGIT_DIR=. git show -s HEAD\n+\t)\n '\n\n # This still does not work as it should...\n : test_expect_success 'no file/rev ambiguity check inside a bare repo' '\n-\tcd \"$HERE\" &&\n \tgit clone -s --bare .git foo.git &&\n-\tcd foo.git && git show -s HEAD\n+\t(\n+\t\tcd foo.git &&\n+\t\tgit show -s HEAD\n+\t)\n '\n\n test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '\n-\tcd \"$HERE\" &&\n \trm -fr foo.git &&\n \tgit clone -s .git another &&\n \tln -s another yetanother &&\n-\tcd yetanother/.git &&\n-\tgit show -s HEAD\n+\t(\n+\t\tcd yetanother/.git &&\n+\t\tgit show -s HEAD\n+\t)\n '\n\n test_done\n-- \n1.7.3.rc0.182.g5433f\n"},{"id":"150212","messageId":"4C8636AE.7070104@kitware.com","threadId":"25007","inReplyTo":"20100907014910.GD1182@burratino","subject":"Re: [PATCH 3/7] t2105 (gitfile): add missing &&","fromName":"Brad King","fromEmail":"brad.king@kitware.com","sentAt":"2010-09-07T12:57:18Z","receivedAt":"2010-09-07T12:57:18Z","isPatch":true,"sender":{"key":"brad.king@kitware.com","avatar":"https://avatars.githubusercontent.com/u/87268?v=4"},"body":"On 09/06/2010 09:49 PM, Jonathan Nieder wrote:\n> Make sure early failures are not masked by later successes.\n> \n> Cc: Brad King <brad.king@kitware.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n\nAn obvious oversight on my part.\n\nAcked-by: Brad King <brad.king@kitware.com>\n\nThanks,\n-Brad\n\n>  t/t2105-update-index-gitfile.sh |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/t/t2105-update-index-gitfile.sh b/t/t2105-update-index-gitfile.sh\n> index 641607d..a7f3d47 100755\n> --- a/t/t2105-update-index-gitfile.sh\n> +++ b/t/t2105-update-index-gitfile.sh\n> @@ -13,7 +13,7 @@ test_expect_success 'submodule with absolute .git file' '\n>  \t(cd sub1 &&\n>  \t git init &&\n>  \t REAL=\"$(pwd)/.real\" &&\n> -\t mv .git \"$REAL\"\n> +\t mv .git \"$REAL\" &&\n>  \t echo \"gitdir: $REAL\" >.git &&\n>  \t test_commit first)\n>  '\n"},{"id":"150259","messageId":"AANLkTinSAqEYnrU=S9mEOztK+hVGvNNh7OQ-hHgyUwKJ@mail.gmail.com","threadId":"25007","inReplyTo":"20100907015227.GF1182@burratino","subject":"Re: [PATCH 5/7] t1302 (core.repositoryversion): style tweaks","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-09-07T23:45:16Z","receivedAt":"2010-09-07T23:45:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/9/7 Jonathan Nieder <jrnieder@gmail.com>:\n> This test is from 2007, which is late enough for the style to be\n> recognizably modern but still a while ago.  Freshen it up to\n> follow new best practices:\n>\n>  - guard setup commands with test_expect_setup, so errors at\n>   that stage can be caught;\n>  - use <<\\EOF in preference to <<EOF, to save reviewers the\n>   trouble of looking for variable interpolations;\n>  - use test_cmp instead of test \"$foo\" = \"$bar\", for better\n>   output with -v on failure;\n>  - indent commands in subshells and let them span multiple lines;\n>  - combine the two \"gitdir required mode\" tests that do not make\n>   as much sense alone.\n>\n> Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n\nLooks good to me.\n-- \nDuy\n"}]}