[PATCH 0/8] bash completion: more porcelain completions

STALE3712d

11 messages, 3 authors, 2016-06-15 · open the first message on its own page

[PATCH 0/8] bash completion: more porcelain completions

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

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(-)

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

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

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 678a155..6ffe259 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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 ;;
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

Added completions for all long options specified in the docs
        --dry-run --quiet

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6ffe259..72be4f1 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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 ;;
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

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.

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   12 +++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6a5c4cd..a292cbd 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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=()
 			;;
diff --git a/git-stash.sh b/git-stash.sh
index d4609ed..5ad2c4b 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -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=
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

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.

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a292cbd..61ea6d9 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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 ;;
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

Added completions for all long options specified in the docs
        --quiet --bare --template= --shared
        --shared={false|true|umask|group|all|world|everybody}

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 72be4f1..c7a6d92 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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 ;;
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

Added completions for all long options specified in the docs
        --edit --mainline --no-edit --no-commit --signoff

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c7a6d92..6a5c4cd 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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 ;;
-- 
1.6.0.rc1.48.g2b6032

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

From: Lee Marlow <hidden>
Date: 2016-06-15 22:45:06

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

Signed-off-by: Lee Marlow <redacted>
---
 contrib/completion/git-completion.bash |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 61ea6d9..936cd35 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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;;
-- 
1.6.0.rc1.48.g2b6032

Re: [PATCH 0/8] bash completion: more porcelain completions

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:06

Lee Marlow [off-list ref] wrote:
This adds basic long option completion for some common commands that I
use, as well as stash name completion.
Entire series is good.

Acked-by: Shawn O. Pearce <redacted>
 
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(-)
-- 
Shawn.

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

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:45:07

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

Signed-off-by: SZEDER Gábor <redacted>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 447cb06..5d60f82 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1427,7 +1427,7 @@ _git_stash ()
 		apply,--*)
 			__gitcomp "--index"
 			;;
-		show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+		show,--*|drop,--*|pop,--*|branch,--*)
 			COMPREPLY=()
 			;;
 		show,*|apply,*|drop,*|pop,*|branch,*)
-- 
1.6.0.rc1.104.gf5b36

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

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:07

SZEDER GGGbor [off-list ref] wrote:
It will never trigger anyway because of the first check, and even if it
would, it would not offer the command line option.

Signed-off-by: SZEDER Gábor <redacted>
Oops.  I should have caught that.  ACK.
quoted hunk
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 447cb06..5d60f82 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1427,7 +1427,7 @@ _git_stash ()
 		apply,--*)
 			__gitcomp "--index"
 			;;
-		show,--*|apply,--*|drop,--*|pop,--*|branch,--*)
+		show,--*|drop,--*|pop,--*|branch,--*)
 			COMPREPLY=()
 			;;
 		show,*|apply,*|drop,*|pop,*|branch,*)
-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help