[PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions

2013-04-02 Thread Ramkumar Ramachandra
From: Jeff King p...@peff.net

Many of the tests in t5516 look like:

  mk_empty 
  git push testrepo ... 
  check_push_result $commit heads/master

It's reasonably easy to see what is being tested, with the
exception that testrepo is a magic global name (it is
implicitly used in the helpers, but we have to name it
explicitly when calling git directly). Let's make it
explicit when call the helpers, too. This is slightly more
typing, but makes the test snippets read more naturally.

It also makes it easy for future tests to use an alternate
or multiple repositories, without a proliferation of helper
functions.

[rr: fixed sloppy quoting]

Signed-off-by: Jeff King p...@peff.net
Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
 t/t5516-fetch-push.sh | 282 ++
 1 file changed, 145 insertions(+), 137 deletions(-)

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index f394271..b800a8e 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -18,10 +18,11 @@ This test checks the following functionality:
 D=`pwd`
 
 mk_empty () {
-   rm -fr testrepo 
-   mkdir testrepo 
+   repo_name=$1
+   rm -fr $repo_name 
+   mkdir $repo_name 
(
-   cd testrepo 
+   cd $repo_name 
git init 
git config receive.denyCurrentBranch warn 
mv .git/hooks .git/hooks-disabled
@@ -29,14 +30,17 @@ mk_empty () {
 }
 
 mk_test () {
-   mk_empty 
+   repo_name=$1
+   shift
+
+   mk_empty $repo_name 
(
for ref in $@
do
-   git push testrepo $the_first_commit:refs/$ref ||
+   git push $repo_name $the_first_commit:refs/$ref ||
exit
done 
-   cd testrepo 
+   cd $repo_name 
for ref in $@
do
echo $the_first_commit expect 
@@ -49,9 +53,10 @@ mk_test () {
 }
 
 mk_test_with_hooks() {
+   repo_name=$1
mk_test $@ 
(
-   cd testrepo 
+   cd $repo_name 
mkdir .git/hooks 
cd .git/hooks 
 
@@ -83,13 +88,16 @@ mk_test_with_hooks() {
 }
 
 mk_child() {
-   rm -rf $1 
-   git clone testrepo $1
+   rm -rf $2 
+   git clone $1 $2
 }
 
 check_push_result () {
+   repo_name=$1
+   shift
+
(
-   cd testrepo 
+   cd $repo_name 
echo $1 expect 
shift 
for ref in $@
@@ -119,7 +127,7 @@ test_expect_success setup '
 '
 
 test_expect_success 'fetch without wildcard' '
-   mk_empty 
+   mk_empty testrepo 
(
cd testrepo 
git fetch .. refs/heads/master:refs/remotes/origin/master 
@@ -131,7 +139,7 @@ test_expect_success 'fetch without wildcard' '
 '
 
 test_expect_success 'fetch with wildcard' '
-   mk_empty 
+   mk_empty testrepo 
(
cd testrepo 
git config remote.up.url .. 
@@ -145,7 +153,7 @@ test_expect_success 'fetch with wildcard' '
 '
 
 test_expect_success 'fetch with insteadOf' '
-   mk_empty 
+   mk_empty testrepo 
(
TRASH=$(pwd)/ 
cd testrepo 
@@ -161,7 +169,7 @@ test_expect_success 'fetch with insteadOf' '
 '
 
 test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
-   mk_empty 
+   mk_empty testrepo 
(
TRASH=$(pwd)/ 
cd testrepo 
@@ -177,7 +185,7 @@ test_expect_success 'fetch with pushInsteadOf (should not 
rewrite)' '
 '
 
 test_expect_success 'push without wildcard' '
-   mk_empty 
+   mk_empty testrepo 
 
git push testrepo refs/heads/master:refs/remotes/origin/master 
(
@@ -189,7 +197,7 @@ test_expect_success 'push without wildcard' '
 '
 
 test_expect_success 'push with wildcard' '
-   mk_empty 
+   mk_empty testrepo 
 
git push testrepo refs/heads/*:refs/remotes/origin/* 
(
@@ -201,7 +209,7 @@ test_expect_success 'push with wildcard' '
 '
 
 test_expect_success 'push with insteadOf' '
-   mk_empty 
+   mk_empty testrepo 
TRASH=$(pwd)/ 
test_config url.$TRASH.insteadOf trash/ 
git push trash/testrepo refs/heads/master:refs/remotes/origin/master 
@@ -214,7 +222,7 @@ test_expect_success 'push with insteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf' '
-   mk_empty 
+   mk_empty testrepo 
TRASH=$(pwd)/ 
test_config url.$TRASH.pushInsteadOf trash/ 
git push trash/testrepo refs/heads/master:refs/remotes/origin/master 
@@ -227,7 +235,7 @@ test_expect_success 'push with pushInsteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf and explicit pushurl 
(pushInsteadOf should not rewrite)' '
-   mk_empty 
+   mk_empty testrepo 
TRASH=$(pwd)/ 

[PATCH 3/6] t5516 (fetch-push): drop implicit arguments from helper functions

2013-03-28 Thread Ramkumar Ramachandra
From: Jeff King p...@peff.net

Many of the tests in t5516 look like:

  mk_empty 
  git push testrepo ... 
  check_push_result $commit heads/master

It's reasonably easy to see what is being tested, with the
exception that testrepo is a magic global name (it is
implicitly used in the helpers, but we have to name it
explicitly when calling git directly). Let's make it
explicit when call the helpers, too. This is slightly more
typing, but makes the test snippets read more naturally.

It also makes it easy for future tests to use an alternate
or multiple repositories, without a proliferation of helper
functions.

[rr: fixed sloppy quoting]

Signed-off-by: Jeff King p...@peff.net
Signed-off-by: Ramkumar Ramachandra artag...@gmail.com
---
 t/t5516-fetch-push.sh | 276 ++
 1 file changed, 142 insertions(+), 134 deletions(-)

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 38f8fc0..94e0189 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -18,10 +18,11 @@ This test checks the following functionality:
 D=`pwd`
 
 mk_empty () {
-   rm -fr testrepo 
-   mkdir testrepo 
+   repo_name=$1
+   rm -fr $repo_name 
+   mkdir $repo_name 
(
-   cd testrepo 
+   cd $repo_name 
git init 
git config receive.denyCurrentBranch warn 
mv .git/hooks .git/hooks-disabled
@@ -29,16 +30,19 @@ mk_empty () {
 }
 
 mk_test () {
-   mk_empty 
+   repo_name=$1
+   shift
+
+   mk_empty $repo_name 
(
for ref in $@
do
-   git push testrepo $the_first_commit:refs/$ref || {
+   git push $repo_name $the_first_commit:refs/$ref || {
echo Oops, push refs/$ref failure
exit 1
}
done 
-   cd testrepo 
+   cd $repo_name 
for ref in $@
do
r=$(git show-ref -s --verify refs/$ref) 
@@ -52,9 +56,10 @@ mk_test () {
 }
 
 mk_test_with_hooks() {
+   repo_name=$1
mk_test $@ 
(
-   cd testrepo 
+   cd $repo_name 
mkdir .git/hooks 
cd .git/hooks 
 
@@ -86,13 +91,16 @@ mk_test_with_hooks() {
 }
 
 mk_child() {
-   rm -rf $1 
-   git clone testrepo $1
+   rm -rf $2 
+   git clone $1 $2
 }
 
 check_push_result () {
+   repo_name=$1
+   shift
+
(
-   cd testrepo 
+   cd $repo_name 
it=$1 
shift
for ref in $@
@@ -124,7 +132,7 @@ test_expect_success setup '
 '
 
 test_expect_success 'fetch without wildcard' '
-   mk_empty 
+   mk_empty testrepo 
(
cd testrepo 
git fetch .. refs/heads/master:refs/remotes/origin/master 
@@ -137,7 +145,7 @@ test_expect_success 'fetch without wildcard' '
 '
 
 test_expect_success 'fetch with wildcard' '
-   mk_empty 
+   mk_empty testrepo 
(
cd testrepo 
git config remote.up.url .. 
@@ -152,7 +160,7 @@ test_expect_success 'fetch with wildcard' '
 '
 
 test_expect_success 'fetch with insteadOf' '
-   mk_empty 
+   mk_empty testrepo 
(
TRASH=$(pwd)/ 
cd testrepo 
@@ -169,7 +177,7 @@ test_expect_success 'fetch with insteadOf' '
 '
 
 test_expect_success 'fetch with pushInsteadOf (should not rewrite)' '
-   mk_empty 
+   mk_empty testrepo 
(
TRASH=$(pwd)/ 
cd testrepo 
@@ -186,7 +194,7 @@ test_expect_success 'fetch with pushInsteadOf (should not 
rewrite)' '
 '
 
 test_expect_success 'push without wildcard' '
-   mk_empty 
+   mk_empty testrepo 
 
git push testrepo refs/heads/master:refs/remotes/origin/master 
(
@@ -199,7 +207,7 @@ test_expect_success 'push without wildcard' '
 '
 
 test_expect_success 'push with wildcard' '
-   mk_empty 
+   mk_empty testrepo 
 
git push testrepo refs/heads/*:refs/remotes/origin/* 
(
@@ -212,7 +220,7 @@ test_expect_success 'push with wildcard' '
 '
 
 test_expect_success 'push with insteadOf' '
-   mk_empty 
+   mk_empty testrepo 
TRASH=$(pwd)/ 
git config url.$TRASH.insteadOf trash/ 
git push trash/testrepo refs/heads/master:refs/remotes/origin/master 
@@ -226,7 +234,7 @@ test_expect_success 'push with insteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf' '
-   mk_empty 
+   mk_empty testrepo 
TRASH=$(pwd)/ 
git config url.$TRASH.pushInsteadOf trash/ 
git push trash/testrepo refs/heads/master:refs/remotes/origin/master 
@@ -240,7 +248,7 @@ test_expect_success 'push with pushInsteadOf' '
 '
 
 test_expect_success 'push with pushInsteadOf and explicit pushurl 
(pushInsteadOf