diff mbox series

[1/2] test-lib-functions: test_create_repo learns --bare

Message ID 20210617124331.17888-1-zhiyou.jx@alibaba-inc.com (mailing list archive)
State New
Headers show
Series [1/2] test-lib-functions: test_create_repo learns --bare | expand

Commit Message

Jiang Xin June 17, 2021, 12:43 p.m. UTC
"test_create_repo" learns --bare option to create bare repository.

Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
---
 t/test-lib-functions.sh | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

Comments

Ævar Arnfjörð Bjarmason June 22, 2021, 4:48 p.m. UTC | #1
On Thu, Jun 17 2021, Jiang Xin wrote:

> "test_create_repo" learns --bare option to create bare repository.
>
> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
> ---
>  t/test-lib-functions.sh | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> index b823c14027..f6d1afe295 100644
> --- a/t/test-lib-functions.sh
> +++ b/t/test-lib-functions.sh
> @@ -1216,8 +1216,21 @@ test_atexit () {
>  }
>  
>  # Most tests can use the created repository, but some may need to create more.
> -# Usage: test_create_repo <directory>
> +# Usage: test_create_repo [--bare] <directory>
>  test_create_repo () {
> +	bare= &&
> +	while test $# -gt 0
> +	do
> +		case "$1" in
> +		--bare)
> +			bare=yes
> +			;;
> +		*)
> +			break
> +			;;
> +		esac
> +		shift
> +	done &&
>  	test "$#" = 1 ||
>  	BUG "not 1 parameter to test-create-repo"
>  	repo="$1"
> @@ -1226,10 +1239,13 @@ test_create_repo () {
>  		cd "$repo" || error "Cannot setup test environment"
>  		"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \
>  			init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
> -			init \
> +			init ${bare:+--bare} \
>  			"--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
>  		error "cannot run git init -- have you built things yet?"
> -		mv .git/hooks .git/hooks-disabled
> +		if test -z "$bare"
> +		then
> +			mv .git/hooks .git/hooks-disabled
> +		fi
>  	) || exit
>  }

It looks like you authored this before, but sent this after f0d4d398e28
(test-lib: split up and deprecate test_create_repo(), 2021-05-10) was
merged down.

Your 2/2 here looks like it's not needed after my 97c8aac9c5f (test-lib:
do not show advice about init.defaultBranch under --verbose, 2021-05-10)
either.
Jiang Xin June 23, 2021, 12:53 a.m. UTC | #2
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 于2021年6月23日周三 上午12:51写道:
>
>
> On Thu, Jun 17 2021, Jiang Xin wrote:
>
> > "test_create_repo" learns --bare option to create bare repository.
> >
> > Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
> > ---
> >  t/test-lib-functions.sh | 22 +++++++++++++++++++---
> >  1 file changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> > index b823c14027..f6d1afe295 100644
> > --- a/t/test-lib-functions.sh
> > +++ b/t/test-lib-functions.sh
> > @@ -1216,8 +1216,21 @@ test_atexit () {
> >  }
> >
> >  # Most tests can use the created repository, but some may need to create more.
> > -# Usage: test_create_repo <directory>
> > +# Usage: test_create_repo [--bare] <directory>
> >  test_create_repo () {
> > +     bare= &&
> > +     while test $# -gt 0
> > +     do
> > +             case "$1" in
> > +             --bare)
> > +                     bare=yes
> > +                     ;;
> > +             *)
> > +                     break
> > +                     ;;
> > +             esac
> > +             shift
> > +     done &&
> >       test "$#" = 1 ||
> >       BUG "not 1 parameter to test-create-repo"
> >       repo="$1"
> > @@ -1226,10 +1239,13 @@ test_create_repo () {
> >               cd "$repo" || error "Cannot setup test environment"
> >               "${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \
> >                       init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
> > -                     init \
> > +                     init ${bare:+--bare} \
> >                       "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
> >               error "cannot run git init -- have you built things yet?"
> > -             mv .git/hooks .git/hooks-disabled
> > +             if test -z "$bare"
> > +             then
> > +                     mv .git/hooks .git/hooks-disabled
> > +             fi
> >       ) || exit
> >  }
>
> It looks like you authored this before, but sent this after f0d4d398e28
> (test-lib: split up and deprecate test_create_repo(), 2021-05-10) was
> merged down.
>
> Your 2/2 here looks like it's not needed after my 97c8aac9c5f (test-lib:
> do not show advice about init.defaultBranch under --verbose, 2021-05-10)
> either.

Thanks Ævar for reminding this.
diff mbox series

Patch

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index b823c14027..f6d1afe295 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1216,8 +1216,21 @@  test_atexit () {
 }
 
 # Most tests can use the created repository, but some may need to create more.
-# Usage: test_create_repo <directory>
+# Usage: test_create_repo [--bare] <directory>
 test_create_repo () {
+	bare= &&
+	while test $# -gt 0
+	do
+		case "$1" in
+		--bare)
+			bare=yes
+			;;
+		*)
+			break
+			;;
+		esac
+		shift
+	done &&
 	test "$#" = 1 ||
 	BUG "not 1 parameter to test-create-repo"
 	repo="$1"
@@ -1226,10 +1239,13 @@  test_create_repo () {
 		cd "$repo" || error "Cannot setup test environment"
 		"${GIT_TEST_INSTALLED:-$GIT_EXEC_PATH}/git$X" -c \
 			init.defaultBranch="${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" \
-			init \
+			init ${bare:+--bare} \
 			"--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
 		error "cannot run git init -- have you built things yet?"
-		mv .git/hooks .git/hooks-disabled
+		if test -z "$bare"
+		then
+			mv .git/hooks .git/hooks-disabled
+		fi
 	) || exit
 }