Re: [PATCH] completion: complete modified files for checkout with '--'
On 02/14/2017 01:50 AM, SZEDER Gábor wrote: > On Tue, Feb 14, 2017 at 12:33 AM, wrote: >> From: Cornelius Weig >> >> The command line completion for git-checkout bails out when seeing '--' >> as an isolated argument. For git-checkout this signifies the start of a >> list of files which are to be checked out. Checkout of files makes only >> sense for modified files, > > No, there is e.g. 'git checkout that-branch this-path', too. Very true. Thanks for prodding me to this palpable oversight. My error was to aim for a small improvement. I think the correct approach is to improve the overall completion of git-checkout. IMHO it is a completion bug that after giving a ref, completion will still offer refs, e.g. $ git checkout HEAD --> list of refs As far as I can see, giving two refs to checkout is always an error. The correct behavior in the example above would be to offer paths instead. I'll follow up with an improved version which considers these cases.
Re: [PATCH] completion: complete modified files for checkout with '--'
On Tue, Feb 14, 2017 at 12:33 AM, wrote: > From: Cornelius Weig > > The command line completion for git-checkout bails out when seeing '--' > as an isolated argument. For git-checkout this signifies the start of a > list of files which are to be checked out. Checkout of files makes only > sense for modified files, No, there is e.g. 'git checkout that-branch this-path', too. > therefore completion can be a bit smarter: > Instead of bailing out, offer modified files for completion. > > Signed-off-by: Cornelius Weig > --- > contrib/completion/git-completion.bash | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/contrib/completion/git-completion.bash > b/contrib/completion/git-completion.bash > index 6c6e1c7..d6523fd 100644 > --- a/contrib/completion/git-completion.bash > +++ b/contrib/completion/git-completion.bash > @@ -1059,7 +1059,10 @@ _git_bundle () > > _git_checkout () > { > - __git_has_doubledash && return > + __git_has_doubledash && { > + __git_complete_index_file "--modified" > + return > + } > > case "$cur" in > --conflict=*) > -- > 2.10.2 >
[PATCH] completion: complete modified files for checkout with '--'
From: Cornelius Weig The command line completion for git-checkout bails out when seeing '--' as an isolated argument. For git-checkout this signifies the start of a list of files which are to be checked out. Checkout of files makes only sense for modified files, therefore completion can be a bit smarter: Instead of bailing out, offer modified files for completion. Signed-off-by: Cornelius Weig --- contrib/completion/git-completion.bash | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 6c6e1c7..d6523fd 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1059,7 +1059,10 @@ _git_bundle () _git_checkout () { - __git_has_doubledash && return + __git_has_doubledash && { + __git_complete_index_file "--modified" + return + } case "$cur" in --conflict=*) -- 2.10.2