🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3665

Re: [PATCH] history: refuse to rewrite branches used by other worktrees

#3665
From: Aniket Gupta
Date: Mon, 23 Nov 2026 21:54
34 lines
11904 bytes
Thanks for taking a look!

> And is_bare_repository() is true.  We skip update_worktree() and
> update the 'main' branch via its HEAD, making the index and the
> worktree of the worktree at ../wt out of sync, no?

True. I am able to repro this. In a bare repo nobody has the branch that
HEAD points to checked out, but the check skips it as if the current
worktree did. So "git history drop" moves "main" and ../wt shows the
changes of the dropped commit as staged.

> Perhaps head_target should be initialized to NULL and assigned the
> resolution result of HEAD only in a non-bare repository, or something?

I think that would fix it. In v2 I'd like to go a bit further though:
ask the other worktrees if they use the current branch instead of
skipping it by name. That also covers a bare repo and a branch that two
worktrees have checked out with "git worktree add --force". Will add
tests for both.

> I didn't trace all other callers, so there may be other glitches I
> did not notice.

Went through them. fixup, reword, split, squash, drop all call
setup_revwalk() before they open an editor, create a commit or update a
ref so they refuse early. Will add a test that runs each of them.

> It probably is also worth noting in
> the log message that 'drop' updates the worktree while 'reword',
> 'split', and 'squash' preserve the tip tree and 'fixup' incorporates
> staged changes from the index.

Point taken. Will fix the log message and add that.
Technical Details
Message-ID: <20261123215424.27553-1-aniketgupta3001@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76178-linux-kernel-git=dewy.ru
References: <20261123103911.98860-1-aniketgupta3001@gmail.com> <xmqqa4mz5mr8.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76178-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] history: refuse to rewrite branches used by other worktrees
Date: Tue, 24 Nov 2026 03:24:24 +0530
Organization: Usenet Network
Message-ID: <20261123215424.27553-1-aniketgupta3001@gmail.com>
References: <20261123103911.98860-1-aniketgupta3001@gmail.com> <xmqqa4mz5mr8.fsf@gitster.g>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="3993175"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3zKXM57J+6/rSipHAXIjrQ2XeTo= sha256:b2S39SPm9Db3VDSkXmNbbsnqc5RBdYCeYRkc97GyYgM= sha1:K3dh6iXjRyC/n5OCGApMnKvrugw= sha256:xIUHUVFPyx+jJU0BU4ezgMzmWqlZYgBhX5QoL8p2bUc=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id EFD65125DC8; Tue, 24 Nov 2026 00:54:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TMe3Cyxz139q; Tue, 24 Nov 2026 00:54:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76178-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 0BC3C125DC3; Tue, 24 Nov 2026 00:54:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 2CAEC37FEE; Mon, 23 Nov 2026 21:54:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795470873; b=k8ng3MGbrAmUx6lBjFwfGD935ttariso0m1xEzC5MgznhIk9W0n16xD9N77c1ebWkYpi 1A8wwmE2no/We7PeQfAmw1/p7XLgokjs1uKweBFYCuEseLNT6EDk7BL17CPPT899F6qtv TqwCMl8b/51Jj9lVQod8dHW31JsYefm3/nekj2RjnKkrRUq+gSqUS/KKdaM69wZOyPQCN ixs7lrnG5hHms8vB6M+uOXK6tBiyGB5Fl3fcCFi3FB/nvCspRYAE7OQq+7UM6nlxZ3faJ rol1ZzEd0H+sQzHtuabQB3DA6O+4TfxRXn/B1U/x+EPLczHVZWgX1fvrH2Hi+iJfSdw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795470873; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=Df6LzVHjtICkQOYg0CyO4fBKg0KYwubLeqHz3IyJzzQ=; b=jT9tIPLSQ+8Rk3WT4086epzil1WbzUlqcXx81gcSW7p7/k158fgP6isv0Ab6YwCPsk+K eeoG5lKxqANp87qi0eUsHxwI1BmhDDbWMgfr7BrE63f9mOzf2xh7IYetag6dF29F0XjG4 /T+/p6rwvaPq3EQ8kMxLsXyG5MdBOzQVyDRSiPgV/uVYcndAwgwcHpF+71/M/0iIYBwT7 Dgy0cR8c88fKNRvnW+ix+fK7+VmnqnkWxkSCzVKUusap8ZgTLztzt5WY1XQHwt7QU5OLk JJuDlmKFhMM/QXzghm3sbRqsghgdsh17iVFWvfTer3g0vYPy0t2IjSMOf8mEtPIky7A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HKxj0OTG; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04053606A32D; Mon, 23 Nov 2026 21:54:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HKxj0OTG
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795470872; b=UNx30LDOlXsmrP206MUXhgXFyZSHezBzq47996M4EMTAUpFzhZfvRlFKYKVIBwtQJyth Ac7dp8kkTnhRuE5gcvu1kt2UR4I3Qw8h+wtNCPqgPzy1axPn+rjMLpnhp/BG6uV1EWVZd icsbnhYKbWVYf1LcxBMYs4l9WwANUfu3YY1qa+CEl0qNqryTj5DuMxM8rKIMmGEmrT0Bt a+eKu0zdsr3nokrP1bjTOxc0ebYlnchfPleNcmgr8NvI4fZXleEQqOx+oJKpywKMTaJbA xAwdSxN4YwguuCgA40/uUkzkwrvmNRsyDmuQhGTNvWWJi505ZWPCAAxt1nNa/bEEfbw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795470872; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Df6LzVHjtICkQOYg0CyO4fBKg0KYwubLeqHz3IyJzzQ=; b=hdy9kEwHYR8mNRG5DRmh93sPolNB1xOo5khF2COMJIp6XUMhBXt3ExP7QFSZTV1DhRij BNf0rcZxxQoT/6BP+EhksI7IQBmO4nxdUKIAu5a113ZMhJx7qBLMAGGWEka7qxUR9Zjhx 1qi9/0fT3k7bOprtVHr7fYedytX1yP9beyyCmlZ8q/NX1lUoTlYuEhg5cV6WRHxICscKt QVbZVuDRaAcKSy63M9yEnbf/YHhdUDa/9fndLXziUqIkrSGbB0YHkUGDkBVtZtSxJHxzZ xnsu/64eaNQUTv9XQgp9aA3cSDzQMkh1BTKRZ7WA5zdfnBPjovrCxMGs93Qu/k3KHmQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=HKxj0OTG; arc=none smtp.remote-ip=209.85.216.44
X-Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF69F606A31E for <git@vger.kernel.org>; Mon, 23 Nov 2026 21:54:31 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CF69F606A31E
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-3b40470fdd8so1819506a91.1 for <git@vger.kernel.org>; Mon, 23 Nov 2026 13:54:31 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795470871; x=1796075671; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Df6LzVHjtICkQOYg0CyO4fBKg0KYwubLeqHz3IyJzzQ=; b=HKxj0OTGkbvbrtHl51tGzQkH3jWeoYM6gC1qLIpZidRV+nswy2yPpzZBjHeQpoNI8R 7jwHCjWB6FJoKszfTZOgHqqhztlNw6aMrQlgjF10WHBKafwzQeXlW2ns+GO7WPC1s48B ziGMPn1zs4uV1ZHWDyIB6YR44en3JDdisS8gUDA7JsTM0MwggOSfIoOgFOPU4x9SCsD4 dkxGme24Zr/G/QMBtfbPuR+J/qnVlZighXuCL9kqSGVzNkG/DVd63RVsCaK4RhEBztuh j1/rLWgWNFz9R5//q9yF3cRKK+fcgvFVg+9qhshJdfGkA4O906L/2kOxRPLNI4Rdk0F5 +6ng==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795470871; x=1796075671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Df6LzVHjtICkQOYg0CyO4fBKg0KYwubLeqHz3IyJzzQ=; b=fraWFvLQ3RXlIbJERfmf2Syd4meNppNT4UUX/tYn2Wct7yd51q5zNIWh8/xwIcYwju MjAIhX+8rJboMjN71W7ZvFvJGiS4Pq4tNd4uCLPb4OFEOnWUI7jHFtmc8czQrIpCOwYF Vn1gIQTG1JLcrWOThcfrfVPEkJ5eaVVRt/Itf4zQVvaXlJRXw8k7yV7Rd/d+Hj8mzoRS MeK5FvybCuh9aGrENJFKw1k0Dt0YkxOp5PC4VxXjRMoRZhwFFSAanp6HzDugID4iGCCA FzPTGCt8wEFZmsfYkliXmJ35Ma2K6iBwvhIsby3M/7P3tw7uevk6AuNgDMMlAtChABro P85A==
X-Gm-Message-State: APuU4Z/aNDOprgxqWGtCubs0wqatiTmka9Cnc/MpY+xfOhvpIayIlpFG z36e06FJ+hs8bw0B4F/R8l6eT6Ks5e29NNxQnISzMWTmJJHNfiNXTNFpgCz+V/xN
X-Gm-Gg: AZFdTZcLKM8LaUIcMiaWbUU/FqqkE5zxjn8igQdTtWWVPGTAW2eFZJWbOn0HwG/C7Hj bg6/zhJsbK2wQ6//wFjyd7iRVczwL90AnFLN5kxl9hvegw2AZh/4L4qyhQVCiwus6AHNNNXmyyF CcV1cctxWFpldEeYpVjE+2c0Ys5nPCrYB/tUVBYQ5mmpYfhPOaYyhEws0j6C7s9oza6aDKitWmE EjAjOzdMCIpkodKuGU0byDeVNuQwoi3adJd6jqkKIQ/LPkKKoN25RCWnwMndHd4CH+tPj4OY51b jnz/4XexXtlcpSMckGvPCByIFZetBm3X6tNvwfnCtaH2JFkXhtAYnKp92sqhnkqr9hDPTPh3L80 i/o+DURzS25KBXn68nuqxUM5AQvXTUqHVrdNyDA69IaSyixFziwSHsqIkzVAzaRAmMAPWngp4Ny 61na93Y6rRAZ8OuLSxDSia8/aycoIIk3K6dZuwW7etg+gvEO10dTIkqSWsfryuEk2gV7K6cqCOs CF9RzBRwCnybmxec2U3dAhqYCIt/wIRc4wBQGUQE7N3DWIem2tqxNbXN4vVQr3KVdVlyJfeFeUg Xsyet4F9efWFgbqMI8u3qGxj0WT06zdeZQditIJhw8GRddJFldBBM3CIafWfJWAajlw2adG8Tkd dxqDuwPDzNm5FnsoK+ynOfcfHXBu2pCW14Zo3sFOBTr4=
X-Received: by 2002:a17:90b:224e:b0:3a0:d265:3647 with SMTP id 98e67ed59e1d1-3b41c7d6084mr10881246a91.8.1795470871078; Mon, 23 Nov 2026 13:54:31 -0800 (PST)
X-Received: from localhost.localdomain ([103.25.231.125]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b44b8c2fcesm6720472a91.4.2026.11.23.13.54.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 23 Nov 2026 13:54:30 -0800 (PST)
X-Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>, Toon Claes <toon@iotcl.com>, Phillip Wood <phillip.wood@dunelm.org.uk>, Nikita Bobko <nikita@nbobko.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <xmqqa4mz5mr8.fsf@gitster.g>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Received-Bytes: 11649