Article View: linux.kernel.git
Article #903Re: switch/checkout stops halfway when it fails to write tracking config
From: 井上司
Date: Tue, 20 Oct 2026 15:08
Date: Tue, 20 Oct 2026 15:08
52 lines
14079 bytes
14079 bytes
> I can see where create_branch() is called prior to setting up HEAD, > but I'm mildly confused about the index/wt updates prior to either! It > seems to me that should be one of the last steps, hm. Unfortunately, > I'm having a hard time finding the responsible code outside of the > "merge" case (which probably has a similar issue). - merge_working_tree() updates the worktree and the index. It is called from switch_branches() on every branch switch, not only with -m, because do_merge starts at 1. - The "merge" here is not -m. It is the 2-way merge in unpack_trees(). -m only adds an autostash step for when that 2-way merge fails. - The order is: update the worktree, create the ref, write the tracking config (which fails), then update HEAD. As you noticed, the worktree and index are updated before the ref and HEAD, so a failure later leaves those changes in place. - As you guessed, the -m case has the same problem. I tried "git switch -m -c y origin/main" with the lock present (v2.56.0 plus my hint patch, which only changes the hint text). It stops in the same place. If local changes conflict, HEAD stays on main, the file is left conflicted, and the changes remain in the stash. - Running the same command again in that conflicted state stops with "a branch named 'y' already exists". Switching to the existing branch y stops with "you need to resolve your current index first" (checkout.c:887 in v2.56.0). Neither run changes the state. 2026年10月20日(火) 22:07 D. Ben Knoble <ben.knoble@gmail.com>: > > On Mon, Oct 19, 2026 at 9:41 PM 井上司 <inoue.tsukasa.4@gmail.com> wrote: > > > > 5. Root cause > > update_refs_for_switch() -> create_branch() -> setup_tracking() fails to write > > the config, and the code calls exit(1) in setup_tracking() (branch.c). At that > > point the worktree and the branch have been changed, but HEAD has not. This > > exit was introduced in 27852b2c53 (branch: report errors in tracking branch > > setup, 2016-02-22). > > I can see where create_branch() is called prior to setting up HEAD, > but I'm mildly confused about the index/wt updates prior to either! It > seems to me that should be one of the last steps, hm. Unfortunately, > I'm having a hard time finding the responsible code outside of the > "merge" case (which probably has a similar issue). > > -- > D. Ben Knoble
Technical Details
Message-ID:
<CAP8tz2+CQcQyTdj3YFpEaiVh=hVoK5Xo8WFxGZNMJoCCM-u=hQ@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72545-linux-kernel-git=dewy.ruReferences:
<CAP8tz2JPXzq=Skokn4OtH8t6c3b+p1Wny1iX6AhXReUGvsBhuw@mail.gmail.com> <CALnO6CCFfd3VcZkFGmc6kYHqEwsafa7UbOg-6cN0jEfsipQm5Q@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72545-linux-kernel-git=dewy.ru
From: inoue.tsukasa.4@gmail.com (井上司)
Newsgroups: linux.kernel.git
Subject: Re: switch/checkout stops halfway when it fails to write tracking config
Date: Wed, 21 Oct 2026 00:08:51 +0900
Organization: Usenet Network
Message-ID: <CAP8tz2+CQcQyTdj3YFpEaiVh=hVoK5Xo8WFxGZNMJoCCM-u=hQ@mail.gmail.com>
References: <CAP8tz2JPXzq=Skokn4OtH8t6c3b+p1Wny1iX6AhXReUGvsBhuw@mail.gmail.com>
<CALnO6CCFfd3VcZkFGmc6kYHqEwsafa7UbOg-6cN0jEfsipQm5Q@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="3881042"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/95DVyf47XOoWZXt/g9ALZ6A9fU= sha256:QRwvrcQZgvbiJufIV70j1i0loUTW6zHp6q9ceLmt8mc=
sha1:1umOuhpc6NT21GeYtpH4KHYYLYU= sha256:RCv//5It9oLjgKnf+UFqsT7qoAkWt3Em/Rmc0uyBgQQ=
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 4110D110D47; Tue, 20 Oct 2026 18:17:29 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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.25,
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 nazeVcIHwupX;
Tue, 20 Oct 2026 18:17:26 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-72545-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 6ED58110D19; Tue, 20 Oct 2026 18:17:18 +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 76B2A65A67; Tue, 20 Oct 2026 15:09:06 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792508945;
b=rsWzzwPNQpatydpoST0N9sbZHpyHUdL0nnhbjlsB/PFJEhvBtJJGakLYZ7MjRgkekVh/
ozOXeiky15Ue5YZsuB2CKQjcgRzbbN1yeMCHxRA0yJJxRCXLIb6WVP6aeUTHf1Pyb7e/E
3fOZz7o1+hkBmtuVdyqb7PbNXBpM54SvfI108ruHVtTHMM7pzSEQcn0zcNHjDOIplvmsC
uWmD+hqSm7lox83VRj0HoGRhs8UeOCnhOrFswwACG+cdDy1j13GhJApdmGTusIYeDQtH2
oFNo5StK7JcF9Wl0UWS7g0EFt2R3qXXSl8eQ++J6ZAMwg5qq5WCdPrNpWcbbi+4En/A==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792508945;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:References:
In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=5XAdaylaVtZxLnOLnbf29eVFghnIc7Gz4uWxReNl69M=;
b=4CP6eOMGdefVqfgW10Z8DoJZd3wcgJIlVTH6089c0xF1uJdBResKmZHudsooLzoDTCZU
okT+4WgWP/bG621WylJoYyDYfFYv1OrKdHlUzxiNKAWUN4Ez1wlIh9t+LZ1gN9qYu5Mda
+usAgE9V2IKJ1SIuPwak9MO1kXDhay4wZZt6JYZFQENK8fpYNCAEEcaxO6lExZcWw5T2C
8PmiPHgAlbUWqSJoAOOJ2twyCfwvWcUqmnn7bg1jd+7vlOpo2YerSV7LPIye2ozGq0OPi
3/47XluyR48pC5MHdrXXZHpJ6arPqFZTVIqLHMYkYO/jUTkAMQTtXDsmTCliJM+KI/A==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Y+6FgKVn;
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 A9D1F606A329;
Tue, 20 Oct 2026 15:09:05 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Y+6FgKVn
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.222.182
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792508944;
b=fAsW8DIvPCUaEKD3350nZneLH0YpwbrqcYrJgcCbvvnd7u7z+yPG4QsfD9LubnWziv1Y
FUbu1s/+q7tIie9osBHixpU5rr5U1OZRYWPyRSd3w7s0ov3jo+YDtnmpLerg3SF6PoRcL
3VtgERn2WyuuhQrgy8+I+J7sPToXPK1EMhN8xcPP8TQLQ2MFFpd4xoG6HFfz7WblXRoAp
6yPlMG+Hbjtlq81uPDUgcZomiKA/yaZVj59n4qUBgI7+tIsnvINc0ZcI5iSWSs3f2zJgK
Xrd4OQZvIe1W2y/w3eLCc4IBnZ64GDrrMOk4c2n0f9MVQ0A3uS8Aeg8BjUxtqBZGEFg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792508944;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:MIME-Version:References:
In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=5XAdaylaVtZxLnOLnbf29eVFghnIc7Gz4uWxReNl69M=;
b=gpMoi0ro1YYPzmjhmpaBfc2DyrMI0z7DqSyQmN8gBUFo+8+vLoZRBVhQLIlmR5pP7Cet
UEUgpI0HYInw+UoNUZ+aRooxDYt00io9ysX7P9TyPcZvB2uQVkGg+e3YDDHe88q3xyTyh
0mzTe8pjq9ZwvK1XO41zzGaaQVgoqhSzTqjz2C5r6ggqO+NhX5WHo64eLq2vXzv0Mjqrj
u0vjvNR5ZFk7eOwQ9ndgmyy5nLbSDt++W2JuIsHgOl5pXZ/Vlh1arxezpkcqcoh8T7pa2
Hg7QSE9n7qCVKxF+wrDhXlJjHjz+rY9HxrNtAM9voBveEPhnTkuopFShmi8SWrHyB5A==
X-ARC-Authentication-Results: i=2; 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=20251104 header.b=Y+6FgKVn;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.222.182
X-Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182])
(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 80233606A325
for <git@vger.kernel.org>; Tue, 20 Oct 2026 15:09:04 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 80233606A325
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-qk1-f182.google.com with SMTP id af79cd13be357-93e56efa2e9so51551985a.1
for <git@vger.kernel.org>; Tue, 20 Oct 2026 08:09:04 -0700 (PDT)
X-ARC-Seal: i=1; a=rsa-sha256; t=1792508943; cv=none;
d=google.com; s=arc-20260327;
b=Qdnf074sVL3qQSvQwhDf0jIu2VfTouEWBdZOdR9x2u6FW6O7CVlef/TpjPoAQ/ACtV
Q+O3EsVBZX3t6kdNPz2gDGVaTqR8ATSv0kHRQCa6/hgKKfV8IJ3efzbEamBV+lG4+3nB
dYwmk1JjiYtthAOh7Hj06OEbqXCsxzXfNYIb5W8c8BJZCXgTzGtJBUVf6deotjQmhTdp
UBgCHcCSArw+jCEULFetEg7VXfbOIqNa4FyEAf4Sc14oGht6PPIbG48OTbBwANIa0Wll
riBlmzcw6JPeI42E+Ubv4iAvTmQabPtH93tOEY2b4gp5duFvEloX6i0vaW9GXg7LP6Gj
3arA==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=5XAdaylaVtZxLnOLnbf29eVFghnIc7Gz4uWxReNl69M=;
fh=o5l0Eu0aYVhYLNaknXG9Bd9QW+Oip/V1pdMxWtUugbA=;
b=hrpIKD8YhVblkeoQeKaf1PIcJppy8iE9wuhJzvP7zLsaUgZldqQuNiiQ25ixJ4wpL5
7hFLkJPxcYaymlGfnrnttsIOetwVjUtONC52ZOcjE6cv0G4HSDUIS5vk8DcvAH3zafPt
oTeEhv4xYAiox9nl0Pl72IttqxNjFuQIyP4Sju64KF1GJ+1xDH1zhjFnlkSytej1qDPg
rhig9FVLkWqnUA+JWJMUeg2IJXVRW9uLpu/WGJZs++wAaj/ZAWH+PdSjhJ5HgBKqjb+w
BH5kPJPYbFmUKmMcjWxlONaa7jtiU7DuCFl1dW/C3Hro5xUHt7a6/1nXT+GP0UFp4ey9
COOQ==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792508943; x=1793113743; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=5XAdaylaVtZxLnOLnbf29eVFghnIc7Gz4uWxReNl69M=;
b=Y+6FgKVn+u+xY7xeZpkTdxhiGouffT0v/TcoZj4y9iDxYkMt0NW2nyAYkLeEa/3KQ4
oPVh79nCQXDHeGQx/fGRmPdVIDby4nyULjPGNgbK754YfkUzfN+SNDkSyD8RARjdd07v
veoLE6qMztoyvMeE+lsHdXytQH1mNAnUiaXhRpbDig1J3lKd/EXDUmQHIcCfuQ19AfLd
nVvQ5KFk6a9tHF0LhutPvkCXYnTmznEMGN0lUGgEN4YavkRZFTZ85CEvxVCHfr3hOqIi
1qnp+PnF3DzMlTdss2gxwXR+9vccBgpUfeHh6acskR/w84R2wAmrg5hzFKcSvQwhWkoo
OeWw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792508943; x=1793113743;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=5XAdaylaVtZxLnOLnbf29eVFghnIc7Gz4uWxReNl69M=;
b=dsPumU16hwM7FVADv+D/SeOL/VUxERFeYyIEc4jUnDF3CYTU47/JSEvOFe/Cgk07Xq
4u2hqC4HUKEanGzeKy1m6kASmil+KxTnYfPU+/IElesHNsGNI8Xhf4npFHwYxOrVM7dD
1Wm58uvTlKvDgpk4IY//vOo71VNLl83n8IJ+0zbb99WSN2HTBbPp/7MLQ2M9Ux1JRECI
geEeELRg94jd9+r+LhtJYngJYJqbEXpPUAxuXlJl4MB0J4DbJ+8IBt+fbnx87q6PNbu+
sWOJusGDoLvHLaKFbJSvGS6Prh9xaBd7ato/m6HvQbUtTF5ZzYz03H+DMl5wSS/+rtXg
6PAw==
X-Gm-Message-State: AFq9FYLxUYKTpM3E2a7tfdW4xcl6IGuYYDobgRWYrUYWWlKs1T64q9+h
A14Z2bhqS5Ndd8JxXd8gB7+0DG1AO8f3c75jSMeJ2twHtGkd2wDW+7FAnIjxGnVNQytomOrJ0uK
RlkAYthk6CsEORWMU5Wxrn+/KfXBeCC0=
X-Gm-Gg: AYBFou3OaFCnXJhmfDLEgjFQXZ3FsFQjONJ2JzyVAqQ4DFyl4ax+qTqs5ZV66a98RfP
kcDUyw4Asg1FtOawu72iaXqZlKt7puRE8GP8bTs5DEj8/IfN+VnIkUIPjMBAern3Iu9OZ9IqoU+
EesqsXoX9rVSrEcWvZgzGtDweQy0cuoa7O12YnPzkWZflpd6SL9/lJKKUhNYqnkAaczyfunupzh
KaKmDxbx+mmhtF5/ZoRjatZQ7iKB8VHD0qPnth3XbjXGpxmd+gHhAmZredCXi9bC+CGtbLhvJuM
xm6HBsnxsduueZ4TSJiGjCgqVuw5krIbVNYjTs3F5hNUarqjF0B+7beTEJsMg+y1
X-Received: by 2002:a05:620a:4452:b0:93a:14c:329c with SMTP id
af79cd13be357-93f29b38f59mr2080531885a.1.1792508943339; Tue, 20 Oct 2026
08:09:03 -0700 (PDT)
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-In-Reply-To: <CALnO6CCFfd3VcZkFGmc6kYHqEwsafa7UbOg-6cN0jEfsipQm5Q@mail.gmail.com>
X-Gm-Features: AclHuK9nc0h8kj0gCao7e_T-U19nJMVA1hyBpYnS_JylA7afiLVcYJWsaKe-rtQ
X-Cc: git@vger.kernel.org