feat(switch): accept revset arguments, and explicitly support - shorthand#1463
Merged
claytonrcarter merged 4 commits intoarxanas:masterfrom Feb 24, 2025
Merged
Conversation
5cc1b7a to
df58ccf
Compare
df58ccf to
72fab57
Compare
arxanas
approved these changes
Jan 8, 2025
Owner
arxanas
left a comment
There was a problem hiding this comment.
Thanks! Both of these issues have bothered me personally as well.
45bc173 to
85d3df3
Compare
Collaborator
Author
Thanks for the review! I've updated my change, and I'll park this here for a few days while I continue using it locally in case I missed anything. |
85d3df3 to
18d3963
Compare
Collaborator
Author
|
This has been working fine for me. Let's see what everyone else thinks of it. 😄 |
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.
This updated
git switchto accept a revset as it's argument, and also to support-(to checkout previously checked out branch/commit) by passing it through to git.The revset parameter must evaluate to a set with a single head, and I've found this handy in cases like
current(...)to move to the latest version of a commit if I had an old smartlog or SHA still on screen or such, and alsoswitch foo:for when I have a branch ref handy but I really want to checkout the latest detached commit in that stack.But with revset support added,
switch -broke because it looked a poorly formed revset:The last commit in this stack adds an explicit check for
-so that this support is restored.Apparently,
revparse_single()inlibgit2doesn't support this. ~~I didn't patch-support intorepo.revparse_single_commit()but I'm thinking as I write this that perhaps that may be better? There is already a special case in that function to work around anotherlibgit2issue, and I suppose we could detect if the passed spec is-and then pass@{-1}torevparse_single()instead. 🤔 ~~ edit I made this change and it seems to be working.