From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796143061; b=iekx5JmmCoogXNUqgpAA+qK0WuLf5cV/tHHMAYlC4dt2nmT7+DDNT1sr8Jev/rrpzvMf uDvSPneRtFoGsvTztandQ6eO56EbTgRIYDewzi7u+wN0lkFEcKuoAhX58vSgv315918Dz QjmTzXgSLJcdwlbao+zLW1WyJS7M3mYHeFeMuK7qOyy9vrbzy0CNaG4GyqgshgiXPs1Fa RV1uJ4amGAc578V/Cnq/V3RJ5CaPF89QHvO+20hRcACiLs2sefqpLwch0NT5FNPcZBH1C owHvRcyexwwNLnbYGvWdpAFgGi8Q8qoEWb5acjSf/Kj3lOcYI2BIGVV9q3BIr9B0WYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796143061; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date: MIME-Version:User-Agent:From:Reply-To:Subject:To:Cc:References: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=XAoMeRl62ZhJR1Q1n2YdjuK4i/U4c0fFm587kkVLhlY=; b=xK1qj2bo0fl2VYKmyqEH48hpL3HLahiqj+Mb5Ox+6gRJT9UUyESkscIlbQ+VL5kSk67l U/TLTTc1AUUjD49S2NXkSICHVzHooVtYMOiM8f3lEnVtbiry5dJ1VwI34hSmyEkJ0j2QT 3ZrC2ngD4m4oJI6sIC2EDs5shvcD2V0ZyK6+L5CMZgyf1LX88XfHPZ8uA+CkUv6rdml0t LJPBv1850dMLWaRMKorunb30eFaIchrwdsAsL4Aal9VD1JUxfCfwbCZW5d4HBP4E9kMJz 838IyIlaFAylLlfNMQ++9YkkCiOc/xmi7jPAyFoq5jqArz9lBSgEwoHArmEq0LiccSA== 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=TIoIZGoR; arc=none smtp.remote-ip=209.85.221.46 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 BA4C7606A322 for ; Tue, 1 Dec 2026 16:37:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BA4C7606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=TIoIZGoR Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-48dee593f18so11465591f8f.3 for ; Tue, 01 Dec 2026 08:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796143059; x=1796747859; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:subject:reply-to:from:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XAoMeRl62ZhJR1Q1n2YdjuK4i/U4c0fFm587kkVLhlY=; b=TIoIZGoRkzgKXvZWF8a1EvyIcME1LIfTzRUyDbaVK4VB/bhOsdBwUBcNFcbrFwm/TF a/ueTayg3+rdpy6OHKRGbtyY9NUfqQpgAK4kHSCm8JhT4KRvWxT9u2+6TQ1tBb7lFuHa X8a4fa21AWUXsc9eD4/ruPIueBq2Gw8MZXA2ZC1oRxxgufpb3aVa1v1JI3JCWIVgu6Pw nFTf4jNHklq3OOvbh6ijupkObOJgHiMih55Gj1TEBn8QmW3b/W6M+rM/qnHSci3Lsfh4 3Ck9iSoUpNeRmFb24amuCdYWlFsUD7VPnjoJoFJt1bdQyGf2mSmmkcSoko5tGsMHUrhx /MNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796143059; x=1796747859; h=content-transfer-encoding:content-type:in-reply-to:content-language :references:cc:to:subject:reply-to:from:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XAoMeRl62ZhJR1Q1n2YdjuK4i/U4c0fFm587kkVLhlY=; b=0/qk0VX2OVXn1DlAC//Irwdw/NtO9ZLlpWCr6nrlurcjc1bZLS1BgfEX5PGT7MMhvF EvbGhdbvPKu34NFQrxNg6kgnE1qBQzzFYCmNOnGEmVIhtVF8/Jnukb4bglmHwGF/3RJb LVSqIhAzBFm5+9J+XtF0bizkDAOmxcVMO4D9KpC4my7qwfu4VTgfu2GaLctYVH9mWQWN 77B/fdU5sutVI8U6rz/kWYTTV0koYY96x0L4KGg20uKLZ+QS9p3MgzP7NCI20k5yBLmY WwGZnsuogq+3OBzwwKPmN/+qSh/f7gbBzg6ApuH/8Cb4xapXaKTIQwJmKgHWPsHBD1s9 674Q== X-Gm-Message-State: APuU4Z+Vk3aTx7FsB00xb5SkqweabYiY1TqZND70wv5XWnFUi5LlG2U9 ViWg8Mqjo7+YLsnSWio6ISxwbnNU7aDtsfQcEg2/jWDaGfNiElTg1Wpk X-Gm-Gg: AZFdTZco7HXheWU0M+Fdm6DlTudWeyiBwOKCvABLGEM1ssQMFqSZPUsLukKMT7W8/xv Rh5WttXcNkCpW53gcTlBhstuH37FhhC8NITHkF1JZjXZ4lSAF6Z0aqsr130X4RQUVVV7udfcG8V 3fid/Vn7iPuKb46NPeYzczkdL0yv39sdIx1eHdmFDgP0JCXstJlQd4rhPwpwXNnAQtQgaoVOCYz 41K69u4crFdDhgl3KvT9Ri1GEfrplseFNqyepFVcCMHtBkahyEpiD5grhEWOH37UjUBOLKHAxMs oHOzvha7k1UQyWNGH4k2nxdVM2xhRqynMy4zp7dEklaRbE2X8bxVtijn7OMBA4pCbGuXdrSRIza PUVRWsMf92UEQuduUQzObsmcStOl8Ft3Gsx0/QCxrnRJs1U0hXKFbkxBn42ts/ZqGxH0dc12Ze0 TViW38UJZamJoWv15vQPOUKNXSIBxNyElrQ2/eGYfWOhsfLKSru3Bl/FIkA4oOp5Latj+1TQKeR KmD54FS84VPYuMjUQT2yjXMbol/JUwDwH1a9xALnSRz92aPjrOF/0D/GrW6k9cKSbAHerkcn3N3 aLRToPs83UrZgENSTB012bpPL8RzMC0OTaLlM46G8fTZ54BY6PeB8iyiDxiX2lX7kTmdkKk/CXt zJI3PnIg= X-Received: by 2002:a05:600c:64c8:b0:4bb:6848:d433 with SMTP id 5b1f17b1804b1-4bb8881d141mr711852815e9.26.1796143058841; Tue, 01 Dec 2026 08:37:38 -0800 (PST) Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb906d6a13sm624617125e9.3.2026.12.01.08.37.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 08:37:38 -0800 (PST) Message-ID: <3d2e9653-87ce-48f4-a154-2b5a1a31a84c@gmail.com> Date: Tue, 1 Dec 2026 16:37:37 +0000 X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Phillip Wood Reply-To: phillip.wood@dunelm.org.uk Subject: Re: [PATCH v2] history: refuse to rewrite branches used by other worktrees To: Patrick Steinhardt , Aniket Gupta Cc: git@vger.kernel.org, Toon Claes , Junio C Hamano , Nikita Bobko References: <20261123103911.98860-1-aniketgupta3001@gmail.com> <20261127173252.7794-1-aniketgupta3001@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Patrick On 01/12/2026 13:18, Patrick Steinhardt wrote: > > I'm probably missing something, but the way we handle `head_target` > seems weird to me. It is getting resolved to whatever we have checked > out in the current worktree. But do we even care about whether the > currently checked out branch is used anywhere else? It's confusing if HEAD gets updated in one worktree because a branch was rewritten in a different worktree. That's why we have checks in "git rebase" to avoid rewriting branches that are checked out in other worktrees. > What I would have expected us to do is that we take the list of pending > ref updates that we compute in `handle_reference_updates()` and verify > that none of those refs that we're updating is checked out or being > rebased/bisected. But as far as I can see, this check here comes before > we have even computed those ref updates in the first place. We need to do the check before rewriting so that a user running "git history reword" does not spend time editing the commit message, only for us to refuse to update any refs. > So we're verifying the pre-rewrite state, not the state after already > having performed the history rewrite where the ref updates are now > pending. And consequently, I think we don't reject some updates that may > happen in worktrees. Ideally we'd find all the branches that we want to rewrite, write those to "$GIT_DIR/history/ref-updates", then walk all the other worktrees checking which branch is checked out, being rebased etc. and read each worktree's "$GIT_DIR/history/ref-updates" to see if there is an active "git history" command rewriting the same branch. If a branch that we want to rewrite is being rewritten by a command running in another worktree we'd remove "$GIT_DIR/history/ref-updates" and error out. "git checkout", "git rebase" etc. would also check "$GIT_DIR/history/ref-updates" as well. By writing the list of refs we want to update before checking if any other worktree is updating them and removing the file after we've rewritten them, I think we avoid races where two commands started at the same time try and update the same branch. I don't think we necessarily need to implement that all at once though, the checks added in this patch are a good first step. Thanks Phillip > But even if we detected all of them, we would now be racy as we should > perform the validation at the point in time where we have already > gathered expected old and new commit IDs for the ref updates, shouldn't > we? > > I may be missing something very obvious, but I think as-is these checks > are somewhat broken? > > Thanks! > > Patrick