Skip to contentSkip to conversation

bash completion: more porcelain completions

PATCH In review Lee Marlow 4 participants 13 messages Jun 15, 2016

lore
Share & tools
lore

Lee Marlow

author
#0 lore raw

cover bash completion: more porcelain completions

This adds basic long option completion for some common commands that I use, as well as stash name completion.

Lee Marlow (8):
bash completion: Add completion for 'git clone' bash completion: Add completion for 'git clean' bash completion: Add completion for 'git init' bash completion: Add completion for 'git revert' bash completion: More completions for 'git stash' bash completion: Add completion for 'git archive' bash completion: Add completion for 'git ls-files' bash completion: Add completion for 'git mv'

 contrib/completion/git-completion.bash |  143 +++++++++++++++++++++++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 143 insertions(+), 2 deletions(-)
author
#1 lore raw

PATCH 1/8 bash completion: Add completion for 'git clone'

Added completions for all long options specified in the docs

	--local --no-hardlinks --shared --reference
	--quiet --no-checkout --bare --mirror --origin
	--upload-pack --template= --depth
---
 contrib/completion/git-completion.bash |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +26 -0
index 678a155..6ffe259 100755
@@ -667,6 +667,31 @@ _git_cherry_pick ()
 	esac
 }
 
+_git_clone ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "
+			--local
+			--no-hardlinks
+			--shared
+			--reference
+			--quiet
+			--no-checkout
+			--bare
+			--mirror
+			--origin
+			--upload-pack
+			--template=
+			--depth
+			"
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 _git_commit ()
 {
 	__git_has_doubledash && return
@@ -1475,6 +1500,7 @@ _git ()
 	checkout)    _git_checkout ;;
 	cherry)      _git_cherry ;;
 	cherry-pick) _git_cherry_pick ;;
+	clone)       _git_clone ;;
 	commit)      _git_commit ;;
 	config)      _git_config ;;
 	describe)    _git_describe ;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#2 lore raw

PATCH 2/8 bash completion: Add completion for 'git clean'

Added completions for all long options specified in the docs

        --dry-run --quiet
---
 contrib/completion/git-completion.bash |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +15 -0
index 6ffe259..72be4f1 100755
@@ -667,6 +667,20 @@ _git_cherry_pick ()
 	esac
 }
 
+_git_clean ()
+{
+	__git_has_doubledash && return
+
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "--dry-run --quiet"
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 _git_clone ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1500,6 +1514,7 @@ _git ()
 	checkout)    _git_checkout ;;
 	cherry)      _git_cherry ;;
 	cherry-pick) _git_cherry_pick ;;
+	clean)       _git_clean ;;
 	clone)       _git_clone ;;
 	commit)      _git_commit ;;
 	config)      _git_config ;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#3 lore raw

PATCH 3/8 bash completion: Add completion for 'git init'

Added completions for all long options specified in the docs

        --quiet --bare --template= --shared
        --shared={false|true|umask|group|all|world|everybody}
---
 contrib/completion/git-completion.bash |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +19 -0
index 72be4f1..c7a6d92 100755
@@ -842,6 +842,24 @@ _git_help ()
 	__gitcomp "$(__git_all_commands)"
 }
 
+_git_init ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--shared=*)
+		__gitcomp "
+			false true umask group all world everybody
+			" "" "${cur##--shared=}"
+		return
+		;;
+	--*)
+		__gitcomp "--quiet --bare --template= --shared --shared="
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 _git_ls_remote ()
 {
 	__gitcomp "$(__git_remotes)"
@@ -1524,6 +1542,7 @@ _git ()
 	format-patch) _git_format_patch ;;
 	gc)          _git_gc ;;
 	help)        _git_help ;;
+	init)        _git_init ;;
 	log)         _git_log ;;
 	ls-remote)   _git_ls_remote ;;
 	ls-tree)     _git_ls_tree ;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#4 lore raw

PATCH 4/8 bash completion: Add completion for 'git revert'

Added completions for all long options specified in the docs

        --edit --mainline --no-edit --no-commit --signoff
---
 contrib/completion/git-completion.bash |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +13 -0
index c7a6d92..6a5c4cd 100755
@@ -1264,6 +1264,18 @@ _git_reset ()
 	__gitcomp "$(__git_refs)"
 }
 
+_git_revert ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "--edit --mainline --no-edit --no-commit --signoff"
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 _git_rm ()
 {
 	__git_has_doubledash && return
@@ -1554,6 +1566,7 @@ _git ()
 	rebase)      _git_rebase ;;
 	remote)      _git_remote ;;
 	reset)       _git_reset ;;
+	revert)      _git_revert ;;
 	rm)          _git_rm ;;
 	send-email)  _git_send_email ;;
 	shortlog)    _git_shortlog ;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#5 lore raw

PATCH 5/8 bash completion: More completions for 'git stash'

Add branch subcommand to completions and USAGE for git-stash.sh. Complete stash names for show, apply, drop, pop, and branch. Add "--index" long option for apply.

---
 contrib/completion/git-completion.bash |   12 +++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)
contrib/completion/git-completion.bash +11 -1
index 6a5c4cd..a292cbd 100755
@@ -1348,7 +1348,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local subcommands='save list show apply clear drop pop create'
+	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_subcommand "$subcommands")"
 	if [ -z "$subcommand" ]; then
 		__gitcomp "$subcommands"
@@ -1358,6 +1358,16 @@ _git_stash ()
 		save,--*)
 			__gitcomp "--keep-index"
 			;;
+		apply,--*)
+			__gitcomp "--index"
+			;;
+		show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+			COMPREPLY=()
+			;;
+		show,*|apply,*|drop,*|pop,*|branch,*)
+			__gitcomp "$(git --git-dir="$(__gitdir)" stash list \
+					| sed -n -e 's/:.*//p')"
+			;;
 		*)
 			COMPREPLY=()
 			;;
git-stash.sh +1 -1
index d4609ed..5ad2c4b 100755
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Copyright (c) 2007, Nanako Shiraishi
 
-USAGE='[  | save | list | show | apply | clear | drop | pop | create ]'
+USAGE='[  | save | list | show | apply | clear | drop | pop | create | branch ]'
 
 SUBDIRECTORY_OK=Yes
 OPTIONS_SPEC=
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#6 lore raw

PATCH 6/8 bash completion: Add completion for 'git archive'

Added completions for all long options specified in the docs

	--format= --list --verbose
	--prefix= --remote= --exec=

The --format= long option can be completed with available formats and the --remote= can be completed with defined remote repositories.

---
 contrib/completion/git-completion.bash |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +24 -0
index a292cbd..61ea6d9 100755
@@ -561,6 +561,29 @@ _git_add ()
 	COMPREPLY=()
 }
 
+_git_archive ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--format=*)
+		__gitcomp "$(git archive --list)" "" "${cur##--format=}"
+		return
+		;;
+	--remote=*)
+		__gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
+		return
+		;;
+	--*)
+		__gitcomp "
+			--format= --list --verbose
+			--prefix= --remote= --exec=
+			"
+		return
+		;;
+	esac
+	__git_complete_file
+}
+
 _git_bisect ()
 {
 	__git_has_doubledash && return
@@ -1548,6 +1571,7 @@ _git ()
 	am)          _git_am ;;
 	add)         _git_add ;;
 	apply)       _git_apply ;;
+	archive)     _git_archive ;;
 	bisect)      _git_bisect ;;
 	bundle)      _git_bundle ;;
 	branch)      _git_branch ;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
author
#7 lore raw

PATCH 7/8 bash completion: Add completion for 'git ls-files'

Added completions for all long options specified in the docs

	--cached --deleted --modified --others --ignored
	--stage --directory --no-empty-directory --unmerged
	--killed --exclude= --exclude-from=
	--exclude-per-directory= --exclude-standard
	--error-unmatch --with-tree= --full-name
	--abbrev --ignored --exclude-per-directory
---
 contrib/completion/git-completion.bash |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +21 -0
index 61ea6d9..936cd35 100755
@@ -883,6 +883,26 @@ _git_init ()
 	COMPREPLY=()
 }
 
+_git_ls_files ()
+{
+	__git_has_doubledash && return
+
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--*)
+		__gitcomp "--cached --deleted --modified --others --ignored
+			--stage --directory --no-empty-directory --unmerged
+			--killed --exclude= --exclude-from=
+			--exclude-per-directory= --exclude-standard
+			--error-unmatch --with-tree= --full-name
+			--abbrev --ignored --exclude-per-directory
+			"
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 _git_ls_remote ()
 {
 	__gitcomp "$(__git_remotes)"
@@ -1590,6 +1610,7 @@ _git ()
 	help)        _git_help ;;
 	init)        _git_init ;;
 	log)         _git_log ;;
+	ls-files)    _git_ls_files ;;
 	ls-remote)   _git_ls_remote ;;
 	ls-tree)     _git_ls_tree ;;
 	merge)       _git_merge;;
Signature · 1 line
1.6.0.rc1.48.g2b6032
#8 lore raw

PATCH 1/1 bash: remove redundant check for 'git stash apply' options

In reply to Lee Marlow

It will never trigger anyway because of the first check, and even if it would, it would not offer the command line option.

---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
contrib/completion/git-completion.bash +1 -1
index 447cb06..5d60f82 100755
@@ -1427,7 +1427,7 @@ _git_stash ()
 		apply,--*)
 			__gitcomp "--index"
 			;;
-		show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+		show,--*|drop,--*|pop,--*|branch,--*)
 			COMPREPLY=()
 			;;
 		show,*|apply,*|drop,*|pop,*|branch,*)
Signature · 1 line
1.6.0.rc1.104.gf5b36
#9 lore raw

Re: [PATCH] bash: remove redundant check for 'git stash apply' options

Quoted 4 lines · SZEDER GGGbor

It will never trigger anyway because of the first check, and even if it would, it would not offer the command line option.

Oops. I should have caught that. ACK.

Quoted 13 lines
contrib/completion/git-completion.bash +1 -1
index 447cb06..5d60f82 100755
@@ -1427,7 +1427,7 @@ _git_stash ()
 		apply,--*)
 			__gitcomp "--index"
 			;;
-		show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+		show,--*|drop,--*|pop,--*|branch,--*)
 			COMPREPLY=()
 			;;
 		show,*|apply,*|drop,*|pop,*|branch,*)
Signature · 1 line
Shawn.
Acked-by on the v1 series
#10 lore raw
In reply to Lee Marlow
Quoted 2 lines · Lee Marlow

This adds basic long option completion for some common commands that I use, as well as stash name completion.

Entire series is good.

Quoted 14 lines

Lee Marlow (8):
bash completion: Add completion for 'git clone' bash completion: Add completion for 'git clean' bash completion: Add completion for 'git init' bash completion: Add completion for 'git revert' bash completion: More completions for 'git stash' bash completion: Add completion for 'git archive' bash completion: Add completion for 'git ls-files' bash completion: Add completion for 'git mv'

 contrib/completion/git-completion.bash |  143 +++++++++++++++++++++++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 143 insertions(+), 2 deletions(-)
Signature · 1 line
Shawn.
#11 lore raw
Quoted 7 lines · Shawn O. Pearce
Quoted 2 lines · Lee Marlow

This adds basic long option completion for some common commands that I use, as well as stash name completion.

Entire series is good.

Have you looked at the last one [PATCH 8/8]? I do not seem to have it.

Quoted 21 lines
Quoted 14 lines

Lee Marlow (8):
bash completion: Add completion for 'git clone' bash completion: Add completion for 'git clean' bash completion: Add completion for 'git init' bash completion: Add completion for 'git revert' bash completion: More completions for 'git stash' bash completion: Add completion for 'git archive' bash completion: Add completion for 'git ls-files' bash completion: Add completion for 'git mv'

 contrib/completion/git-completion.bash |  143 +++++++++++++++++++++++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 143 insertions(+), 2 deletions(-)
Signature · 5 lines
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Shawn O. Pearce
Quoted 2 lines · Lee Marlow

This adds basic long option completion for some common commands that I use, as well as stash name completion.

Entire series is good.

Have you looked at the last one [PATCH 8/8]? I do not seem to have it.

Yes. I just sent it back to you and the list. Hopefully at least one copy makes it. ;-)

Signature · 1 line
Shawn.