All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tsukasa-ino via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Harald Nordgren <haraldnordgren@gmail.com>,
	tsukasa-ino <inoue.tsukasa.4@gmail.com>
Subject: [PATCH 0/2] checkout: finish switch when tracking config cannot be written
Date: Thu, 22 Oct 2026 02:51:33 +0000	[thread overview]
Message-ID: <pull.2275.git.1792637495.gitgitgadget@gmail.com> (raw)

When the tracking config cannot be written (for example, because
.git/config.lock exists), git switch -c and checkout -b stop halfway. The
worktree, the index and the new branch ref are already updated, but HEAD
stays on the old branch, and the changes are left staged.

 * 1/2 makes setup_tracking() return an error instead of calling exit(). No
   behavior change yet.
 * 2/2 makes switch and checkout finish the switch and exit with status 0,
   as push -u, clone and fetch already do. git branch still fails.

These patches were first sent as part of v2 of a series that also fixed the
hint
(https://lore.kernel.org/git/pull.2268.v2.git.1792618518.gitgitgadget@gmail.com/).
Junio asked whether they can be treated separately from the hint fix
(https://lore.kernel.org/git/xmqq7bjalmpt.fsf@gitster.g/), and I replied
that they can
(https://lore.kernel.org/git/CAP8tz2KOXHLjc5V1o1tZZWSsgOjVrp-ekH7H5KszBGK+hRqwrg@mail.gmail.com/).
The direction was agreed in the bug report thread
(https://lore.kernel.org/git/xmqqecdjsryk.fsf@gitster.g/).

Making the switch fully atomic, so that a failure undoes the worktree, the
index, the ref and the config, is left for a separate topic.

tsukasa inoue (2):
  branch: return an error from setup_tracking()
  checkout: finish switching when the tracking config cannot be written

 branch.c                  | 35 +++++++++++++++++++++--------------
 branch.h                  | 21 +++++++++++++--------
 builtin/branch.c          | 17 ++++++++++++-----
 builtin/checkout.c        |  6 ++++++
 t/t2027-checkout-track.sh | 20 ++++++++++++++++++++
 t/t2060-switch.sh         | 20 ++++++++++++++++++++
 t/t3200-branch.sh         | 13 +++++++++++++
 7 files changed, 105 insertions(+), 27 deletions(-)


base-commit: 47fdf2208c5b94c8cc01c106b8f7c85efb91c926
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2275%2FtsukasaI%2Ffix%2Fcheckout-tracking-config-failure-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2275/tsukasaI/fix/checkout-tracking-config-failure-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2275
-- 
gitgitgadget

             reply	other threads:[~2026-10-22  2:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  2:51 tsukasa-ino via GitGitGadget [this message]
2026-10-22  2:51 ` [PATCH 1/2] branch: return an error from setup_tracking() tsukasa inoue via GitGitGadget
2026-10-22  2:51 ` [PATCH 2/2] checkout: finish switching when the tracking config cannot be written tsukasa inoue via GitGitGadget
2026-10-23 18:30 ` [PATCH 0/2] checkout: finish switch when " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.2275.git.1792637495.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=haraldnordgren@gmail.com \
    --cc=inoue.tsukasa.4@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.