summaryrefslogtreecommitdiff
path: root/t/t5516-fetch-push.sh
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2021-12-01 22:15:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-02 06:18:25 (GMT)
commit9fdf4f1db422cc259e4a3ce0023a255102c6fa3b (patch)
treea041ac1de8d1661dbedee3df94834dd453db9781 /t/t5516-fetch-push.sh
parent38baae6cfe4ac3af60e127b9e7f9de04c47c4881 (diff)
downloadgit-9fdf4f1db422cc259e4a3ce0023a255102c6fa3b.zip
git-9fdf4f1db422cc259e4a3ce0023a255102c6fa3b.tar.gz
git-9fdf4f1db422cc259e4a3ce0023a255102c6fa3b.tar.bz2
receive-pack: protect current branch for bare repository worktree
A bare repository won’t have a working tree at "..", but it may still have separate working trees created with git worktree. We should protect the current branch of such working trees from being updated or deleted, according to receive.denyCurrentBranch. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-xt/t5516-fetch-push.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index f07e321..cd2e144 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1769,9 +1769,23 @@ test_expect_success 'denyCurrentBranch and worktrees' '
test_must_fail git -C cloned push origin HEAD:new-wt &&
test_config receive.denyCurrentBranch updateInstead &&
git -C cloned push origin HEAD:new-wt &&
+ test_path_exists new-wt/first.t &&
test_must_fail git -C cloned push --delete origin new-wt
'
+test_expect_success 'denyCurrentBranch and bare repository worktrees' '
+ test_when_finished "rm -fr bare.git" &&
+ git clone --bare . bare.git &&
+ git -C bare.git worktree add wt &&
+ test_commit grape &&
+ git -C bare.git config receive.denyCurrentBranch refuse &&
+ test_must_fail git push bare.git HEAD:wt &&
+ git -C bare.git config receive.denyCurrentBranch updateInstead &&
+ git push bare.git HEAD:wt &&
+ test_path_exists bare.git/wt/grape.t &&
+ test_must_fail git push --delete bare.git wt
+'
+
test_expect_success 'refuse fetch to current branch of worktree' '
test_when_finished "git worktree remove --force wt && git branch -D wt" &&
git worktree add wt &&