{"thread":{"id":"58860","subject":"[PATCH v1 1/4] t1301: fix wrong template dir for git-init","startedAt":"2022-11-27T14:51:40Z","lastAt":"2022-11-29T13:16:11Z","messageCount":24,"participants":["Jiang Xin","Junio C Hamano","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"468044","messageId":"20221127145130.16155-1-worldhello.net@gmail.com","threadId":"58860","inReplyTo":null,"subject":"[PATCH v1 1/4] t1301: fix wrong template dir for git-init","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-27T14:51:27Z","receivedAt":"2022-11-27T14:51:40Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nThe template dir parepared in test case \"forced modes\" is not used as\nexpected because a wrong template dir is provided to \"git init\". This is\nbecause the $CWD for \"git-init\" command is a sibling directory alongside\nthe template directory. Change it to the right template directory and\nadd a protection test using \"test_path_is_file\".\n\nThe wrong template directory was introduced by mistake in commit\ne1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 93a2f91f8a..7578e75d77 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n \t(\n \t\tcd new &&\n \t\tumask 002 &&\n-\t\tgit init --shared=0660 --template=templates &&\n+\t\tgit init --shared=0660 --template=../templates &&\n+\t\ttest_path_is_file .git/hooks/post-update &&\n \t\t>frotz &&\n \t\tgit add frotz &&\n \t\tgit commit -a -m initial &&\n-- \n2.39.0.rc0\n\n"},{"id":"468045","messageId":"20221127145130.16155-2-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v1 2/4] t1301: use test_when_finished for cleanup","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-27T14:51:28Z","receivedAt":"2022-11-27T14:51:49Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 7578e75d77..1225abbb6d 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -25,6 +25,7 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '\n for u in 002 022\n do\n \ttest_expect_success POSIXPERM \"shared=1 does not clear bits preset by umask $u\" '\n+\t\ttest_when_finished \"rm -rf sub\" &&\n \t\tmkdir sub && (\n \t\t\tcd sub &&\n \t\t\tumask $u &&\n@@ -42,7 +43,6 @@ do\n \t\t\t;;\n \t\tesac\n \t'\n-\trm -rf sub\n done\n \n test_expect_success 'shared=all' '\n@@ -132,6 +132,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n '\n \n test_expect_success POSIXPERM 'forced modes' '\n+\ttest_when_finished \"rm -rf new\" &&\n \tmkdir -p templates/hooks &&\n \techo update-server-info >templates/hooks/post-update &&\n \tchmod +x templates/hooks/post-update &&\n@@ -174,6 +175,7 @@ test_expect_success POSIXPERM 'forced modes' '\n '\n \n test_expect_success POSIXPERM 'remote init does not use config from cwd' '\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tgit config core.sharedrepository 0666 &&\n \tumask 0022 &&\n \tgit init --bare child.git &&\n@@ -193,7 +195,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '\n '\n \n test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit init --bare --shared=0666 child.git &&\n \ttest_path_is_missing child.git/foo &&\n@@ -204,7 +206,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'\n '\n \n test_expect_success POSIXPERM 'template can set core.sharedrepository' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit config core.sharedrepository 0666 &&\n \tcp .git/config templates/config &&\n-- \n2.39.0.rc0\n\n"},{"id":"468046","messageId":"20221127145130.16155-3-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v1 3/4] t1301: wrap the statements in the for loop","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-27T14:51:29Z","receivedAt":"2022-11-27T14:51:55Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nWrap the statements which were introduced in commit 06cbe85503 (Make\ncore.sharedRepository more generic, 2008-04-16)) in the for loop in a\nnew test case, so if we want to skip some of the test cases, these\nunwrapped statements won't affect the test cases we choose to run.\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 19 ++++++++-----------\n 1 file changed, 8 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 1225abbb6d..3ca91bf504 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -78,31 +78,28 @@ for u in\t0660:rw-rw---- \\\n \t\t0666:rw-rw-rw- \\\n \t\t0664:rw-rw-r--\n do\n-\tx=$(expr \"$u\" : \".*:\\([rw-]*\\)\") &&\n-\ty=$(echo \"$x\" | sed -e \"s/w/-/g\") &&\n-\tu=$(expr \"$u\" : \"\\([0-7]*\\)\") &&\n-\tgit config core.sharedrepository \"$u\" &&\n-\tumask 0277 &&\n+\ttest_expect_success POSIXPERM \"set variables from $u\" '\n+\t\tx=$(expr \"$u\" : \".*:\\([rw-]*\\)\") &&\n+\t\ty=$(echo \"$x\" | sed -e \"s/w/-/g\") &&\n+\t\tu=$(expr \"$u\" : \"\\([0-7]*\\)\") &&\n+\t\tgit config core.sharedrepository \"$u\"\n+\t'\n \n \ttest_expect_success POSIXPERM \"shared = $u ($y) ro\" '\n-\n+\t\tumask 0277 &&\n \t\trm -f .git/info/refs &&\n \t\tgit update-server-info &&\n \t\tactual=\"$(test_modebits .git/info/refs)\" &&\n \t\tverbose test \"x$actual\" = \"x-$y\"\n-\n \t'\n \n-\tumask 077 &&\n \ttest_expect_success POSIXPERM \"shared = $u ($x) rw\" '\n-\n+\t\tumask 077 &&\n \t\trm -f .git/info/refs &&\n \t\tgit update-server-info &&\n \t\tactual=\"$(test_modebits .git/info/refs)\" &&\n \t\tverbose test \"x$actual\" = \"x-$x\"\n-\n \t'\n-\n done\n \n test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '\n-- \n2.39.0.rc0\n\n"},{"id":"468047","messageId":"20221127145130.16155-4-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v1 4/4] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-27T14:51:30Z","receivedAt":"2022-11-27T14:51:56Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nIn test case \"shared=all\", the working directory is permanently changed\nto the \"sub\" directory. This leads to a strange behavior that the\ntemporary repositories created by subsequent test cases are all in this\n\"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\ntest case, all subsequent test cases will have different working\ndirectory.\n\nSince the test case \"shared=all\" and all subsequent will work properly\nin the default test repository, we don't need to create and change to\nthe \"sub\" directory in the test case \"shared=all\".\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 2 --\n 1 file changed, 2 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 3ca91bf504..c4f2f72f6b 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -46,8 +46,6 @@ do\n done\n \n test_expect_success 'shared=all' '\n-\tmkdir sub &&\n-\tcd sub &&\n \tgit init --template= --shared=all &&\n \ttest 2 = $(git config core.sharedrepository)\n '\n-- \n2.39.0.rc0\n\n"},{"id":"468056","messageId":"xmqq8rjv90rr.fsf@gitster.g","threadId":"58860","inReplyTo":"20221127145130.16155-2-worldhello.net@gmail.com","subject":"Re: [PATCH v1 2/4] t1301: use test_when_finished for cleanup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-11-28T04:11:04Z","receivedAt":"2022-11-28T04:11:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>\n> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> ---\n>  t/t1301-shared-repo.sh | 8 +++++---\n>  1 file changed, 5 insertions(+), 3 deletions(-)\n>\n> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> index 7578e75d77..1225abbb6d 100755\n> --- a/t/t1301-shared-repo.sh\n> +++ b/t/t1301-shared-repo.sh\n> @@ -25,6 +25,7 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '\n>  for u in 002 022\n>  do\n>  \ttest_expect_success POSIXPERM \"shared=1 does not clear bits preset by umask $u\" '\n> +\t\ttest_when_finished \"rm -rf sub\" &&\n>  \t\tmkdir sub && (\n>  \t\t\tcd sub &&\n>  \t\t\tumask $u &&\n> @@ -42,7 +43,6 @@ do\n>  \t\t\t;;\n>  \t\tesac\n>  \t'\n> -\trm -rf sub\n>  done\n\nThis is indeed \"we used to clean-up outside the test, but instead\nlet's use test_when_finished for that\".\n\n\n> @@ -132,6 +132,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n>  '\n>  \n>  test_expect_success POSIXPERM 'forced modes' '\n> +\ttest_when_finished \"rm -rf new\" &&\n>  \tmkdir -p templates/hooks &&\n>  \techo update-server-info >templates/hooks/post-update &&\n>  \tchmod +x templates/hooks/post-update &&\n\nBut strictly speaking this is different.  We used to leave \"new\"\nafter we are done, now we do clean up.  Which is definitely an\nimprovement in any way ;-)\n\n> @@ -174,6 +175,7 @@ test_expect_success POSIXPERM 'forced modes' '\n>  '\n>  \n>  test_expect_success POSIXPERM 'remote init does not use config from cwd' '\n> +\ttest_when_finished \"rm -rf child.git\" &&\n>  \tgit config core.sharedrepository 0666 &&\n>  \tumask 0022 &&\n>  \tgit init --bare child.git &&\n> @@ -193,7 +195,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '\n>  '\n>  \n>  test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)' '\n> -\trm -rf child.git &&\n> +\ttest_when_finished \"rm -rf child.git\" &&\n>  \tumask 0022 &&\n>  \tgit init --bare --shared=0666 child.git &&\n>  \ttest_path_is_missing child.git/foo &&\n> @@ -204,7 +206,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'\n>  '\n>  \n>  test_expect_success POSIXPERM 'template can set core.sharedrepository' '\n> -\trm -rf child.git &&\n> +\ttest_when_finished \"rm -rf child.git\" &&\n>  \tumask 0022 &&\n>  \tgit config core.sharedrepository 0666 &&\n>  \tcp .git/config templates/config &&\n\nThese child.git test repositories used to follow \"initialize what we\nare going to use to a known state before we use\" pattern, which is\nnot wrong per-se, but now we use \"clean up the cruft we make after\nwe are done\" pattern, which may arguably be better, simply because\nthe test that makes cruft should know what cruft it created better\nthan whatever comes later that may not know.\n\nOK.\n"},{"id":"468057","messageId":"xmqq35a390ek.fsf@gitster.g","threadId":"58860","inReplyTo":"20221127145130.16155-3-worldhello.net@gmail.com","subject":"Re: [PATCH v1 3/4] t1301: wrap the statements in the for loop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-11-28T04:18:59Z","receivedAt":"2022-11-28T04:21:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> Subject: Re: [PATCH v1 3/4] t1301: wrap the statements in the for loop\n\nThat makes it sound as if there weren't a loop and now you wrapped\nthe statement in a loop, but that is not what is happening.  You are\nwrapping the statements in something you are not telling us, and \"in\nthe for loop\" is there only to explain where the statements in\nquestion are found.\n\n\tt1301: wrap code to prepare configuration in a separate test\n\nor something?\n\n> Wrap the statements which were introduced in commit 06cbe85503 (Make\n> core.sharedRepository more generic, 2008-04-16)) in the for loop in a\n> new test case, so if we want to skip some of the test cases, these\n> unwrapped statements won't affect the test cases we choose to run.\n\nI am not quite sure why this change is needed for the above, though.\nIf we want to skip u=0660:rw-rw---- test, we can skip the two\ntest_expect_success for the first iteration, which will still run\n\"git config core.sharedrepository\" for the first case, and when we\ntest for the next one (i.e. u=0640:rw-r-----), we will overwrite the\nconfiguration with the value appropriate for the round.\n\nNow you have three separate tests in an interation of the loop.  If\nyou skipped the first one in the iteration (by mistake) and let the\nother two run, they will run with a wrong configuration and values\nof $x and $y variables, either unset or leftover from the previous\nround.\n\nSo I am not sure how this patch can be an improvement.\n\nIf you wrapped the setting of $x, $y, $u and the config into a\nhelper shell function, e.g.\n\n\tprepare_perm_test_variables () {\n\t\tu=$1\n\t\tx=...\n\t\ty=...\n\t\tu=...\n\t\tgit config core.sharedrepository \"$u\"\n\t}\n\nbefore and outside the loop, and make these two tests in the loop to\ncall it upfront, then your users can skip each test and iteration\nindependently while ensuring that the necessary setup is always done\ncorrectly, though.\n\n>\n> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> ---\n>  t/t1301-shared-repo.sh | 19 ++++++++-----------\n>  1 file changed, 8 insertions(+), 11 deletions(-)\n>\n> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> index 1225abbb6d..3ca91bf504 100755\n> --- a/t/t1301-shared-repo.sh\n> +++ b/t/t1301-shared-repo.sh\n> @@ -78,31 +78,28 @@ for u in\t0660:rw-rw---- \\\n>  \t\t0666:rw-rw-rw- \\\n>  \t\t0664:rw-rw-r--\n>  do\n> -\tx=$(expr \"$u\" : \".*:\\([rw-]*\\)\") &&\n> -\ty=$(echo \"$x\" | sed -e \"s/w/-/g\") &&\n> -\tu=$(expr \"$u\" : \"\\([0-7]*\\)\") &&\n> -\tgit config core.sharedrepository \"$u\" &&\n> -\tumask 0277 &&\n> +\ttest_expect_success POSIXPERM \"set variables from $u\" '\n> +\t\tx=$(expr \"$u\" : \".*:\\([rw-]*\\)\") &&\n> +\t\ty=$(echo \"$x\" | sed -e \"s/w/-/g\") &&\n> +\t\tu=$(expr \"$u\" : \"\\([0-7]*\\)\") &&\n> +\t\tgit config core.sharedrepository \"$u\"\n> +\t'\n>  \n>  \ttest_expect_success POSIXPERM \"shared = $u ($y) ro\" '\n> -\n> +\t\tumask 0277 &&\n>  \t\trm -f .git/info/refs &&\n>  \t\tgit update-server-info &&\n>  \t\tactual=\"$(test_modebits .git/info/refs)\" &&\n>  \t\tverbose test \"x$actual\" = \"x-$y\"\n> -\n>  \t'\n>  \n> -\tumask 077 &&\n>  \ttest_expect_success POSIXPERM \"shared = $u ($x) rw\" '\n> -\n> +\t\tumask 077 &&\n>  \t\trm -f .git/info/refs &&\n>  \t\tgit update-server-info &&\n>  \t\tactual=\"$(test_modebits .git/info/refs)\" &&\n>  \t\tverbose test \"x$actual\" = \"x-$x\"\n> -\n>  \t'\n> -\n>  done\n>  \n>  test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '\n"},{"id":"468058","messageId":"xmqqwn7f7ktb.fsf@gitster.g","threadId":"58860","inReplyTo":"20221127145130.16155-4-worldhello.net@gmail.com","subject":"Re: [PATCH v1 4/4] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-11-28T04:41:04Z","receivedAt":"2022-11-28T04:41:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>\n> In test case \"shared=all\", the working directory is permanently changed\n> to the \"sub\" directory. This leads to a strange behavior that the\n> temporary repositories created by subsequent test cases are all in this\n> \"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\n> test case, all subsequent test cases will have different working\n> directory.\n>\n> Since the test case \"shared=all\" and all subsequent will work properly\n> in the default test repository, we don't need to create and change to\n> the \"sub\" directory in the test case \"shared=all\".\n\nIt is much worse than that.  If existing tests after this step were\nrunning destructive operations in their \"..\", because we have this\nextra \"sub\" directory and such a destructive test were running\nthere, the damage would have been contained in $TRASH_DIRECTORY but\nwith this change, it will touch t/ (or the parent directory of the\n$TRASH_DIRECTORY).  So, \"will work properly\" may not be sufficient;\nwe need to audit the rest of the script and make sure there is no\nsuch funny \"step outside the test enviromnent\" happening before we\nare sure that this is a \"safe\" change.\n\nIt is the \"right\" thing to do, though.  I do not see any reason why\nwe want to have an extra level \"sub\" directory there.\n\n\n\n\n>\n> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> ---\n>  t/t1301-shared-repo.sh | 2 --\n>  1 file changed, 2 deletions(-)\n>\n> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> index 3ca91bf504..c4f2f72f6b 100755\n> --- a/t/t1301-shared-repo.sh\n> +++ b/t/t1301-shared-repo.sh\n> @@ -46,8 +46,6 @@ do\n>  done\n>  \n>  test_expect_success 'shared=all' '\n> -\tmkdir sub &&\n> -\tcd sub &&\n>  \tgit init --template= --shared=all &&\n>  \ttest 2 = $(git config core.sharedrepository)\n>  '\n"},{"id":"468067","messageId":"CANYiYbGwHQiDh7qf-LTtuUM7eC3AEpkuXoejOBkJs-VGZTA14A@mail.gmail.com","threadId":"58860","inReplyTo":"xmqq35a390ek.fsf@gitster.g","subject":"Re: [PATCH v1 3/4] t1301: wrap the statements in the for loop","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T09:43:49Z","receivedAt":"2022-11-28T09:44:03Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"On Mon, Nov 28, 2022 at 12:19 PM Junio C Hamano <gitster@pobox.com> wrote:\n> Now you have three separate tests in an interation of the loop.  If\n> you skipped the first one in the iteration (by mistake) and let the\n> other two run, they will run with a wrong configuration and values\n> of $x and $y variables, either unset or leftover from the previous\n> round.\n>\n> So I am not sure how this patch can be an improvement.\n\nI agree that this patch is not that necessary as the other 3 patches\nand will remove it in next reroll.\n\n>\n> If you wrapped the setting of $x, $y, $u and the config into a\n> helper shell function, e.g.\n>\n>         prepare_perm_test_variables () {\n>                 u=$1\n>                 x=...\n>                 y=...\n>                 u=...\n>                 git config core.sharedrepository \"$u\"\n>         }\n>\n> before and outside the loop, and make these two tests in the loop to\n> call it upfront, then your users can skip each test and iteration\n> independently while ensuring that the necessary setup is always done\n> correctly, though.\n>\n"},{"id":"468068","messageId":"CANYiYbHtC57e4PpsxKRcfU9QVwjiy=__AnfgsUMzBeJr7LYaTw@mail.gmail.com","threadId":"58860","inReplyTo":"xmqqwn7f7ktb.fsf@gitster.g","subject":"Re: [PATCH v1 4/4] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T09:46:37Z","receivedAt":"2022-11-28T09:46:51Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"On Mon, Nov 28, 2022 at 12:41 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jiang Xin <worldhello.net@gmail.com> writes:\n>\n> > From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> >\n> > In test case \"shared=all\", the working directory is permanently changed\n> > to the \"sub\" directory. This leads to a strange behavior that the\n> > temporary repositories created by subsequent test cases are all in this\n> > \"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\n> > test case, all subsequent test cases will have different working\n> > directory.\n> >\n> > Since the test case \"shared=all\" and all subsequent will work properly\n> > in the default test repository, we don't need to create and change to\n> > the \"sub\" directory in the test case \"shared=all\".\n>\n> It is much worse than that.  If existing tests after this step were\n> running destructive operations in their \"..\", because we have this\n> extra \"sub\" directory and such a destructive test were running\n> there, the damage would have been contained in $TRASH_DIRECTORY but\n> with this change, it will touch t/ (or the parent directory of the\n> $TRASH_DIRECTORY).  So, \"will work properly\" may not be sufficient;\n> we need to audit the rest of the script and make sure there is no\n> such funny \"step outside the test enviromnent\" happening before we\n> are sure that this is a \"safe\" change.\n\nNo such funny operations in the follow test cases, but will add some\nnotes in commit log.\n\nThanks.\n\n--\nJiang Xin\n\n>\n> It is the \"right\" thing to do, though.  I do not see any reason why\n> we want to have an extra level \"sub\" directory there.\n"},{"id":"468075","messageId":"CANYiYbEpuPk==QZLAzn0vy_FTr-_8KVnT9zB0as2WZHg2=L2Kw@mail.gmail.com","threadId":"58860","inReplyTo":"xmqq35a390ek.fsf@gitster.g","subject":"Re: [PATCH v1 3/4] t1301: wrap the statements in the for loop","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T11:56:56Z","receivedAt":"2022-11-28T11:57:15Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"On Mon, Nov 28, 2022 at 12:19 PM Junio C Hamano <gitster@pobox.com> wrote:\n> So I am not sure how this patch can be an improvement.\n>\n> If you wrapped the setting of $x, $y, $u and the config into a\n> helper shell function, e.g.\n>\n>         prepare_perm_test_variables () {\n>                 u=$1\n>                 x=...\n>                 y=...\n>                 u=...\n>                 git config core.sharedrepository \"$u\"\n>         }\n\nI tried, but found the first test case passed, but the other test case\nin the for loop failed. This is because the variable u is changed\ntwice after prepare_perm_test_variables has been called twice.\n\nSo, will drop this patch 3/4.\n\n--\nJiang Xin\n"},{"id":"468083","messageId":"20221128130323.8914-2-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v2 1/3] t1301: fix wrong template dir for git-init","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T13:03:21Z","receivedAt":"2022-11-28T13:03:31Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nThe template dir prepared in test case \"forced modes\" is not used as\nexpected because a wrong template dir is provided to \"git init\". This is\nbecause the $CWD for \"git-init\" command is a sibling directory alongside\nthe template directory. Change it to the right template directory and\nadd a protection test using \"test_path_is_file\".\n\nThe wrong template directory was introduced by mistake in commit\ne1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 93a2f91f8a..7578e75d77 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n \t(\n \t\tcd new &&\n \t\tumask 002 &&\n-\t\tgit init --shared=0660 --template=templates &&\n+\t\tgit init --shared=0660 --template=../templates &&\n+\t\ttest_path_is_file .git/hooks/post-update &&\n \t\t>frotz &&\n \t\tgit add frotz &&\n \t\tgit commit -a -m initial &&\n-- \n2.39.0.rc0\n\n"},{"id":"468084","messageId":"20221128130323.8914-3-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v2 2/3] t1301: use test_when_finished for cleanup","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T13:03:22Z","receivedAt":"2022-11-28T13:03:35Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nRefactor several test cases to use \"test_when_finished\" for cleanup.\n\n1. For first of these, we used to clean-up outside the test, but instead\n   let's use test_when_finished for that.\n\n2. For the second, we used to leave \"new\" after we are done, but not use\n   it at all later. Now we do clean up.\n\n3. For the rest, these child.git test repositories used to follow\n   \"initialize what we are going to use to a known state before we use\"\n   pattern, which is not wrong per-se, but now we use \"clean up the\n   cruft we made after we are done\" pattern, which may arguably be\n   better simply because the test that makes cruft should know what\n   cruft it created better than whatever comes later that may not know.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 7578e75d77..1225abbb6d 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -25,6 +25,7 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '\n for u in 002 022\n do\n \ttest_expect_success POSIXPERM \"shared=1 does not clear bits preset by umask $u\" '\n+\t\ttest_when_finished \"rm -rf sub\" &&\n \t\tmkdir sub && (\n \t\t\tcd sub &&\n \t\t\tumask $u &&\n@@ -42,7 +43,6 @@ do\n \t\t\t;;\n \t\tesac\n \t'\n-\trm -rf sub\n done\n \n test_expect_success 'shared=all' '\n@@ -132,6 +132,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n '\n \n test_expect_success POSIXPERM 'forced modes' '\n+\ttest_when_finished \"rm -rf new\" &&\n \tmkdir -p templates/hooks &&\n \techo update-server-info >templates/hooks/post-update &&\n \tchmod +x templates/hooks/post-update &&\n@@ -174,6 +175,7 @@ test_expect_success POSIXPERM 'forced modes' '\n '\n \n test_expect_success POSIXPERM 'remote init does not use config from cwd' '\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tgit config core.sharedrepository 0666 &&\n \tumask 0022 &&\n \tgit init --bare child.git &&\n@@ -193,7 +195,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '\n '\n \n test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit init --bare --shared=0666 child.git &&\n \ttest_path_is_missing child.git/foo &&\n@@ -204,7 +206,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'\n '\n \n test_expect_success POSIXPERM 'template can set core.sharedrepository' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit config core.sharedrepository 0666 &&\n \tcp .git/config templates/config &&\n-- \n2.39.0.rc0\n\n"},{"id":"468085","messageId":"20221128130323.8914-4-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v2 3/3] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T13:03:23Z","receivedAt":"2022-11-28T13:03:37Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nIn test case \"shared=all\", the working directory is permanently changed\nto the \"sub\" directory. This leads to a strange behavior that the\ntemporary repositories created by subsequent test cases are all in this\n\"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\ntest case, all subsequent test cases will have different working\ndirectory.\n\nBesides, all subsequent test cases assuming they are in the \"sub\"\ndirectory do not run any destructive operations in their parent\ndirectory (\"..\"), and will not make damage out side of $TRASH_DIRECTORY.\n\nSo it is a safe change for us to run the test case \"shared=all\" in\ncurrent repository instead of creating and changing to \"sub\".\n\nFor the next test case, we no longer run it in the \"sub\" repository\nwhich is initialized from an empty template, we should not assume the\npath \".git/info\" is missing. So add option \"-p\" to mkdir.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 1225abbb6d..fd10c139f5 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -46,8 +46,6 @@ do\n done\n \n test_expect_success 'shared=all' '\n-\tmkdir sub &&\n-\tcd sub &&\n \tgit init --template= --shared=all &&\n \ttest 2 = $(git config core.sharedrepository)\n '\n@@ -57,7 +55,7 @@ test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n \tgit add a1 &&\n \ttest_tick &&\n \tgit commit -m a1 &&\n-\tmkdir .git/info &&\n+\tmkdir -p .git/info &&\n \tumask 0277 &&\n \tgit update-server-info &&\n \tactual=\"$(ls -l .git/info/refs)\" &&\n-- \n2.39.0.rc0\n\n"},{"id":"468086","messageId":"20221128130323.8914-1-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221127145130.16155-1-worldhello.net@gmail.com","subject":"[PATCH v2 0/3] t1301: various updates","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T13:03:20Z","receivedAt":"2022-11-28T13:03:52Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\n## Changes since v1\n\nThe first version is based on the \"master\" branch, and this v2\nrevsion is based on the \"maint\" branch. Because only master\nbranch has the commit 93e02b6e1e (tests: don't assume a .git/info\nfor .git/info/grafts, 2022-06-03), we need add a \"-p\" option for\nmkdir in patch 3/3.\n\nIt's very interesting. Just because the \"mkdir .git/info\" changes\nin the above commit conflicts with our internal reference-transaction\nhook which will automatically create a \".git/info\" directory to\ncreate some files inside, I found the wrong template issue in t1301\nwhich is fixed in patch 1/3.\n\nOther changes see the following range-diff.\n\n\n## Range-diff v1...v2\n\n1:  876709e3c8 ! 1:  bc68ffb41c t1301: fix wrong template dir for git-init\n    @@ Metadata\n      ## Commit message ##\n         t1301: fix wrong template dir for git-init\n     \n    -    The template dir parepared in test case \"forced modes\" is not used as\n    +    The template dir prepared in test case \"forced modes\" is not used as\n         expected because a wrong template dir is provided to \"git init\". This is\n         because the $CWD for \"git-init\" command is a sibling directory alongside\n         the template directory. Change it to the right template directory and\n2:  515f6a5619 ! 2:  ae2b2f8afc t1301: use test_when_finished for cleanup\n    @@ Metadata\n      ## Commit message ##\n         t1301: use test_when_finished for cleanup\n     \n    +    Refactor several test cases to use \"test_when_finished\" for cleanup.\n    +\n    +    1. For first of these, we used to clean-up outside the test, but instead\n    +       let's use test_when_finished for that.\n    +\n    +    2. For the second, we used to leave \"new\" after we are done, but not use\n    +       it at all later. Now we do clean up.\n    +\n    +    3. For the rest, these child.git test repositories used to follow\n    +       \"initialize what we are going to use to a known state before we use\"\n    +       pattern, which is not wrong per-se, but now we use \"clean up the\n    +       cruft we made after we are done\" pattern, which may arguably be\n    +       better simply because the test that makes cruft should know what\n    +       cruft it created better than whatever comes later that may not know.\n    +\n    +    Helped-by: Junio C Hamano <gitster@pobox.com>\n         Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n     \n      ## t/t1301-shared-repo.sh ##\n3:  17a318c30d < -:  ---------- t1301: wrap the statements in the for loop\n4:  4738ad6f8b ! 3:  f1bf255e5a t1301: do not change $CWD in \"shared=all\" test case\n    @@ Commit message\n         test case, all subsequent test cases will have different working\n         directory.\n     \n    -    Since the test case \"shared=all\" and all subsequent will work properly\n    -    in the default test repository, we don't need to create and change to\n    -    the \"sub\" directory in the test case \"shared=all\".\n    +    Besides, all subsequent test cases assuming they are in the \"sub\"\n    +    directory do not run any destructive operations in their parent\n    +    directory (\"..\"), and will not make damage out side of $TRASH_DIRECTORY.\n     \n    +    So it is a safe change for us to run the test case \"shared=all\" in\n    +    current repository instead of creating and changing to \"sub\".\n    +\n    +    For the next test case, we no longer run it in the \"sub\" repository\n    +    which is initialized from an empty template, we should not assume the\n    +    path \".git/info\" is missing. So add option \"-p\" to mkdir.\n    +\n    +    Helped-by: Junio C Hamano <gitster@pobox.com>\n         Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n     \n      ## t/t1301-shared-repo.sh ##\n    @@ t/t1301-shared-repo.sh: do\n      \tgit init --template= --shared=all &&\n      \ttest 2 = $(git config core.sharedrepository)\n      '\n    +@@ t/t1301-shared-repo.sh: test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n    + \tgit add a1 &&\n    + \ttest_tick &&\n    + \tgit commit -m a1 &&\n    +-\tmkdir .git/info &&\n    ++\tmkdir -p .git/info &&\n    + \tumask 0277 &&\n    + \tgit update-server-info &&\n    + \tactual=\"$(ls -l .git/info/refs)\" &&\n\n--\n\nJiang Xin (3):\n  t1301: fix wrong template dir for git-init\n  t1301: use test_when_finished for cleanup\n  t1301: do not change $CWD in \"shared=all\" test case\n\n t/t1301-shared-repo.sh | 15 ++++++++-------\n 1 file changed, 8 insertions(+), 7 deletions(-)\n\n-- \n2.39.0.rc0\n\n\n"},{"id":"468090","messageId":"221128.86ilizkybr.gmgdl@evledraar.gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-4-worldhello.net@gmail.com","subject":"Re: [PATCH v2 3/3] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-11-28T13:18:45Z","receivedAt":"2022-11-28T13:23:10Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Nov 28 2022, Jiang Xin wrote:\n\n> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>\n> In test case \"shared=all\", the working directory is permanently changed\n> to the \"sub\" directory. This leads to a strange behavior that the\n> temporary repositories created by subsequent test cases are all in this\n> \"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\n> test case, all subsequent test cases will have different working\n> directory.\n>\n> Besides, all subsequent test cases assuming they are in the \"sub\"\n> directory do not run any destructive operations in their parent\n> directory (\"..\"), and will not make damage out side of $TRASH_DIRECTORY.\n>\n> So it is a safe change for us to run the test case \"shared=all\" in\n> current repository instead of creating and changing to \"sub\".\n>\n> For the next test case, we no longer run it in the \"sub\" repository\n> which is initialized from an empty template, we should not assume the\n> path \".git/info\" is missing. So add option \"-p\" to mkdir.\n>\n> Helped-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> ---\n>  t/t1301-shared-repo.sh | 4 +---\n>  1 file changed, 1 insertion(+), 3 deletions(-)\n>\n> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> index 1225abbb6d..fd10c139f5 100755\n> --- a/t/t1301-shared-repo.sh\n> +++ b/t/t1301-shared-repo.sh\n> @@ -46,8 +46,6 @@ do\n>  done\n>  \n>  test_expect_success 'shared=all' '\n> -\tmkdir sub &&\n> -\tcd sub &&\n>  \tgit init --template= --shared=all &&\n>  \ttest 2 = $(git config core.sharedrepository)\n>  '\n> @@ -57,7 +55,7 @@ test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n>  \tgit add a1 &&\n>  \ttest_tick &&\n>  \tgit commit -m a1 &&\n> -\tmkdir .git/info &&\n> +\tmkdir -p .git/info &&\n>  \tumask 0277 &&\n>  \tgit update-server-info &&\n>  \tactual=\"$(ls -l .git/info/refs)\" &&\n\nI think this approach goes against the effort to implicitly stop relying\non templates. See 3d3874d537a (Merge branch 'ab/test-without-templates',\n2022-07-18) for commits related to that.\n\nI think better thing to do here is to squash this in:\n\t\n\tdiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n\tindex 0b3722aa149..b7222b7bc07 100755\n\t--- a/t/t1301-shared-repo.sh\n\t+++ b/t/t1301-shared-repo.sh\n\t@@ -8,6 +8,7 @@ test_description='Test shared repository initialization'\n\t GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n\t export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n\t \n\t+TEST_CREATE_REPO_NO_TEMPLATE=1\n\t . ./test-lib.sh\n\t \n\t # Remove a default ACL from the test dir if possible.\n\t@@ -55,7 +56,7 @@ test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n\t \tgit add a1 &&\n\t \ttest_tick &&\n\t \tgit commit -m a1 &&\n\t-\tmkdir -p .git/info &&\n\t+\tmkdir .git/info &&\n\t \tumask 0277 &&\n\t \tgit update-server-info &&\n\t \tactual=\"$(ls -l .git/info/refs)\" &&\n\nI.e. before we'd not reply on the template, as we created a directory\nmanually, but now we're using the standard templated \"git init\", so\nAFAICT the first hunk here could be taken, and this could be squashed\ninto the second hunk instead:\n\n\tdiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n\tindex 0b3722aa149..d4315b5ef5a 100755\n\t--- a/t/t1301-shared-repo.sh\n\t+++ b/t/t1301-shared-repo.sh\n\t@@ -55,7 +55,6 @@ test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n\t \tgit add a1 &&\n\t \ttest_tick &&\n\t \tgit commit -m a1 &&\n\t-\tmkdir -p .git/info &&\n\t \tumask 0277 &&\n\t \tgit update-server-info &&\n\t \tactual=\"$(ls -l .git/info/refs)\" &&\n\nI.e. before your change we went from knowing that we're crafting a\ncustom repo, to saying that we're unsure what we're doing by using the\n\"mkdir -p\".\n\nBut can't we just use \"TEST_CREATE_REPO_NO_TEMPLATE=1\" then, and avoid\nthe \"cd sub?\"\n"},{"id":"468091","messageId":"221128.86edtnky39.gmgdl@evledraar.gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-2-worldhello.net@gmail.com","subject":"Re: [PATCH v2 1/3] t1301: fix wrong template dir for git-init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-11-28T13:24:33Z","receivedAt":"2022-11-28T13:28:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Nov 28 2022, Jiang Xin wrote:\n\n> From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>\n> The template dir prepared in test case \"forced modes\" is not used as\n> expected because a wrong template dir is provided to \"git init\". This is\n> because the $CWD for \"git-init\" command is a sibling directory alongside\n> the template directory. Change it to the right template directory and\n> add a protection test using \"test_path_is_file\".\n>\n> The wrong template directory was introduced by mistake in commit\n> e1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n>\n> Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> ---\n>  t/t1301-shared-repo.sh | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> index 93a2f91f8a..7578e75d77 100755\n> --- a/t/t1301-shared-repo.sh\n> +++ b/t/t1301-shared-repo.sh\n> @@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n>  \t(\n>  \t\tcd new &&\n>  \t\tumask 002 &&\n> -\t\tgit init --shared=0660 --template=templates &&\n> +\t\tgit init --shared=0660 --template=../templates &&\n> +\t\ttest_path_is_file .git/hooks/post-update &&\n>  \t\t>frotz &&\n>  \t\tgit add frotz &&\n>  \t\tgit commit -a -m initial &&\n\nThis fix looks fishy to me. The code you're changing looks like it was\nbuggy, but this looks like it's sweeping under the rug the fact that\n\"templates\" never did anything at this point.\n\nSo I'm not saying you should squash this in, but if you do so you'll see\nthat we only ever used this later.\n\t\n\tdiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n\tindex d4315b5ef5a..106ccc5704e 100755\n\t--- a/t/t1301-shared-repo.sh\n\t+++ b/t/t1301-shared-repo.sh\n\t@@ -129,15 +129,12 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n\t '\n\t \n\t test_expect_success POSIXPERM 'forced modes' '\n\t-\tmkdir -p templates/hooks &&\n\t-\techo update-server-info >templates/hooks/post-update &&\n\t-\tchmod +x templates/hooks/post-update &&\n\t \techo : >random-file &&\n\t \tmkdir new &&\n\t \t(\n\t \t\tcd new &&\n\t \t\tumask 002 &&\n\t-\t\tgit init --shared=0660 --template=templates &&\n\t+\t\tgit init --shared=0660 &&\n\t \t\t>frotz &&\n\t \t\tgit add frotz &&\n\t \t\tgit commit -a -m initial &&\n\t@@ -181,6 +178,10 @@ test_expect_success POSIXPERM 'remote init does not use config from cwd' '\n\t test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '\n\t \tgit config core.sharedrepository 0666 &&\n\t \tumask 0022 &&\n\t+\tmkdir -p templates/hooks &&\n\t+\techo update-server-info >templates/hooks/post-update &&\n\t+\tchmod +x templates/hooks/post-update &&\n\t+\n\t \techo whatever >templates/foo &&\n\t \tgit init --template=templates &&\n\t \techo \"-rw-rw-rw-\" >expect &&\n\nFrom a glance isn't the real fix here to adjust the \"post-update hook\nmust be 0770\" case? I.e. it's conflating \"I saw the right permissions\"\nwith \"I didn't see this line at all\", isn't it?\n\nThus if we take this squash above we're not setting up the post-update\nhook at all, so it's \"not broken\", but if we ever screw up our test\nsetup again it'll be broken again...\n\nNo?\n"},{"id":"468100","messageId":"CANYiYbHxgktZ27C0tPReS4m-esU9PD4jRacO08tmnrgyrq+jOg@mail.gmail.com","threadId":"58860","inReplyTo":"221128.86edtnky39.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 1/3] t1301: fix wrong template dir for git-init","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T14:12:16Z","receivedAt":"2022-11-28T14:12:36Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"On Mon, Nov 28, 2022 at 9:28 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n>\n>\n> On Mon, Nov 28 2022, Jiang Xin wrote:\n>\n> > From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> >\n> > The template dir prepared in test case \"forced modes\" is not used as\n> > expected because a wrong template dir is provided to \"git init\". This is\n> > because the $CWD for \"git-init\" command is a sibling directory alongside\n> > the template directory. Change it to the right template directory and\n> > add a protection test using \"test_path_is_file\".\n> >\n> > The wrong template directory was introduced by mistake in commit\n> > e1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n> >\n> > Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n> > ---\n> >  t/t1301-shared-repo.sh | 3 ++-\n> >  1 file changed, 2 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n> > index 93a2f91f8a..7578e75d77 100755\n> > --- a/t/t1301-shared-repo.sh\n> > +++ b/t/t1301-shared-repo.sh\n> > @@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n> >       (\n> >               cd new &&\n> >               umask 002 &&\n> > -             git init --shared=0660 --template=templates &&\n> > +             git init --shared=0660 --template=../templates &&\n> > +             test_path_is_file .git/hooks/post-update &&\n> >               >frotz &&\n> >               git add frotz &&\n> >               git commit -a -m initial &&\n>\n> This fix looks fishy to me. The code you're changing looks like it was\n> buggy, but this looks like it's sweeping under the rug the fact that\n> \"templates\" never did anything at this point.\n>\n> So I'm not saying you should squash this in, but if you do so you'll see\n> that we only ever used this later.\n>\n>         diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n>         index d4315b5ef5a..106ccc5704e 100755\n>         --- a/t/t1301-shared-repo.sh\n>         +++ b/t/t1301-shared-repo.sh\n>         @@ -129,15 +129,12 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n>          '\n>\n>          test_expect_success POSIXPERM 'forced modes' '\n>         -       mkdir -p templates/hooks &&\n>         -       echo update-server-info >templates/hooks/post-update &&\n>         -       chmod +x templates/hooks/post-update &&\n\nThe \"post-update\" is used in this test case. A wrong template dir\nleads to an empty hooks dir in \"new/\", that cause the test at the\nend of this test case passed by accident.\n\n        # post-update hook must be 0770\n        test -z \"$(sed -n -e \"/post-update/{\n                /^-rwxrwx---/d\n                p\n        }\" actual)\" &&\n\n--\nJiang Xin\n"},{"id":"468104","messageId":"221128.86a64bkvkm.gmgdl@evledraar.gmail.com","threadId":"58860","inReplyTo":"CANYiYbHxgktZ27C0tPReS4m-esU9PD4jRacO08tmnrgyrq+jOg@mail.gmail.com","subject":"Re: [PATCH v2 1/3] t1301: fix wrong template dir for git-init","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-11-28T14:21:14Z","receivedAt":"2022-11-28T14:22:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Nov 28 2022, Jiang Xin wrote:\n\n> On Mon, Nov 28, 2022 at 9:28 PM Ævar Arnfjörð Bjarmason\n> <avarab@gmail.com> wrote:\n>>\n>>\n>> On Mon, Nov 28 2022, Jiang Xin wrote:\n>>\n>> > From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>> >\n>> > The template dir prepared in test case \"forced modes\" is not used as\n>> > expected because a wrong template dir is provided to \"git init\". This is\n>> > because the $CWD for \"git-init\" command is a sibling directory alongside\n>> > the template directory. Change it to the right template directory and\n>> > add a protection test using \"test_path_is_file\".\n>> >\n>> > The wrong template directory was introduced by mistake in commit\n>> > e1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n>> >\n>> > Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n>> > ---\n>> >  t/t1301-shared-repo.sh | 3 ++-\n>> >  1 file changed, 2 insertions(+), 1 deletion(-)\n>> >\n>> > diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n>> > index 93a2f91f8a..7578e75d77 100755\n>> > --- a/t/t1301-shared-repo.sh\n>> > +++ b/t/t1301-shared-repo.sh\n>> > @@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n>> >       (\n>> >               cd new &&\n>> >               umask 002 &&\n>> > -             git init --shared=0660 --template=templates &&\n>> > +             git init --shared=0660 --template=../templates &&\n>> > +             test_path_is_file .git/hooks/post-update &&\n>> >               >frotz &&\n>> >               git add frotz &&\n>> >               git commit -a -m initial &&\n>>\n>> This fix looks fishy to me. The code you're changing looks like it was\n>> buggy, but this looks like it's sweeping under the rug the fact that\n>> \"templates\" never did anything at this point.\n>>\n>> So I'm not saying you should squash this in, but if you do so you'll see\n>> that we only ever used this later.\n>>\n>>         diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n>>         index d4315b5ef5a..106ccc5704e 100755\n>>         --- a/t/t1301-shared-repo.sh\n>>         +++ b/t/t1301-shared-repo.sh\n>>         @@ -129,15 +129,12 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n>>          '\n>>\n>>          test_expect_success POSIXPERM 'forced modes' '\n>>         -       mkdir -p templates/hooks &&\n>>         -       echo update-server-info >templates/hooks/post-update &&\n>>         -       chmod +x templates/hooks/post-update &&\n>\n> The \"post-update\" is used in this test case. A wrong template dir\n> leads to an empty hooks dir in \"new/\", that cause the test at the\n> end of this test case passed by accident.\n>\n>         # post-update hook must be 0770\n>         test -z \"$(sed -n -e \"/post-update/{\n>                 /^-rwxrwx---/d\n>                 p\n>         }\" actual)\" &&\n\nYes exactly, which is what I was pointing out with \"isn't the real\nfix...?\". I.e. this does seem to improve things, but as this shows this\ntest is really fragile already.\n\nSo I think if we're poking at this it makes sense to change that \"test\n-z\" to use \"test_modebits\" or something instead, so it'll actually do\nwhat we expect, and not just silently pass if the hook is missing...\n"},{"id":"468105","messageId":"CANYiYbG2LNALFzOj+VvZZWQAhFjYY8y3ymLh9KTptFL2OXs7gQ@mail.gmail.com","threadId":"58860","inReplyTo":"221128.86ilizkybr.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 3/3] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-28T14:29:32Z","receivedAt":"2022-11-28T14:30:23Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"On Mon, Nov 28, 2022 at 9:23 PM Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> I think this approach goes against the effort to implicitly stop relying\n> on templates. See 3d3874d537a (Merge branch 'ab/test-without-templates',\n> 2022-07-18) for commits related to that.\n\nAs I said in the cover letter, it was the conflict of \".git/info\" with\nour internal reference transactions that drew my attention to this\ntest case. This is because our builtin reference-transaction hook\nwhich will automatically create a \".git/info\" directory to create some\nfiles inside, such as \".git/info/checksum\", I have to change \"mkdir\n.git/info\" to \"mkdir -p .git/info\" one by one. And I found in this\ntest case, there is a wrong template dir.\n\n> I think better thing to do here is to squash this in:\n>\n>         diff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\n>         index 0b3722aa149..b7222b7bc07 100755\n>         --- a/t/t1301-shared-repo.sh\n>         +++ b/t/t1301-shared-repo.sh\n>         @@ -8,6 +8,7 @@ test_description='Test shared repository initialization'\n>          GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n>          export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>\n>         +TEST_CREATE_REPO_NO_TEMPLATE=1\n>          . ./test-lib.sh\n\nWill use this implementation instead.\n\nThanks.\n\n--\nJiang Xin\n"},{"id":"468134","messageId":"xmqq4jui61r8.fsf@gitster.g","threadId":"58860","inReplyTo":"221128.86ilizkybr.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH v2 3/3] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-11-29T00:30:19Z","receivedAt":"2022-11-29T00:30:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> I think this approach goes against the effort to implicitly stop relying\n> on templates.\n\n... which I am perfectly OK with.  If you removed something that is\nessential to the health of the respository from your templates, you\ndeserve the breakage you caused yourself and can keep both halves.\n"},{"id":"468179","messageId":"20221129131511.7173-1-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-1-worldhello.net@gmail.com","subject":"[PATCH v3 0/3] t1301: various updates","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-29T13:15:08Z","receivedAt":"2022-11-29T13:15:53Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nVarious updates for t1301:\n\n  * t1301: fix wrong template dir for git-init\n  * t1301: use test_when_finished for cleanup\n  * t1301: do not change $CWD in \"shared=all\" test case\n\n## range-diff v2...v3\n\n\n1:  bc68ffb41c = 1:  7a66766a10 t1301: fix wrong template dir for git-init\n2:  ae2b2f8afc = 2:  97eefb1e67 t1301: use test_when_finished for cleanup\n3:  f1bf255e5a ! 3:  9575f2eb1c t1301: do not change $CWD in \"shared=all\" test case\n    @@ Commit message\n         So it is a safe change for us to run the test case \"shared=all\" in\n         current repository instead of creating and changing to \"sub\".\n     \n    -    For the next test case, we no longer run it in the \"sub\" repository\n    -    which is initialized from an empty template, we should not assume the\n    -    path \".git/info\" is missing. So add option \"-p\" to mkdir.\n    +    For the next test case, the path \".git/info\" is assumed to be missing,\n    +    but we no longer run the test case in the \"sub\" repository which is\n    +    initialized from an empty template. In order for the test case to run\n    +    properly, we can set \"TEST_CREATE_REPO_NO_TEMPLATE=1\" to initialize the\n    +    default repository without a template.\n     \n         Helped-by: Junio C Hamano <gitster@pobox.com>\n    +    Helped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n         Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n     \n      ## t/t1301-shared-repo.sh ##\n    +@@ t/t1301-shared-repo.sh: test_description='Test shared repository initialization'\n    + GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n    + export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n    + \n    ++TEST_CREATE_REPO_NO_TEMPLATE=1\n    + . ./test-lib.sh\n    + \n    + # Remove a default ACL from the test dir if possible.\n     @@ t/t1301-shared-repo.sh: do\n      done\n      \n    @@ t/t1301-shared-repo.sh: do\n      \tgit init --template= --shared=all &&\n      \ttest 2 = $(git config core.sharedrepository)\n      '\n    -@@ t/t1301-shared-repo.sh: test_expect_success POSIXPERM 'update-server-info honors core.sharedRepository'\n    - \tgit add a1 &&\n    - \ttest_tick &&\n    - \tgit commit -m a1 &&\n    --\tmkdir .git/info &&\n    -+\tmkdir -p .git/info &&\n    - \tumask 0277 &&\n    - \tgit update-server-info &&\n    - \tactual=\"$(ls -l .git/info/refs)\" &&\n\n--\n\nJiang Xin (3):\n  t1301: fix wrong template dir for git-init\n  t1301: use test_when_finished for cleanup\n  t1301: do not change $CWD in \"shared=all\" test case\n\n t/t1301-shared-repo.sh | 14 ++++++++------\n 1 file changed, 8 insertions(+), 6 deletions(-)\n\n-- \n2.39.0.rc0\n\n"},{"id":"468180","messageId":"20221129131511.7173-2-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-1-worldhello.net@gmail.com","subject":"[PATCH v3 1/3] t1301: fix wrong template dir for git-init","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-29T13:15:09Z","receivedAt":"2022-11-29T13:16:05Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nThe template dir prepared in test case \"forced modes\" is not used as\nexpected because a wrong template dir is provided to \"git init\". This is\nbecause the $CWD for \"git-init\" command is a sibling directory alongside\nthe template directory. Change it to the right template directory and\nadd a protection test using \"test_path_is_file\".\n\nThe wrong template directory was introduced by mistake in commit\ne1df7fe43f (init: make --template path relative to $CWD, 2019-05-10).\n\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 93a2f91f8a..7578e75d77 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -140,7 +140,8 @@ test_expect_success POSIXPERM 'forced modes' '\n \t(\n \t\tcd new &&\n \t\tumask 002 &&\n-\t\tgit init --shared=0660 --template=templates &&\n+\t\tgit init --shared=0660 --template=../templates &&\n+\t\ttest_path_is_file .git/hooks/post-update &&\n \t\t>frotz &&\n \t\tgit add frotz &&\n \t\tgit commit -a -m initial &&\n-- \n2.39.0.rc0\n\n"},{"id":"468181","messageId":"20221129131511.7173-3-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-1-worldhello.net@gmail.com","subject":"[PATCH v3 2/3] t1301: use test_when_finished for cleanup","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-29T13:15:10Z","receivedAt":"2022-11-29T13:16:09Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nRefactor several test cases to use \"test_when_finished\" for cleanup.\n\n1. For first of these, we used to clean-up outside the test, but instead\n   let's use test_when_finished for that.\n\n2. For the second, we used to leave \"new\" after we are done, but not use\n   it at all later. Now we do clean up.\n\n3. For the rest, these child.git test repositories used to follow\n   \"initialize what we are going to use to a known state before we use\"\n   pattern, which is not wrong per-se, but now we use \"clean up the\n   cruft we made after we are done\" pattern, which may arguably be\n   better simply because the test that makes cruft should know what\n   cruft it created better than whatever comes later that may not know.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 7578e75d77..1225abbb6d 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -25,6 +25,7 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '\n for u in 002 022\n do\n \ttest_expect_success POSIXPERM \"shared=1 does not clear bits preset by umask $u\" '\n+\t\ttest_when_finished \"rm -rf sub\" &&\n \t\tmkdir sub && (\n \t\t\tcd sub &&\n \t\t\tumask $u &&\n@@ -42,7 +43,6 @@ do\n \t\t\t;;\n \t\tesac\n \t'\n-\trm -rf sub\n done\n \n test_expect_success 'shared=all' '\n@@ -132,6 +132,7 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '\n '\n \n test_expect_success POSIXPERM 'forced modes' '\n+\ttest_when_finished \"rm -rf new\" &&\n \tmkdir -p templates/hooks &&\n \techo update-server-info >templates/hooks/post-update &&\n \tchmod +x templates/hooks/post-update &&\n@@ -174,6 +175,7 @@ test_expect_success POSIXPERM 'forced modes' '\n '\n \n test_expect_success POSIXPERM 'remote init does not use config from cwd' '\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tgit config core.sharedrepository 0666 &&\n \tumask 0022 &&\n \tgit init --bare child.git &&\n@@ -193,7 +195,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (local)' '\n '\n \n test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit init --bare --shared=0666 child.git &&\n \ttest_path_is_missing child.git/foo &&\n@@ -204,7 +206,7 @@ test_expect_success POSIXPERM 're-init respects core.sharedrepository (remote)'\n '\n \n test_expect_success POSIXPERM 'template can set core.sharedrepository' '\n-\trm -rf child.git &&\n+\ttest_when_finished \"rm -rf child.git\" &&\n \tumask 0022 &&\n \tgit config core.sharedrepository 0666 &&\n \tcp .git/config templates/config &&\n-- \n2.39.0.rc0\n\n"},{"id":"468182","messageId":"20221129131511.7173-4-worldhello.net@gmail.com","threadId":"58860","inReplyTo":"20221128130323.8914-1-worldhello.net@gmail.com","subject":"[PATCH v3 3/3] t1301: do not change $CWD in \"shared=all\" test case","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2022-11-29T13:15:11Z","receivedAt":"2022-11-29T13:16:11Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"From: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n\nIn test case \"shared=all\", the working directory is permanently changed\nto the \"sub\" directory. This leads to a strange behavior that the\ntemporary repositories created by subsequent test cases are all in this\n\"sub\" directory, such as \"sub/new\", \"sub/child.git\". If we bypass this\ntest case, all subsequent test cases will have different working\ndirectory.\n\nBesides, all subsequent test cases assuming they are in the \"sub\"\ndirectory do not run any destructive operations in their parent\ndirectory (\"..\"), and will not make damage out side of $TRASH_DIRECTORY.\n\nSo it is a safe change for us to run the test case \"shared=all\" in\ncurrent repository instead of creating and changing to \"sub\".\n\nFor the next test case, the path \".git/info\" is assumed to be missing,\nbut we no longer run the test case in the \"sub\" repository which is\ninitialized from an empty template. In order for the test case to run\nproperly, we can set \"TEST_CREATE_REPO_NO_TEMPLATE=1\" to initialize the\ndefault repository without a template.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\nSigned-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>\n---\n t/t1301-shared-repo.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/t1301-shared-repo.sh b/t/t1301-shared-repo.sh\nindex 1225abbb6d..58d6da7feb 100755\n--- a/t/t1301-shared-repo.sh\n+++ b/t/t1301-shared-repo.sh\n@@ -8,6 +8,7 @@ test_description='Test shared repository initialization'\n GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n+TEST_CREATE_REPO_NO_TEMPLATE=1\n . ./test-lib.sh\n \n # Remove a default ACL from the test dir if possible.\n@@ -46,8 +47,6 @@ do\n done\n \n test_expect_success 'shared=all' '\n-\tmkdir sub &&\n-\tcd sub &&\n \tgit init --template= --shared=all &&\n \ttest 2 = $(git config core.sharedrepository)\n '\n-- \n2.39.0.rc0\n\n"}]}