Repository navigation
Conversation
setup_tracking() calls exit(1) when it cannot write the tracking configuration. This exit was introduced in 27852b2 (branch: report errors in tracking branch setup, 2016-02-22). Because of it, callers cannot continue after a tracking failure, even though the ref has already been created. Change setup_tracking() to return an error instead of exiting, and make create_branch() and dwim_and_setup_tracking() return that value too. This does not change behavior. Callers still exit with status 1 on failure, as before. Changing checkout Signed-off-by: tsukasa inoue <inoue.tsukasa.4@gmail.com>
When git switch -c <new> <remote>/<branch> (or checkout -b) cannot write the tracking config, for example because .git/config.lock exists, the worktree, the index and the new branch ref have already been updated. Git then exits with status 1 while HEAD still points to the original branch. The changes of the switch remain staged, and the post-checkout hook does not run. create_branch() now returns an error instead of exiting. Make checkout ignore that error so that the switch completes and the command exits with status 0. The error and the hint are still printed. Match push -u, clone and fetch, which also print the error and continue. The upstream can be set later with the command shown in the hint. Keep git branch <new> <start> failing when the tracking config cannot be written, so its behavior does not change; t3200 covers this. Making the switch fully atomic, undoing the worktree, the index, the ref and the config when the tracking config fails, is a separate topic. Signed-off-by: tsukasa inoue <inoue.tsukasa.4@gmail.com>
Author
|
/submit |
|
Submitted as pull.2275.git.1792637495.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
No behavior change yet.
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.
cc: Harald Nordgren haraldnordgren@gmail.com