threads / patch / 14836

patch, 8 partsbash completion: Add completion for 'git clone'

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

## tl;dr

13 messages between Aug 5, 2008 and Aug 6, 2008. Diffs are folded; open one to read it.

replies: 12people: 4as markdown or json

Lee Marlow· Aug 5, 2008, 05:50 UTC · lore

[PATCH 0/8] 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(-)
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore
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 <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +26 −0
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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

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

Added completions for all long options specified in the docs
        --dry-run --quiet
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +15 −0
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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

[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}
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +19 −0
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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

[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
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +13 −0
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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

[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.

Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   12 +++++++++++-
 git-stash.sh                           |    2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)
Show changes to 2 files +12 −2

contrib/completion/git-completion.bash, git-stash.sh

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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

[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.
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +24 −0
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
Lee Marlow· Aug 5, 2008, 05:50 UTC · re: Lee Marlow · lore

[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
Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
---
 contrib/completion/git-completion.bash |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
Show changes to contrib/completion/git-completion.bash +21 −0
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
SZEDER Gábor· Aug 6, 2008, 15:45 UTC · re: Lee Marlow · lore

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

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 <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to contrib/completion/git-completion.bash +1 −1
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
Shawn O. Pearce· Aug 6, 2008, 15:47 UTC · re: SZEDER Gábor · lore

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

SZEDER GGGbor <szeder@ira.uka.de> 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 <szeder@ira.uka.de>
Oops.  I should have caught that.  ACK.
Show 13 quoted lines
> 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.
Shawn O. Pearce· Aug 5, 2008, 14:29 UTC · re: Lee Marlow · lore

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

Lee Marlow <lee.marlow@gmail.com> 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 <spearce@spearce.org>
 
Show 14 quoted 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(-)
> 
-- 
Shawn.
Junio C Hamano· Aug 5, 2008, 18:58 UTC · re: Shawn O. Pearce · lore

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

"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 7 quoted lines
> Lee Marlow <lee.marlow@gmail.com> 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 <spearce@spearce.org>
Have you looked at the last one [PATCH 8/8]?  I do not seem to have it.
Show 21 quoted 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(-)
>> 
>
> -- 
> Shawn.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn O. Pearce· Aug 5, 2008, 19:09 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> wrote:
Show 10 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > Lee Marlow <lee.marlow@gmail.com> 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 <spearce@spearce.org>
> 
> 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.  ;-)
 
-- 
Shawn.

← back to recent threads