* [PATCH 1/2] test-lib-functions: test_create_repo learns --bare
@ 2021-06-17 12:43 Jiang Xin
2021-06-17 12:43 ` [PATCH 2/2] test: create repo using test_create_repo Jiang Xin
2021-06-22 16:48 ` [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Ævar Arnfjörð Bjarmason
0 siblings, 2 replies; 4+ messages in thread
From: Jiang Xin @ 2021-06-17 12:43 UTC (permalink / raw)
To: Junio C Hamano, Git List; +Cc: Jiang Xin
"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
}
--
2.32.0.rc0.27.g7b1e85181b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] test: create repo using test_create_repo
2021-06-17 12:43 [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Jiang Xin
@ 2021-06-17 12:43 ` Jiang Xin
2021-06-22 16:48 ` [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 4+ messages in thread
From: Jiang Xin @ 2021-06-17 12:43 UTC (permalink / raw)
To: Junio C Hamano, Git List; +Cc: Jiang Xin
When creating new repository, function "test_create_repo" uses env
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME as default branch. Replace
"git-init" with "test_create_repo" in t5411, t5548 and t6020 to create
repository with specific default branch.
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
---
t/t5411-proc-receive-hook.sh | 4 ++--
t/t5548-push-porcelain.sh | 7 +++++--
t/t6020-bundle-misc.sh | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh
index 98b0e81208..7148e5ab7e 100755
--- a/t/t5411-proc-receive-hook.sh
+++ b/t/t5411-proc-receive-hook.sh
@@ -18,8 +18,8 @@ setup_upstream_and_workbench () {
test_expect_success "setup upstream and workbench" '
rm -rf upstream.git &&
rm -rf workbench &&
- git init --bare upstream.git &&
- git init workbench &&
+ test_create_repo --bare upstream.git &&
+ test_create_repo workbench &&
create_commits_in workbench A B &&
(
cd workbench &&
diff --git a/t/t5548-push-porcelain.sh b/t/t5548-push-porcelain.sh
index 5a761f3642..8725b00a68 100755
--- a/t/t5548-push-porcelain.sh
+++ b/t/t5548-push-porcelain.sh
@@ -4,6 +4,9 @@
#
test_description='Test git push porcelain output'
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
. ./test-lib.sh
# Create commits in <repo> and assign each commit's oid to shell variables
@@ -61,8 +64,8 @@ setup_upstream_and_workbench () {
# Workbench after setup : main(A)
test_expect_success "setup upstream repository and workbench" '
rm -rf upstream.git workbench &&
- git init --bare upstream.git &&
- git init workbench &&
+ test_create_repo --bare upstream.git &&
+ test_create_repo workbench &&
create_commits_in workbench A B &&
(
cd workbench &&
diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh
index 881f72fd44..4ad98a3385 100755
--- a/t/t6020-bundle-misc.sh
+++ b/t/t6020-bundle-misc.sh
@@ -315,7 +315,7 @@ test_expect_success 'create bundle 2 - has prerequisites' '
'
test_expect_success 'fail to verify bundle without prerequisites' '
- git init --bare test1.git &&
+ test_create_repo --bare test1.git &&
cat >expect <<-\EOF &&
error: Repository lacks these prerequisite commits:
--
2.32.0.rc0.27.g7b1e85181b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] test-lib-functions: test_create_repo learns --bare
2021-06-17 12:43 [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Jiang Xin
2021-06-17 12:43 ` [PATCH 2/2] test: create repo using test_create_repo Jiang Xin
@ 2021-06-22 16:48 ` Ævar Arnfjörð Bjarmason
2021-06-23 0:53 ` Jiang Xin
1 sibling, 1 reply; 4+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-22 16:48 UTC (permalink / raw)
To: Jiang Xin; +Cc: Junio C Hamano, Git List, Jiang Xin
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] test-lib-functions: test_create_repo learns --bare
2021-06-22 16:48 ` [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Ævar Arnfjörð Bjarmason
@ 2021-06-23 0:53 ` Jiang Xin
0 siblings, 0 replies; 4+ messages in thread
From: Jiang Xin @ 2021-06-23 0:53 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason
Cc: Junio C Hamano, Git List, Jiang Xin
Æ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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-23 0:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 12:43 [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Jiang Xin
2021-06-17 12:43 ` [PATCH 2/2] test: create repo using test_create_repo Jiang Xin
2021-06-22 16:48 ` [PATCH 1/2] test-lib-functions: test_create_repo learns --bare Ævar Arnfjörð Bjarmason
2021-06-23 0:53 ` Jiang Xin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).