Re: [RFC/PATCH v4 6/6] completion: add public _GIT_complete helper

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

Re: [RFC/PATCH v4 6/6] completion: add public _GIT_complete helper

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:46

Felipe Contreras [off-list ref] writes:
quoted hunk
So that users can easily define aliases, such as:

 _GIT_complete gf git_fetch

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/completion/git-completion.bash |   10 +++++-----
 t/t9902-completion.sh                  |    9 ++++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 049110e..2b7ef02 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2678,6 +2678,7 @@ _gitk ()
 
 __git_func_wrap ()
 {
+	local cmd="${1#git_}" cmd_pos=1
 	if [[ -n ${ZSH_VERSION-} ]]; then
 		emulate -L bash
 		setopt KSH_TYPESET
@@ -2695,8 +2696,7 @@ __git_func_wrap ()
 	_$1
 }
 
-# this is NOT a public function; use at your own risk
-__git_complete ()
+_GIT_complete ()
If it is now a public function, please have some description as to how to
use it for people who find this in the tarball extract.

I am guessing that

	_GIT_complete frotz git_fetch

is a way to declare that 'git frotz' wants the same kind of completion as
'git fetch' command, but I am not sure, as if it were the case it strikes
me somewhat odd that it is not "_GIT_complete frotz fetch".

Re: [RFC/PATCH v4 6/6] completion: add public _GIT_complete helper

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:53:46

On Mon, May 7, 2012 at 8:56 PM, Junio C Hamano [off-list ref] wrote:
Felipe Contreras [off-list ref] writes:
quoted
So that users can easily define aliases, such as:

 _GIT_complete gf git_fetch

Signed-off-by: Felipe Contreras <redacted>
---
 contrib/completion/git-completion.bash |   10 +++++-----
 t/t9902-completion.sh                  |    9 ++++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 049110e..2b7ef02 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2678,6 +2678,7 @@ _gitk ()
 __git_func_wrap ()
 {
+     local cmd="${1#git_}" cmd_pos=1
      if [[ -n ${ZSH_VERSION-} ]]; then
              emulate -L bash
              setopt KSH_TYPESET
@@ -2695,8 +2696,7 @@ __git_func_wrap ()
      _$1
 }

-# this is NOT a public function; use at your own risk
-__git_complete ()
+_GIT_complete ()
If it is now a public function, please have some description as to how to
use it for people who find this in the tarball extract.
This is RFC, I'm not planning to push for this, I truly have given up on it.
I am guessing that

       _GIT_complete frotz git_fetch

is a way to declare that 'git frotz' wants the same kind of completion as
'git fetch' command, but I am not sure, as if it were the case it strikes
me somewhat odd that it is not "_GIT_complete frotz fetch".
Yeah, I think that would be nicer, but one would need to take into
consideration the git/gitk cases.

Hopefully somebody else would pick this up and go through the eternal
nitpicking.

Cheers.

-- 
Felipe Contreras
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help