From patchwork Sun Jan 22 01:23:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13111380 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 E7A8BC38142 for ; Sun, 22 Jan 2023 01:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229744AbjAVBX7 (ORCPT ); Sat, 21 Jan 2023 20:23:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjAVBX5 (ORCPT ); Sat, 21 Jan 2023 20:23:57 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB25F768 for ; Sat, 21 Jan 2023 17:23:56 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id b7so7891706wrt.3 for ; Sat, 21 Jan 2023 17:23:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject:from:to:cc :subject:date:message-id:reply-to; bh=EiuRXkPtYEgYeeosA0eVtt8bqpWzKX0V6qTRosIZ76w=; b=D+IC2PZcIZatg8+b9ZXRnlNMFNINES4qSS9EYyeKPjWraEmQNGOGr41GOc/FID/uQ0 pAdgJ4WIi0XlcNka2OCXD1ZtcB8/q9IKqKh+Q2vNfTndtIpMkTDPO2ys3yeqh4HsWvO6 6mtOsH7bsFSq9Njc6t4rrstWSLsJuCDY1mDfPkcAikvaXt5fnBl6KraahJlHau2he+LV ipkuKmvkhcC6R/wD5j+4Id5XM3HyE9KnqwgySaXeZX3vporIc3fHI+VBEHBHwGWP6USB kfEwzuQjpJ5n6p0dtNJNOQcwv4Fhhcfj0ShUFmh4k2+Rk3REbzfLjLZ3uqhrRymtWKFQ 7JIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EiuRXkPtYEgYeeosA0eVtt8bqpWzKX0V6qTRosIZ76w=; b=kePB3HCNAy57FHvrRwj4aNIw5e7wRksqnl28yni5qmxQKjtEtmUmgbGlP9YYn5ifA0 gpG4v9ITKjLFhxcnxnWD9cCV0xSPVxZBAkUcizB4SuBsH6Cz1KgAdNHmSZGmiuXfgw4W K1Pa2WfIOWWFHU94l1VUARrmr0Z4PLMXJoYOADZuVVZlfC7YaSlxG4cZH/DbIXmv2j1G jv6q14lBk3DRWbE5YReN5eQ4LMi0N3tI07z4/V8lFnD5GoyqsupRfW5Jhck3+1rqv0NG PbSbiI23LLY1hHdqTT0N32KMC3kAHAAmp2jKh5qS7dhnEUYBjJch9T0SVX9CgSi3yJsE 8p0Q== X-Gm-Message-State: AFqh2kq0TGf7wzeGbkl7MOPb22ohU/pwVMZesZjqbkMLk0gNHcF5QyAj FxkBh5QXRQfqUBHyryjftEA= X-Google-Smtp-Source: AMrXdXuf8LE14PGVWx4h+opeaV37BHmad/XZyJgml4ngtaFKv1syud2Ndnq7xl0fZgk3EvL1ZUiyAQ== X-Received: by 2002:adf:de0f:0:b0:2bb:de14:a18 with SMTP id b15-20020adfde0f000000b002bbde140a18mr11510206wrm.14.1674350634694; Sat, 21 Jan 2023 17:23:54 -0800 (PST) Received: from [192.168.2.52] (94.red-88-14-213.dynamicip.rima-tde.net. [88.14.213.94]) by smtp.gmail.com with ESMTPSA id k5-20020adfd845000000b002bdd96d88b4sm24205349wrl.75.2023.01.21.17.23.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Jan 2023 17:23:54 -0800 (PST) Subject: [PATCH v2 1/3] branch: fix die_if_checked_out() when ignore_current_worktree From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List Cc: Junio C Hamano , Phillip Wood References: Message-ID: <17f267b1-7f5e-2fb6-fb14-1c37ec355e65@gmail.com> Date: Sun, 22 Jan 2023 02:23:53 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In 8d9fdd7 (worktree.c: check whether branch is rebased in another worktree, 2016-04-22) die_if_checked_out() learned a new option ignore_current_worktree, to modify the operation from "die() if the branch is checked out in any worktree" to "die() if the branch is checked out in any worktree other than the current one". Unfortunately we implemented it by checking the flag is_current in the worktree that find_shared_symref() returns. When the same branch is checked out in several worktrees simultaneously, find_shared_symref() will return the first matching worktree in the list composed by get_worktrees(). If one of the worktrees with the checked out branch is the current worktree, find_shared_symref() may or may not return it, depending on the order of the list. Let's stop using find_shared_symref() in die_if_checked_out(), to handle correctly ignore_current_worktree. Signed-off-by: Rubén Justo --- branch.c | 16 +++++++++++----- worktree.c | 54 +++++++++++++++++++++++++++++------------------------- worktree.h | 6 ++++++ 3 files changed, 46 insertions(+), 30 deletions(-) diff --git a/branch.c b/branch.c index d182756827..2378368415 100644 --- a/branch.c +++ b/branch.c @@ -820,12 +820,18 @@ void remove_branch_state(struct repository *r, int verbose) void die_if_checked_out(const char *branch, int ignore_current_worktree) { struct worktree **worktrees = get_worktrees(); - const struct worktree *wt; + int i; + + for (i = 0; worktrees[i]; i++) + { + if (worktrees[i]->is_current && ignore_current_worktree) + continue; - wt = find_shared_symref(worktrees, "HEAD", branch); - if (wt && (!ignore_current_worktree || !wt->is_current)) { - skip_prefix(branch, "refs/heads/", &branch); - die(_("'%s' is already checked out at '%s'"), branch, wt->path); + if (is_shared_symref(worktrees[i], "HEAD", branch)) { + skip_prefix(branch, "refs/heads/", &branch); + die(_("'%s' is already checked out at '%s'"), + branch, worktrees[i]->path); + } } free_worktrees(worktrees); diff --git a/worktree.c b/worktree.c index aa43c64119..d500d69e4c 100644 --- a/worktree.c +++ b/worktree.c @@ -403,6 +403,33 @@ int is_worktree_being_bisected(const struct worktree *wt, * bisect). New commands that do similar things should update this * function as well. */ +int is_shared_symref(const struct worktree *wt, const char *symref, + const char *target) +{ + const char *symref_target; + struct ref_store *refs; + int flags; + + if (wt->is_bare) + return 0; + + if (wt->is_detached && !strcmp(symref, "HEAD")) { + if (is_worktree_being_rebased(wt, target)) + return 1; + if (is_worktree_being_bisected(wt, target)) + return 1; + } + + refs = get_worktree_ref_store(wt); + symref_target = refs_resolve_ref_unsafe(refs, symref, 0, + NULL, &flags); + if ((flags & REF_ISSYMREF) && + symref_target && !strcmp(symref_target, target)) + return 1; + + return 0; +} + const struct worktree *find_shared_symref(struct worktree **worktrees, const char *symref, const char *target) @@ -411,31 +438,8 @@ const struct worktree *find_shared_symref(struct worktree **worktrees, int i = 0; for (i = 0; worktrees[i]; i++) { - struct worktree *wt = worktrees[i]; - const char *symref_target; - struct ref_store *refs; - int flags; - - if (wt->is_bare) - continue; - - if (wt->is_detached && !strcmp(symref, "HEAD")) { - if (is_worktree_being_rebased(wt, target)) { - existing = wt; - break; - } - if (is_worktree_being_bisected(wt, target)) { - existing = wt; - break; - } - } - - refs = get_worktree_ref_store(wt); - symref_target = refs_resolve_ref_unsafe(refs, symref, 0, - NULL, &flags); - if ((flags & REF_ISSYMREF) && - symref_target && !strcmp(symref_target, target)) { - existing = wt; + if (is_shared_symref(worktrees[i], symref, target)) { + existing = worktrees[i]; break; } } diff --git a/worktree.h b/worktree.h index 9dcea6fc8c..7889c4761d 100644 --- a/worktree.h +++ b/worktree.h @@ -149,6 +149,12 @@ const struct worktree *find_shared_symref(struct worktree **worktrees, const char *symref, const char *target); +/* + * Returns true if a symref points to a ref in a worktree. + */ +int is_shared_symref(const struct worktree *wt, + const char *symref, const char *target); + /* * Similar to head_ref() for all HEADs _except_ one from the current * worktree, which is covered by head_ref(). From patchwork Sun Jan 22 01:28:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13111381 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 E662AC27C76 for ; Sun, 22 Jan 2023 01:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbjAVB2P (ORCPT ); Sat, 21 Jan 2023 20:28:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjAVB2O (ORCPT ); Sat, 21 Jan 2023 20:28:14 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81281193F5 for ; Sat, 21 Jan 2023 17:28:13 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id l8so6633109wms.3 for ; Sat, 21 Jan 2023 17:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject:from:to:cc :subject:date:message-id:reply-to; bh=ZjHBNeqLSs/pYqIMWgX8unSi3QbAzvP0xO/zdCMIkHo=; b=iWHQ89PtGkw0oZQTZAWSBpkbNlUdcjC2AGHxTWwyQ2QKCNaQhFgFkzennrcPYBZQ+E +GZb2S+YJ/rawdq8ewETMg4cJfhQq/eXx818K1104gy9lDJivEkOoKTKSwIgAMan6z0h coitwBh9bl3g3rZ2sptv/FUfqj7yY0zcDYbiuQ2nqGmpu5w3mUYCkxKpO6tstM3ibVF3 eh4dg1Jsucbib0W1aoroi2vDnxeV1uxirz64jA8vCAGewbVu8vAeQiKC4LxFTvq9r0ZV qWNIMs4jb8x75mc6VbJhIArJbxv+fenO+g96waEAfihd3rAIgvb8fTuJctC9U5UnaaJ4 9PlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZjHBNeqLSs/pYqIMWgX8unSi3QbAzvP0xO/zdCMIkHo=; b=7V8O1tm3RYeSL38ztcVd20dQ0iQP/XplFl4F6FmkKb+9wBETbidAFY/nSUK78Tq5kF okvrTgUQ/JQyHjFzobCyCK3gtq9biaStPOxugJdWhYQkbqYOdn3JaklLdSJBFmRr3rP1 UX+qLzFsJVDbot5KMRZXx5WnVup5z34z8g315DcVHBbSCFZnuXlfRN9/3pJR65iwTpAH 45gvwtGoWENoaOiqLdIlEQeNtkE4nXHcKbZlcG+y+bVd+Eg7Q4qGeBkv4EQhDmfzfRzl uvLKPLjGLKzXzAGAbF5LUAKJBH4uHvHJeI027Q0QPJMreCsbxka0Tbi3buw/bxZ6lhFB IdFw== X-Gm-Message-State: AFqh2kq1u33llTcXyi4tusC/4HSxv3+ceT/9J8IO7CYsjR0gVRG2TCeD aZ15kyIZILlxy0Gdnba024g= X-Google-Smtp-Source: AMrXdXuKJ2MxHJsAAyl6p5Ky++Evvm6V8YqRpXExDH/48tPaf7Vz1uQKO0Jho1eyAM8XeMsYugRKfw== X-Received: by 2002:a05:600c:3b13:b0:3db:26b8:5023 with SMTP id m19-20020a05600c3b1300b003db26b85023mr10429682wms.10.1674350892083; Sat, 21 Jan 2023 17:28:12 -0800 (PST) Received: from [192.168.2.52] (94.red-88-14-213.dynamicip.rima-tde.net. [88.14.213.94]) by smtp.gmail.com with ESMTPSA id q7-20020a05600c46c700b003c6bbe910fdsm8606418wmo.9.2023.01.21.17.28.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Jan 2023 17:28:11 -0800 (PST) Subject: [PATCH v2 2/3] rebase: refuse to switch to a branch already checked out elsewhere (test) From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List Cc: Junio C Hamano , Phillip Wood References: Message-ID: <3452517b-1efa-4ea9-a7d9-ed27715c750c@gmail.com> Date: Sun, 22 Jan 2023 02:28:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In b5cabb4a9 (rebase: refuse to switch to branch already checked out elsewhere, 2020-02-23) we add a condition to prevent a rebase operation involving a switch to a branch that is already checked out in another worktree. A bug has recently been fixed that caused this to not work as expected. Let's add a test to notice if this changes in the future. Signed-off-by: Rubén Justo --- t/t3400-rebase.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index d5a8ee39fc..3ce918fdb8 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -388,6 +388,20 @@ test_expect_success 'switch to branch checked out here' ' git rebase main main ' +test_expect_success 'switch to branch checked out elsewhere fails' ' + test_when_finished " + git worktree remove wt1 && + git worktree remove wt2 && + git branch -d shared + " && + git worktree add wt1 -b shared && + git worktree add wt2 -f shared && + # we test in both worktrees to ensure that works + # as expected with "first" and "next" worktrees + test_must_fail git -C wt1 rebase shared shared && + test_must_fail git -C wt2 rebase shared shared +' + test_expect_success 'switch to branch not checked out' ' git checkout main && git branch other && From patchwork Sun Jan 22 01:28:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Rub=C3=A9n_Justo?= X-Patchwork-Id: 13111382 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 3D989C54EAA for ; Sun, 22 Jan 2023 01:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbjAVB2Y (ORCPT ); Sat, 21 Jan 2023 20:28:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjAVB2X (ORCPT ); Sat, 21 Jan 2023 20:28:23 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E98E19698 for ; Sat, 21 Jan 2023 17:28:22 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so8311499wmb.2 for ; Sat, 21 Jan 2023 17:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject:from:to:cc :subject:date:message-id:reply-to; bh=BOdibKdMGHDB1zNbm5hBI+eesv7GEKskhjDC1YrlgfY=; b=HjM1W/dnzaTgHlWdIK1BwhvsAxa/OmqV9+STGOhV1cqOI5abgq57FxsJyf5sQFIeaM czeoyINUuC7nhOt9zb2az1O5IculxOWlBNcqk4zUwTDewWuDXe5fgIaw3X7VD/qFwM7e qgxqRce++X15HpXL+GPmNXrFD7G8BS6IdSNg+bFURoNEor00t36oyDtYgbGfNWyTjB2Z iJSqrBI1fQrtaawxKhP96AgN0dXRAl58sG2GgrmL0MiKzafP1FJxtXDHmcUsQS45hWYY lj2dAJvtbT/eSb5s+/lc2zTgVHuCgOyQS37ScvzD9yJzRNRX8NaK+h/wc/P9LR0C+lAu R+Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:cc:to:from:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BOdibKdMGHDB1zNbm5hBI+eesv7GEKskhjDC1YrlgfY=; b=o9xSdX7TNuNCi1l94UgiNr6tX8XGiARH4PnrOp3TzctIaqkiH/Nt2V69SMv+A/ZQkr NbpgCFQ9iWJapXjIlfzddTXF22cCSAZXuPVbGFm+Tj6RkGDG4mO3Dm+aQcKhNGmHIwPK OBd4dxQ4gabpwGCw9vt4HUqBsAr0CuG37KYYTPCkaRcYwbNoYR6EPZTxRuV/aGsN9aCh u8tJ20PXXhvv59NqyoJuqy+P1yUvm8wmG4BPZbrzlLnD1NrCc7ScVPdvUuEUfw6l69g4 H9FhUq+yuYlbY2db2yh/xFnb66MvoDxYSlJmuo/8LxzndHFFx+xgpBbaDPJxZI2OJ4dc 4XDw== X-Gm-Message-State: AFqh2krReGDjuez9bvZKLJDrozHsn7u2q2OSXy/1C2GGHWQO0kjsKnZq mgN6htaMIoIQVxUI4HSKTmk= X-Google-Smtp-Source: AMrXdXsBCyJFcZpTfoz1f9GwoKAX5007BGTuCnKCmwhSS5B134HIRCmvgHwqwQiJM3oiG7hbUaqGng== X-Received: by 2002:a05:600c:3b83:b0:3d9:f758:e280 with SMTP id n3-20020a05600c3b8300b003d9f758e280mr19993456wms.24.1674350901084; Sat, 21 Jan 2023 17:28:21 -0800 (PST) Received: from [192.168.2.52] (94.red-88-14-213.dynamicip.rima-tde.net. [88.14.213.94]) by smtp.gmail.com with ESMTPSA id l7-20020a7bc447000000b003dafa04ecc4sm6534869wmi.6.2023.01.21.17.28.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Jan 2023 17:28:20 -0800 (PST) Subject: [PATCH v2 3/3] switch: reject if the branch is already checked out elsewhere (test) From: =?utf-8?q?Rub=C3=A9n_Justo?= To: Git List Cc: Junio C Hamano , Phillip Wood References: Message-ID: <1c98cbe8-8bca-e202-ef52-ce100307c7f3@gmail.com> Date: Sun, 22 Jan 2023 02:28:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since 5883034 (checkout: reject if the branch is already checked out elsewhere) in normal use, we do not allow multiple worktrees having the same checked out branch. A bug has recently been fixed that caused this to not work as expected. Let's add a test to notice if this changes in the future. Signed-off-by: Rubén Justo --- t/t2060-switch.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh index 5a7caf958c..7bea95dba2 100755 --- a/t/t2060-switch.sh +++ b/t/t2060-switch.sh @@ -146,4 +146,33 @@ test_expect_success 'tracking info copied with autoSetupMerge=inherit' ' test_cmp_config "" --default "" branch.main2.merge ' +test_expect_success 'switch back when temporarily detached and checked out elsewhere ' ' + test_when_finished " + git worktree remove wt1 && + git worktree remove wt2 && + git branch -d shared + git checkout - + " && + git checkout -b shared && + test_commit shared-first && + HASH1=$(git rev-parse --verify HEAD) && + test_commit shared-second && + test_commit shared-third && + HASH2=$(git rev-parse --verify HEAD) && + git worktree add wt1 -f shared && + git -C wt1 bisect start && + git -C wt1 bisect good $HASH1 && + git -C wt1 bisect bad $HASH2 && + git worktree add wt2 -f shared && + git -C wt2 bisect start && + git -C wt2 bisect good $HASH1 && + git -C wt2 bisect bad $HASH2 && + # we test in both worktrees to ensure that works + # as expected with "first" and "next" worktrees + test_must_fail git -C wt1 switch shared && + git -C wt1 switch --ignore-other-worktrees shared && + test_must_fail git -C wt2 switch shared && + git -C wt2 switch --ignore-other-worktrees shared +' + test_done