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:
authorJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:16 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-22 02:03:16 +0300
commit13fa77b6899d0068303761c449d9a7e01dd85eb8 (patch)
treeb15e735aa90f701444aaa66ab080695f10a85549 /t/t5516-fetch-push.sh
parentee1dc493d10d814ceba1a551d9a185b9da627ad8 (diff)
parent593a2a5d0639b4b4f91ff6e6ffb64e72020f8fd8 (diff)
Merge branch 'ak/protect-any-current-branch'
"git fetch" without the "--update-head-ok" option ought to protect a checked out branch from getting updated, to prevent the working tree that checks it out to go out of sync. The code was written before the use of "git worktree" got widespread, and only checked the branch that was checked out in the current worktree, which has been updated. (originally called ak/fetch-not-overwrite-any-current-branch) * ak/protect-any-current-branch: branch: protect branches checked out in all worktrees receive-pack: protect current branch for bare repository worktree receive-pack: clean dead code from update_worktree() fetch: protect branches checked out in all worktrees worktree: simplify find_shared_symref() memory ownership model branch: lowercase error messages receive-pack: lowercase error messages fetch: lowercase error messages
Diffstat (limited to 't/t5516-fetch-push.sh')
-rwxr-xr-xt/t5516-fetch-push.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 7831a38dde..837a49642a 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1778,6 +1778,38 @@ 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 &&
+ 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