Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2021-12-02 01:15:44 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-02 09:18:25 +0300
commit8bc1f39f411e06b940230dc84da5568dfafec922 (patch)
tree667a72d0d0509b2675e0a3655b5b3da525553280 /t/t5516-fetch-push.sh
parentc8dd491fa5b57ecfd9ef33ae5291eb2a9402cd59 (diff)
fetch: protect branches checked out in all worktrees
Refuse to fetch into the currently checked out branch of any working tree, not just the current one. Fixes this previously reported bug: https://lore.kernel.org/git/cb957174-5e9a-5603-ea9e-ac9b58a2eaad@mathema.de/ As a side effect of using find_shared_symref, we’ll also refuse the fetch when we’re on a detached HEAD because we’re rebasing or bisecting on the branch in question. This seems like a sensible change. 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.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 8212ca56dc..f07e32126f 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1771,4 +1771,22 @@ test_expect_success 'denyCurrentBranch and worktrees' '
git -C cloned push origin HEAD:new-wt &&
test_must_fail git -C cloned push --delete origin new-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 &&
+ test_commit apple &&
+ test_must_fail git fetch . HEAD:wt &&
+ git fetch -u . HEAD:wt
+'
+
+test_expect_success 'refuse fetch to current branch of bare repository worktree' '
+ test_when_finished "rm -fr bare.git" &&
+ git clone --bare . bare.git &&
+ git -C bare.git worktree add wt &&
+ test_commit banana &&
+ test_must_fail git -C bare.git fetch .. HEAD:wt &&
+ git -C bare.git fetch -u .. HEAD:wt
+'
+
test_done