[PATCH 12/12] tests: use test_create_repo instead of "git init"

John Keeping john at keeping.me.uk
Mon Apr 8 21:12:41 CEST 2013


This gets us a more consistent initial repository state with a fixed
template and no hooks.

Also change the setup code to use a subshell instead of the "cd there;
...; cd back" anti-pattern.

Signed-off-by: John Keeping <john at keeping.me.uk>
---
 tests/setup.sh | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/tests/setup.sh b/tests/setup.sh
index 5977390..f5a788e 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -60,28 +60,25 @@ fi
 mkrepo() {
 	name=$1
 	count=$2
-	dir=$PWD
-	test -d "$name" && return
-	printf "Creating testrepo %s\n" "$name"
-	mkdir -p "$name"
-	cd "$name"
-	git init
-	n=1
-	while test $n -le $count
-	do
-		echo $n >file-$n
-		git add file-$n
-		git commit -m "commit $n"
-		n=$(expr $n + 1)
-	done
-	if test "$3" = "testplus"
-	then
-		echo "hello" >a+b
-		git add a+b
-		git commit -m "add a+b"
-		git branch "1+2"
-	fi
-	cd "$dir"
+	test_create_repo "$name"
+	(
+		cd "$name"
+		n=1
+		while test $n -le $count
+		do
+			echo $n >file-$n
+			git add file-$n
+			git commit -m "commit $n"
+			n=$(expr $n + 1)
+		done
+		if test "$3" = "testplus"
+		then
+			echo "hello" >a+b
+			git add a+b
+			git commit -m "add a+b"
+			git branch "1+2"
+		fi
+	)
 }
 
 setup_repos()
-- 
1.8.2.694.ga76e9c3.dirty





More information about the CGit mailing list