From patchwork Wed Dec 1 22:15:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Kaseorg X-Patchwork-Id: 12651201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C27ACC433F5 for ; Wed, 1 Dec 2021 22:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353479AbhLAWTr (ORCPT ); Wed, 1 Dec 2021 17:19:47 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:33948 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S243260AbhLAWTn (ORCPT ); Wed, 1 Dec 2021 17:19:43 -0500 Received: from localhost (198-27-191-186.fiber.dynamic.sonic.net [198.27.191.186]) (authenticated bits=0) (User authenticated as andersk@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 1B1MG1qD012556 (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 1 Dec 2021 17:16:02 -0500 From: Anders Kaseorg To: Junio C Hamano Cc: git@vger.kernel.org, Johannes Schindelin , Jeff King , Andreas Heiduk , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24g?= , Jiang Xin , Anders Kaseorg Subject: [PATCH v7 0/8] protect branches checked out in all worktrees Date: Wed, 1 Dec 2021 14:15:39 -0800 Message-Id: <20211201221547.1796213-1-andersk@mit.edu> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org ‘git fetch’ (without ‘--update-head-ok’), ‘git receive-pack’, and ‘git branch -M’ protect the currently checked out branch from being accidentally updated. However, the code for these checks predates ‘git worktree’. Improve it to protect branches checked out in all worktrees, not just the current one. Anders Kaseorg (8): fetch: lowercase error messages receive-pack: lowercase error messages branch: lowercase error messages worktree: simplify find_shared_symref() memory ownership model fetch: protect branches checked out in all worktrees receive-pack: clean dead code from update_worktree() receive-pack: protect current branch for bare repository worktree branch: protect branches checked out in all worktrees branch.c | 45 +++++++----- builtin/branch.c | 7 +- builtin/fetch.c | 119 +++++++++++++++++--------------- builtin/notes.c | 6 +- builtin/receive-pack.c | 92 +++++++++++++----------- t/t2018-checkout-branch.sh | 2 +- t/t3200-branch.sh | 11 ++- t/t5504-fetch-receive-strict.sh | 2 +- t/t5516-fetch-push.sh | 32 +++++++++ worktree.c | 8 +-- worktree.h | 5 +- 11 files changed, 198 insertions(+), 131 deletions(-)