]> git.ipfire.org Git - thirdparty/git.git/commit
fetch: protect branches checked out in all worktrees
authorAnders Kaseorg <andersk@mit.edu>
Wed, 1 Dec 2021 22:15:44 +0000 (14:15 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Dec 2021 06:18:25 +0000 (22:18 -0800)
commit8bc1f39f411e06b940230dc84da5568dfafec922
tree667a72d0d0509b2675e0a3655b5b3da525553280
parentc8dd491fa5b57ecfd9ef33ae5291eb2a9402cd59
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>
builtin/fetch.c
t/t5516-fetch-push.sh