[PATCH v2 12/17] t5540/t5541: avoid accessing a bare repository via `-C <dir>`
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Apr 4, 2026, 19:49 UTC
- Message-ID
- <c8789bd5423cec3a52dea88b78a7ca541ab9db06.1775332197.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2076.v2.git.1775332197.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In the `test_http_push_nonff` function both of these test scripts call, there were two Git invocations that assume that bare repositories will always be discovered when the current working directory is inside one. This is unlikely to be true forever because at some stage, the `safe.bareRepository` config is prone to be modified to be safe by default.
So let's be safe and specify the bare repository explicitly.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- t/lib-httpd.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 4c76e813e3..f15158b2c5 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -259,7 +259,7 @@ test_http_push_nonff () { test_expect_success 'non-fast-forward push fails' ' cd "$REMOTE_REPO" && - HEAD=$(git rev-parse --verify HEAD) && + HEAD=$(git --git-dir=. rev-parse --verify HEAD) && cd "$LOCAL_REPO" && git checkout $BRANCH && @@ -270,7 +270,7 @@ test_http_push_nonff () { ( cd "$REMOTE_REPO" && echo "$HEAD" >expect && - git rev-parse --verify HEAD >actual && + git --git-dir=. rev-parse --verify HEAD >actual && test_cmp expect actual ) ' @@ -284,18 +284,16 @@ test_http_push_nonff () { ' test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' ' - HEAD=$( cd "$REMOTE_REPO" && git rev-parse --verify HEAD ) && + HEAD=$(git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD) && test_when_finished '\'' - (cd "$REMOTE_REPO" && git update-ref HEAD "$HEAD") + git --git-dir="$REMOTE_REPO" update-ref HEAD "$HEAD" '\'' && ( cd "$LOCAL_REPO" && git push -v --force-with-lease=$BRANCH:$HEAD origin ) && git rev-parse --verify "$BRANCH" >expect && - ( - cd "$REMOTE_REPO" && git rev-parse --verify HEAD - ) >actual && + git --git-dir="$REMOTE_REPO" rev-parse --verify HEAD >actual && test_cmp expect actual ' }
-- gitgitgadget