Update BASH completions
cover Update BASH completions
While playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.
Paul Wagland (2):
Update the flags for git show-branch
Fix up the arguments for git stash. This adds the branch to the branch
subcommand, and adds the missing options to save and drop commands
contrib/completion/git-completion.bash | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
--
2.7.0
PATCH 1/2] Update the flags for git show-branch
--- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
@@ -2369,7 +2369,7 @@ _git_show_branch () case "$cur" in --*) __gitcomp " - --all --remotes --topo-order --current --more= + --all --remotes --topo-order --date-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog
--
2.7.0
Re: PATCH 1/2] Update the flags for git show-branch
Thanks. I'll retitle this to
completion: complete show-branch "--date-order"
while queuing.
PATCH 2/2 Fix up the arguments for git stash.
In reply to Paul Wagland--- contrib/completion/git-completion.bash | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +14 -3
@@ -2382,7 +2382,7 @@ _git_show_branch () _git_stash () { - local save_opts='--keep-index --no-keep-index --quiet --patch' + local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash () apply,--*|pop,--*) __gitcomp "--index --quiet" ;; - show,--*|drop,--*|branch,--*) + drop,--*) + __gitcomp "--quiet" ;; - show,*|apply,*|drop,*|pop,*|branch,*) + show,--*|branch,--*) + ;; + branch,*) + if [ $cword -eq 3 ]; then + __gitcomp_nl "$(__git_refs)"; + else + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + fi + ;; + show,*|apply,*|drop,*|pop,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;;
Signature · 1 line
2.7.0
Re: [PATCH 2/2] Fix up the arguments for git stash.
Quoted 2 lines · Paul Wagland
Signed-off-by Paul Wagland <[email protected]>---
This needs a better explanation than just "Fix up" in the title. What is broken in the current behaviour and what is the more desired behaviour?
Thanks.
Quoted 39 lines
contrib/completion/git-completion.bash | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)contrib/completion/git-completion.bash +14
-3@@ -2382,7 +2382,7 @@ _git_show_branch () _git_stash () { - local save_opts='--keep-index --no-keep-index --quiet --patch' + local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then@@ -2404,9 +2404,20 @@ _git_stash () apply,--*|pop,--*) __gitcomp "--index --quiet" ;; - show,--*|drop,--*|branch,--*) + drop,--*) + __gitcomp "--quiet" ;; - show,*|apply,*|drop,*|pop,*|branch,*) + show,--*|branch,--*) + ;; + branch,*) + if [ $cword -eq 3 ]; then + __gitcomp_nl "$(__git_refs)"; + else + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + fi + ;; + show,*|apply,*|drop,*|pop,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;;
Re: [PATCH 2/2] Fix up the arguments for git stash.
Fair enough. I'll re-roll the patches with improved comments, and get these out to the list today.
Cheers,
Paul
Sent from my iPhone
Quoted 12 lines · Junio C Hamano
Quoted 2 lines · Paul Wagland
Signed-off-by Paul Wagland <[email protected]>---
This needs a better explanation than just "Fix up" in the title. What is broken in the current behaviour and what is the more desired behaviour?
Thanks.
v2 cover Update BASH completions
In reply to Paul WaglandWhile playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.
This re-roll doesn't change the code, but updates the commit comments to make it clearer what each change is doing.
Paul Wagland (2):
Update the flags for git show-branch
Fix up the arguments for git stash. This adds the branch to the branch
subcommand, and adds the missing options to save and drop commands
contrib/completion/git-completion.bash | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
--
2.7.0
PATCH v2 1/2 completion: complete show-branch "--date-order"
--- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/completion/git-completion.bash +1 -1
@@ -2369,7 +2369,7 @@ _git_show_branch () case "$cur" in --*) __gitcomp " - --all --remotes --topo-order --current --more= + --all --remotes --topo-order --date-order --current --more= --list --independent --merge-base --no-name --color --no-color --sha1-name --sparse --topics --reflog
Signature · 1 line
2.7.0
PATCH v2 2/4 completion: update completion arguments for stash
In reply to Paul WaglandAdd --all and --include-untracked to the git stash save completions. Add --quiet to the git stash drop completions.
Update git stash branch so that the first argument expands out to the possible branch names, and the other arguments expand to the stash names.
--- contrib/completion/git-completion.bash | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
contrib/completion/git-completion.bash +14 -3
@@ -2382,7 +2382,7 @@ _git_show_branch () _git_stash () { - local save_opts='--keep-index --no-keep-index --quiet --patch' + local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local subcommands='save list show apply clear drop pop create branch' local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash () apply,--*|pop,--*) __gitcomp "--index --quiet" ;; - show,--*|drop,--*|branch,--*) + drop,--*) + __gitcomp "--quiet" ;; - show,*|apply,*|drop,*|pop,*|branch,*) + show,--*|branch,--*) + ;; + branch,*) + if [ $cword -eq 3 ]; then + __gitcomp_nl "$(__git_refs)"; + else + __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ + | sed -n -e 's/:.*//p')" + fi + ;; + show,*|apply,*|drop,*|pop,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;;
Signature · 1 line
2.7.0
PATCH 1/1 completion: fix mis-indentation in _git_stash()
--- contrib/completion/git-completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
contrib/completion/git-completion.bash +2 -2
@@ -2415,8 +2415,8 @@ _git_stash () show,--*|branch,--*) ;; branch,*) - if [ $cword -eq 3 ]; then - __gitcomp_nl "$(__git_refs)"; + if [ $cword -eq 3 ]; then + __gitcomp_nl "$(__git_refs)"; else __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')"
Signature · 1 line
2.7.1.384.g61d9461