-
Notifications
You must be signed in to change notification settings - Fork 165
checkout: don't revert file on ambiguous tracking branches #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
checkout: don't revert file on ambiguous tracking branches #504
Conversation
This is done for the next commit to avoid crazy 7x tab code padding. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
For easier understanding, here are the existing good scenarios:
1) Have *no* file 'foo', *no* local branch 'foo' and a *single*
remote branch 'foo'
2) `git checkout foo` will create local branch foo, see [1]
and
1) Have *a* file 'foo', *no* local branch 'foo' and a *single*
remote branch 'foo'
2) `git checkout foo` will complain, see [3]
This patch prevents the following scenario:
1) Have *a* file 'foo', *no* local branch 'foo' and *multiple*
remote branches 'foo'
2) `git checkout foo` will successfully... revert contents of
file `foo`!
That is, adding another remote suddenly changes behavior significantly,
which is a surprise at best and could go unnoticed by user at worst.
Please see [3] which gives some real world complaints.
To my understanding, fix in [3] overlooked the case of multiple remotes,
and the whole behavior of falling back to reverting file was never
intended:
[1] introduces the unexpected behavior. Before, there was fallback
from not-a-ref to pathspec. This is reasonable fallback. After, there
is another fallback from ambiguous-remote to pathspec. I understand
that it was a copy&paste oversight.
[2] noticed the unexpected behavior but chose to semi-document it
instead of forbidding, because the goal of the patch series was
focused on something else.
[3] adds `die()` when there is ambiguity between branch and file. The
case of multiple tracking branches is seemingly overlooked.
The new behavior: if there is no local branch and multiple remote
candidates, just die() and don't try reverting file whether it
exists (prevents surprise) or not (improves error message).
[1] Commit 70c9ac2 ("DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"" 2009-10-18)
https://public-inbox.org/git/7vaazpxha4.fsf_-_@alter.siamese.dyndns.org/
[2] Commit ad8d510 ("checkout: add advice for ambiguous "checkout <branch>"", 2018-06-05)
https://public-inbox.org/git/20180502105452.17583-1-avarab@gmail.com/
[3] Commit be4908f ("checkout: disambiguate dwim tracking branches and local files", 2018-11-13)
https://public-inbox.org/git/20181110120707.25846-1-pclouds@gmail.com/
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
|
/submit |
|
Submitted as pull.504.git.1577731093.gitgitgadget@gmail.com |
|
This branch is now known as |
|
This patch series was integrated into pu via git@1ed3ace. |
|
This patch series was integrated into pu via git@3aca945. |
|
This patch series was integrated into pu via git@15da7d4. |
|
This patch series was integrated into pu via git@ea598e5. |
|
This patch series was integrated into pu via git@8b7ad33. |
|
This patch series was integrated into pu via git@dda7344. |
|
This patch series was integrated into pu via git@386ba44. |
|
This patch series was integrated into pu via git@fa531ec. |
|
This patch series was integrated into pu via git@b0a137d. |
|
This patch series was integrated into pu via git@a8e7cd6. |
|
This patch series was integrated into pu via git@4958d71. |
|
This patch series was integrated into pu via git@25f1c9b. |
|
This patch series was integrated into pu via git@f3c06eb. |
|
This patch series was integrated into pu via git@ea59758. |
|
This patch series was integrated into pu via git@38c67b9. |
|
This patch series was integrated into next via git@daf1dad. |
|
This patch series was integrated into pu via git@6b09d00. |
|
This patch series was integrated into pu via git@d0e70cd. |
|
This patch series was integrated into next via git@d0e70cd. |
|
This patch series was integrated into master via git@d0e70cd. |
|
Closed via d0e70cd. |
Uh oh!
There was an error while loading. Please reload this page.