Re: [PATCH v2 3/4] bug: denyCurrentBranch and unborn branch with ref namespace
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 23, 2020, 06:10 UTC
- Message-ID
- <xmqqk14dsuj8.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <b3e573d44a99a828e710f06b723942107189afeb.1582410908.git.gitgitgadget@gmail.com>
"Hariom Verma via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +test_expect_failure 'denyCurrentBranch and unborn branch with ref namespace' '
Please do not chdir around in the test script. The next person who adds new test after this test will be surprised that his/her test does not start at the top-level of the test/trash directory, but in the "original" subdirectory.
And no, adding "&& cd .." at the end of this &&-cascade is *not* a fix---when any of the steps chained with && fails, such a "we have moved the process to a wrong place, so let's move back with 'cd ..'" will not get executed.
Show 7 quoted lines
> + cd original && > + git init unborn && > + git remote add unborn-namespaced "ext::git --namespace=namespace %s unborn" && > + test_must_fail git push unborn-namespaced HEAD:master && > + test_config -C unborn receive.denyCurrentBranch updateInstead && > + git push unborn-namespaced HEAD:master > +'
What is often done to fix is to execute what you need to run in a subshell, e.g.
test_expect_success 'demonstration' ' ( cd original && git init unborn && ... test_must_fail git push ... && git -C unborn config ... && git push ... ) '
The use of "git config" instead of "test_config" in the above illustration is deliberate---the latter does not work and should not be used inside a subshell.
> + > test_done