Skip to content

Commit

Permalink
tests: subshell indentation stylefix
Browse files Browse the repository at this point in the history
Format the subshells introduced by the previous patch (Several tests:
cd inside subshell instead of around, 2010-09-06) like so:

	(
		cd subdir &&
		...
	) &&

This is generally easier to read and has the nice side-effect that
this patch will show what commands are used in the subshell, making
it easier to check for lost environment variables and similar
behavior changes.

Cc: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
jrn authored and gitster committed Sep 9, 2010
1 parent 347c47e commit 18a8269
Show file tree
Hide file tree
Showing 22 changed files with 260 additions and 192 deletions.
13 changes: 7 additions & 6 deletions t/t1020-subdirectory.sh
Expand Up @@ -27,12 +27,13 @@ test_expect_success 'update-index and ls-files' '
one) echo pass one ;;
*) echo bad one; exit 1 ;;
esac &&
(cd dir &&
git update-index --add two &&
case "`git ls-files`" in
two) echo pass two ;;
*) echo bad two; exit 1 ;;
esac
(
cd dir &&
git update-index --add two &&
case "`git ls-files`" in
two) echo pass two ;;
*) echo bad two; exit 1 ;;
esac
) &&
case "`git ls-files`" in
dir/two"$LF"one) echo pass both ;;
Expand Down
11 changes: 9 additions & 2 deletions t/t1302-repo-version.sh
Expand Up @@ -33,8 +33,15 @@ test_expect_success 'gitdir selection on unsupported repo' '

test_expect_success 'gitdir not required mode' '
git apply --stat test.patch &&
(cd test && git apply --stat ../test.patch) &&
(cd test2 && git apply --stat ../test.patch)'
(
cd test &&
git apply --stat ../test.patch
) &&
(
cd test2 &&
git apply --stat ../test.patch
)
'

test_expect_success 'gitdir required mode on normal repos' '
(git apply --check --index test.patch &&
Expand Down
12 changes: 6 additions & 6 deletions t/t3060-ls-files-with-tree.sh
Expand Up @@ -53,13 +53,13 @@ test_expect_success setup '
git add .
'

# We have to run from a sub-directory to trigger prune_path
# Then we finally get to run our --with-tree test

test_expect_success 'git -ls-files --with-tree should succeed from subdir' '
(cd sub && git ls-files --with-tree=HEAD~1 >../output)
# We have to run from a sub-directory to trigger prune_path
# Then we finally get to run our --with-tree test
(
cd sub &&
git ls-files --with-tree=HEAD~1 >../output
)
'

test_expect_success \
Expand Down
13 changes: 7 additions & 6 deletions t/t3409-rebase-preserve-merges.sh
Expand Up @@ -52,12 +52,13 @@ test_expect_success 'setup for merge-preserving rebase' \
git commit -m "Add different B" &&
git clone ./. clone2 &&
(cd clone2 &&
git checkout -b topic origin/topic &&
test_must_fail git merge origin/master &&
echo Resolved > B &&
git add B &&
git commit -m "Merge origin/master into topic"
(
cd clone2 &&
git checkout -b topic origin/topic &&
test_must_fail git merge origin/master &&
echo Resolved >B &&
git add B &&
git commit -m "Merge origin/master into topic"
) &&
git checkout topic &&
Expand Down
5 changes: 3 additions & 2 deletions t/t3903-stash.sh
Expand Up @@ -69,8 +69,9 @@ test_expect_success 'apply stashed changes (including index)' '
test_expect_success 'unstashing in a subdirectory' '
git reset --hard HEAD &&
mkdir subdir &&
(cd subdir &&
git stash apply
(
cd subdir &&
git stash apply
)
'

Expand Down
7 changes: 4 additions & 3 deletions t/t4041-diff-submodule-option.sh
Expand Up @@ -85,9 +85,10 @@ EOF
"

commit_file sm1 &&
head3=$(cd sm1 &&
git reset --hard HEAD~2 >/dev/null &&
git rev-parse --verify HEAD | cut -c1-7
head3=$(
cd sm1 &&
git reset --hard HEAD~2 >/dev/null &&
git rev-parse --verify HEAD | cut -c1-7
)

test_expect_success 'modified submodule(backward)' "
Expand Down
35 changes: 19 additions & 16 deletions t/t5510-fetch.sh
Expand Up @@ -21,26 +21,29 @@ test_expect_success setup '

test_expect_success "clone and setup child repos" '
git clone . one &&
(cd one &&
echo >file updated by one &&
git commit -a -m "updated by one"
(
cd one &&
echo >file updated by one &&
git commit -a -m "updated by one"
) &&
git clone . two &&
(cd two &&
git config branch.master.remote one &&
git config remote.one.url ../one/.git/ &&
git config remote.one.fetch refs/heads/master:refs/heads/one
(
cd two &&
git config branch.master.remote one &&
git config remote.one.url ../one/.git/ &&
git config remote.one.fetch refs/heads/master:refs/heads/one
) &&
git clone . three &&
(cd three &&
git config branch.master.remote two &&
git config branch.master.merge refs/heads/one &&
mkdir -p .git/remotes &&
{
echo "URL: ../two/.git/"
echo "Pull: refs/heads/master:refs/heads/two"
echo "Pull: refs/heads/one:refs/heads/one"
} >.git/remotes/two
(
cd three &&
git config branch.master.remote two &&
git config branch.master.merge refs/heads/one &&
mkdir -p .git/remotes &&
{
echo "URL: ../two/.git/"
echo "Pull: refs/heads/master:refs/heads/two"
echo "Pull: refs/heads/one:refs/heads/one"
} >.git/remotes/two
) &&
git clone . bundle &&
git clone . seven
Expand Down
46 changes: 25 additions & 21 deletions t/t6050-replace.sh
Expand Up @@ -104,16 +104,17 @@ test_expect_success '"git fsck" works' '
test_expect_success 'repack, clone and fetch work' '
git repack -a -d &&
git clone --no-hardlinks . clone_dir &&
(cd clone_dir &&
git show HEAD~5 | grep "A U Thor" &&
git show $HASH2 | grep "A U Thor" &&
git cat-file commit $R &&
git repack -a -d &&
test_must_fail git cat-file commit $R &&
git fetch ../ "refs/replace/*:refs/replace/*" &&
git show HEAD~5 | grep "O Thor" &&
git show $HASH2 | grep "O Thor" &&
git cat-file commit $R
(
cd clone_dir &&
git show HEAD~5 | grep "A U Thor" &&
git show $HASH2 | grep "A U Thor" &&
git cat-file commit $R &&
git repack -a -d &&
test_must_fail git cat-file commit $R &&
git fetch ../ "refs/replace/*:refs/replace/*" &&
git show HEAD~5 | grep "O Thor" &&
git show $HASH2 | grep "O Thor" &&
git cat-file commit $R
)
'

Expand Down Expand Up @@ -177,9 +178,10 @@ test_expect_success 'create parallel branch without the bug' '

test_expect_success 'push to cloned repo' '
git push cloned $HASH6^:refs/heads/parallel &&
(cd clone_dir &&
git checkout parallel &&
git log --pretty=oneline | grep $PARA2
(
cd clone_dir &&
git checkout parallel &&
git log --pretty=oneline | grep $PARA2
)
'

Expand All @@ -191,19 +193,21 @@ test_expect_success 'push branch with replacement' '
git show $HASH6~2 | grep "O Thor" &&
git show $PARA3 | grep "O Thor" &&
git push cloned $HASH6^:refs/heads/parallel2 &&
(cd clone_dir &&
git checkout parallel2 &&
git log --pretty=oneline | grep $PARA3 &&
git show $PARA3 | grep "A U Thor"
(
cd clone_dir &&
git checkout parallel2 &&
git log --pretty=oneline | grep $PARA3 &&
git show $PARA3 | grep "A U Thor"
)
'

test_expect_success 'fetch branch with replacement' '
git branch tofetch $HASH6 &&
(cd clone_dir &&
git fetch origin refs/heads/tofetch:refs/heads/parallel3
git log --pretty=oneline parallel3 | grep $PARA3
git show $PARA3 | grep "A U Thor"
(
cd clone_dir &&
git fetch origin refs/heads/tofetch:refs/heads/parallel3
git log --pretty=oneline parallel3 | grep $PARA3
git show $PARA3 | grep "A U Thor"
)
'

Expand Down
11 changes: 6 additions & 5 deletions t/t7400-submodule-basic.sh
Expand Up @@ -413,11 +413,12 @@ test_expect_success 'submodule <invalid-path> warns' '

test_expect_success 'add submodules without specifying an explicit path' '
mkdir repo &&
(cd repo &&
git init &&
echo r >r &&
git add r &&
git commit -m "repo commit 1"
(
cd repo &&
git init &&
echo r >r &&
git add r &&
git commit -m "repo commit 1"
) &&
git clone --bare repo/ bare.git &&
cd addtest &&
Expand Down
7 changes: 4 additions & 3 deletions t/t7401-submodule-summary.sh
Expand Up @@ -66,9 +66,10 @@ EOF
"

commit_file sm1 &&
head3=$(cd sm1 &&
git reset --hard HEAD~2 >/dev/null &&
git rev-parse --verify HEAD | cut -c1-7
head3=$(
cd sm1 &&
git reset --hard HEAD~2 >/dev/null &&
git rev-parse --verify HEAD | cut -c1-7
)

test_expect_success 'modified submodule(backward)' "
Expand Down
21 changes: 11 additions & 10 deletions t/t9100-git-svn-basic.sh
Expand Up @@ -22,16 +22,17 @@ esac
test_expect_success \
'initialize git svn' '
mkdir import &&
(cd import &&
echo foo > foo &&
ln -s foo foo.link
mkdir -p dir/a/b/c/d/e &&
echo "deep dir" > dir/a/b/c/d/e/file &&
mkdir bar &&
echo "zzz" > bar/zzz &&
echo "#!/bin/sh" > exec.sh &&
chmod +x exec.sh &&
svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null
(
cd import &&
echo foo >foo &&
ln -s foo foo.link
mkdir -p dir/a/b/c/d/e &&
echo "deep dir" >dir/a/b/c/d/e/file &&
mkdir bar &&
echo "zzz" >bar/zzz &&
echo "#!/bin/sh" >exec.sh &&
chmod +x exec.sh &&
svn_cmd import -m "import for git svn" . "$svnrepo" >/dev/null
) &&
rm -rf import &&
git svn init "$svnrepo"'
Expand Down
33 changes: 19 additions & 14 deletions t/t9101-git-svn-props.sh
Expand Up @@ -53,8 +53,9 @@ cd ..

rm -rf import
test_expect_success 'checkout working copy from svn' 'svn co "$svnrepo" test_wc'
test_expect_success 'setup some commits to svn' \
'(cd test_wc &&
test_expect_success 'setup some commits to svn' '
(
cd test_wc &&
echo Greetings >> kw.c &&
poke kw.c &&
svn_cmd commit -m "Not yet an Id" &&
Expand All @@ -64,7 +65,8 @@ test_expect_success 'setup some commits to svn' \
svn_cmd propset svn:keywords Id kw.c &&
poke kw.c &&
svn_cmd commit -m "Propset Id"
)'
)
'

test_expect_success 'initialize git svn' 'git svn init "$svnrepo"'
test_expect_success 'fetch revisions from svn' 'git svn fetch'
Expand All @@ -81,13 +83,15 @@ expect='/* $Id$ */'
got="`sed -ne 2p kw.c`"
test_expect_success 'raw $Id$ found in kw.c' "test '$expect' = '$got'"

test_expect_success "propset CR on crlf files" \
'(cd test_wc &&
test_expect_success "propset CR on crlf files" '
(
cd test_wc &&
svn_cmd propset svn:eol-style CR empty &&
svn_cmd propset svn:eol-style CR crlf &&
svn_cmd propset svn:eol-style CR ne_crlf &&
svn_cmd commit -m "propset CR on crlf files"
)'
)
'

test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
'git svn fetch &&
Expand Down Expand Up @@ -137,19 +141,20 @@ cat > show-ignore.expect <<\EOF
EOF

test_expect_success 'test show-ignore' "
(cd test_wc &&
mkdir -p deeply/nested/directory &&
touch deeply/nested/directory/.keep &&
svn_cmd add deeply &&
svn_cmd up &&
svn_cmd propset -R svn:ignore '
(
cd test_wc &&
mkdir -p deeply/nested/directory &&
touch deeply/nested/directory/.keep &&
svn_cmd add deeply &&
svn_cmd up &&
svn_cmd propset -R svn:ignore '
no-such-file*
' .
svn_cmd commit -m 'propset svn:ignore'
svn_cmd commit -m 'propset svn:ignore'
) &&
git svn show-ignore > show-ignore.got &&
cmp show-ignore.expect show-ignore.got
"
"

cat >create-ignore.expect <<\EOF
/no-such-file*
Expand Down
13 changes: 7 additions & 6 deletions t/t9102-git-svn-deep-rmdir.sh
Expand Up @@ -4,12 +4,13 @@ test_description='git svn rmdir'

test_expect_success 'initialize repo' '
mkdir import &&
(cd import &&
mkdir -p deeply/nested/directory/number/1 &&
mkdir -p deeply/nested/directory/number/2 &&
echo foo > deeply/nested/directory/number/1/file &&
echo foo > deeply/nested/directory/number/2/another &&
svn_cmd import -m "import for git svn" . "$svnrepo"
(
cd import &&
mkdir -p deeply/nested/directory/number/1 &&
mkdir -p deeply/nested/directory/number/2 &&
echo foo >deeply/nested/directory/number/1/file &&
echo foo >deeply/nested/directory/number/2/another &&
svn_cmd import -m "import for git svn" . "$svnrepo"
)
'

Expand Down

0 comments on commit 18a8269

Please sign in to comment.