Open dannoe opened 3 years ago
Finally revisiting this - absurdly belated thanks for the issue and PR! Pulling over https://github.com/dahlbyk/posh-git/pull/815#issuecomment-770280114 from @rkeithhill:
My one concern here is that folks used to doing
git checkout <tab>
via posh-git might be a bit surprised to see modified files showing up in the completion list. But if your intent is to switch branches you could usegit switch
AND it is less likely you'd switch branches when you have modified files.
I tend to agree that existing posh-git users might be surprised if paths started showing up where they're used to only seeing branches. Personally, my muscle memory is to explicitly add --
when I want to complete a path. That said, you're right that it's perfectly legal to omit --
unless it's ambiguous.
Tentative suggestions:
git checkout
and git reset
consistently completely only paths after --
. Currently git reset -- <tab>
completes branches/tags, which is incorrect.git reset
probably shouldn't be limited to HEAD
. https://github.com/dahlbyk/posh-git/blob/dc2b6367324a9db79db55186375462a454f29c2e/src/GitTabExpansion.ps1#L404$GitTabSettings.DoubleDashOptional
or equivalent (name suggestions?) to allow opting in to including paths from status
without --
. It seems reasonable to me that we would give refs priority over paths, i.e. the path-without---
cases would be added after the ref cases in the switch -regex
.Since I proposed and added this PR I didn't use it a single time in my local version. Feel free to choose one of the suggestions or even close this issue (maybe until someone else needs the feature). Sorry for wasting your time and the late response.
I leave the issue open, so you can decide what you want to do with it.
The git manual page also states the "--" are optional for git checkout:
https://git-scm.com/docs/git-checkout
The path expansion for git reset does also work with and without "--".