Commit b32c452563c515bd8597b168d85510fa50d64f65

Stefan Sperling 2020-01-05T19:19:59

make it possible to run regress tests with packed repositories

diff --git a/README b/README
index 6f21c24..94876ae 100644
--- a/README
+++ b/README
@@ -33,6 +33,10 @@ binaries in $PATH. Tests in the cmdline directory currently depend on git(1).
  $ doas pkg_add git
  $ make regress
 
+To test with packed repositories, run:
+
+ $ make regress GOT_TEST_PACK=1
+
 Man page files in the Got source tree can be viewed with 'man -l':
 
  $ man -l got/got.1
diff --git a/regress/cmdline/common.sh b/regress/cmdline/common.sh
index 1b91f45..3089992 100644
--- a/regress/cmdline/common.sh
+++ b/regress/cmdline/common.sh
@@ -29,11 +29,20 @@ function git_init
 	git init -q "$1"
 }
 
+function maybe_pack_repo
+{
+	local repo="$1"
+	if [ -n "$GOT_TEST_PACK" ]; then
+		(cd $repo && git repack -a -q)
+	fi
+}
+
 function git_commit
 {
 	local repo="$1"
 	shift
 	(cd $repo && git commit --author="$GOT_AUTHOR" -q -a "$@")
+	maybe_pack_repo $repo
 }
 
 function git_rm
@@ -96,6 +105,7 @@ function git_commit_tree
 	local msg="$2"
 	local tree="$3"
 	(cd $repo && git commit-tree -m "$msg" "$tree")
+	maybe_pack_repo $repo
 }
 
 function make_test_tree