threads / patch / 34251

patch, 2 partscompletion: learn about --man-path

Subject: [PATCH 2/2] completion: learn about --man-path

## tl;dr

7 messages between Jun 22, 2013 and Jun 30, 2013. Diffs are folded; open one to read it.

replies: 6people: 4as markdown or json

John Keeping· Jun 22, 2013, 11:25 UTC · lore

[PATCH 1/2] completion: handle unstuck form of base git options

git-completion.bash's parsing of the command name relies on everything preceding it starting with '-' unless it is the "-c" option. This allows users to use the stuck form of "--work-tree=<path>" and "--namespace=<path>" but not the unstuck forms "--work-tree <path>" and "--namespace <path>". Fix this.

Similarly, the completion only handles the stuck form "--git-dir=<path>" and not "--git-dir <path>", so fix this as well.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 contrib/completion/git-completion.bash | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Show changes to contrib/completion/git-completion.bash +2 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6c3bafe..8fbf941 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2492,9 +2492,10 @@ __git_main ()
 		i="${words[c]}"
 		case "$i" in
 		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
+		--git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
 		--bare)      __git_dir="." ;;
 		--help) command="help"; break ;;
-		-c) c=$((++c)) ;;
+		-c|--work-tree|--namespace) ((c++)) ;;
 		-*) ;;
 		*) command="$i"; break ;;
 		esac
-- 
1.8.3.1.676.gaae6535
John Keeping· Jun 22, 2013, 11:25 UTC · re: John Keeping · lore
Signed-off-by: John Keeping <john@keeping.me.uk>
---
 contrib/completion/git-completion.bash | 2 ++
 t/t9902-completion.sh                  | 1 +
 2 files changed, 3 insertions(+)
Show changes to 2 files +3 −0

contrib/completion/git-completion.bash, t/t9902-completion.sh

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 8fbf941..c3290af 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2513,11 +2513,13 @@ __git_main ()
 			--exec-path
 			--exec-path=
 			--html-path
+			--man-path
 			--info-path
 			--work-tree=
 			--namespace=
 			--no-replace-objects
 			--help
+			-c
 			"
 			;;
 		*)     __git_compute_porcelain_commands
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 81a1657..14d605a 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -231,6 +231,7 @@ test_expect_success 'double dash "git" itself' '
 	--exec-path Z
 	--exec-path=
 	--html-path Z
+	--man-path Z
 	--info-path Z
 	--work-tree=
 	--namespace=
-- 
1.8.3.1.676.gaae6535
SZEDER Gábor· Jun 30, 2013, 11:41 UTC · re: John Keeping · lore

Re: [PATCH 2/2] completion: learn about --man-path

Hi,
On Sat, Jun 22, 2013 at 12:25:18PM +0100, John Keeping wrote:
Show 21 quoted lines
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
>  contrib/completion/git-completion.bash | 2 ++
>  t/t9902-completion.sh                  | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 8fbf941..c3290af 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2513,11 +2513,13 @@ __git_main ()
>  			--exec-path
>  			--exec-path=
>  			--html-path
> +			--man-path
>  			--info-path
>  			--work-tree=
>  			--namespace=
>  			--no-replace-objects
>  			--help
> +			-c
There are a couple of issues with this '-c' here:
- We normally offer only --long-options in the completion script.
- The log message doesn't mention it.
- And finally the most important: it will never be offered for
  completion.  This is the condition of this case branch:
                case "$cur" in
                --*)   __gitcomp "
  i.e. this case branch is executed only when the current word on the
  command line begins with '--', but then '-c' will never match.

Without the '-c' part it's "obviously correct" and together with patch 1/2 is

Acked-by: SZEDER Gábor <szeder@ira.uka.de>
Show 19 quoted lines
>  			"
>  			;;
>  		*)     __git_compute_porcelain_commands
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 81a1657..14d605a 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -231,6 +231,7 @@ test_expect_success 'double dash "git" itself' '
>  	--exec-path Z
>  	--exec-path=
>  	--html-path Z
> +	--man-path Z
>  	--info-path Z
>  	--work-tree=
>  	--namespace=
> -- 
> 1.8.3.1.676.gaae6535
> 
> 
Junio C Hamano· Jun 30, 2013, 22:59 UTC · re: SZEDER Gábor · lore

Re: [PATCH 2/2] completion: learn about --man-path

SZEDER Gábor <szeder@fzi.de> writes:
> Without the '-c' part it's "obviously correct" and together with patch
> 1/2 is
>
> Acked-by: SZEDER Gábor <szeder@ira.uka.de>
Thanks, both.  Will queue.
SZEDER Gábor· Jun 22, 2013, 12:30 UTC · re: John Keeping · lore

Re: [PATCH 1/2] completion: handle unstuck form of base git options

Hi,
On Sat, Jun 22, 2013 at 12:25:17PM +0100, John Keeping wrote:
Show 5 quoted lines
> git-completion.bash's parsing of the command name relies on everything
> preceding it starting with '-' unless it is the "-c" option.  This
> allows users to use the stuck form of "--work-tree=<path>" and
> "--namespace=<path>" but not the unstuck forms "--work-tree <path>" and
> "--namespace <path>".  Fix this.

I never use these commands, so I looked up what --namespace means. While doing so I noticed that --exec-path takes a path just like these options, so that option should be handled similarly as well.

Otherwise it makes sense.
Gábor
Show 27 quoted lines
> Similarly, the completion only handles the stuck form "--git-dir=<path>"
> and not "--git-dir <path>", so fix this as well.
> 
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
>  contrib/completion/git-completion.bash | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 6c3bafe..8fbf941 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2492,9 +2492,10 @@ __git_main ()
>  		i="${words[c]}"
>  		case "$i" in
>  		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
> +		--git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
>  		--bare)      __git_dir="." ;;
>  		--help) command="help"; break ;;
> -		-c) c=$((++c)) ;;
> +		-c|--work-tree|--namespace) ((c++)) ;;
>  		-*) ;;
>  		*) command="$i"; break ;;
>  		esac
> -- 
> 1.8.3.1.676.gaae6535
> 
SZEDER Gábor· Jun 22, 2013, 12:35 UTC · re: SZEDER Gábor · lore

Re: [PATCH 1/2] completion: handle unstuck form of base git options

On Sat, Jun 22, 2013 at 02:30:33PM +0200, SZEDER Gábor wrote:
Show 12 quoted lines
> Hi,
> 
> On Sat, Jun 22, 2013 at 12:25:17PM +0100, John Keeping wrote:
> > git-completion.bash's parsing of the command name relies on everything
> > preceding it starting with '-' unless it is the "-c" option.  This
> > allows users to use the stuck form of "--work-tree=<path>" and
> > "--namespace=<path>" but not the unstuck forms "--work-tree <path>" and
> > "--namespace <path>".  Fix this.
> 
> I never use these commands, so I looked up what --namespace means.
> While doing so I noticed that --exec-path takes a path just like these
> options, so that option should be handled similarly as well.

Never mind, I misunderstood the docs: --exec-path either takes a path as --exec-path=<path> or it doesn't take one at all, but there is no '--exec-path <path>'.

Gábor
John Keeping· Jun 28, 2013, 08:20 UTC · re: John Keeping · lore

Re: [PATCH 1/2] completion: handle unstuck form of base git options

Hi Junio, I don't think you've picked this up. Are you expecting a re-roll or did it just get lost in the noise?

On Sat, Jun 22, 2013 at 12:25:17PM +0100, John Keeping wrote:
Show 33 quoted lines
> git-completion.bash's parsing of the command name relies on everything
> preceding it starting with '-' unless it is the "-c" option.  This
> allows users to use the stuck form of "--work-tree=<path>" and
> "--namespace=<path>" but not the unstuck forms "--work-tree <path>" and
> "--namespace <path>".  Fix this.
> 
> Similarly, the completion only handles the stuck form "--git-dir=<path>"
> and not "--git-dir <path>", so fix this as well.
> 
> Signed-off-by: John Keeping <john@keeping.me.uk>
> ---
>  contrib/completion/git-completion.bash | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 6c3bafe..8fbf941 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2492,9 +2492,10 @@ __git_main ()
>  		i="${words[c]}"
>  		case "$i" in
>  		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
> +		--git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
>  		--bare)      __git_dir="." ;;
>  		--help) command="help"; break ;;
> -		-c) c=$((++c)) ;;
> +		-c|--work-tree|--namespace) ((c++)) ;;
>  		-*) ;;
>  		*) command="$i"; break ;;
>  		esac
> -- 
> 1.8.3.1.676.gaae6535
> 

← back to recent threads