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

7 messages from 2013-06-22 to 2013-06-30. Participants: John Keeping, SZEDER Gábor, Junio C Hamano.
Thread: https://gitlist.dev/t/34251

## John Keeping, 2013-06-22 11:25

Subject: [PATCH 1/2] completion: handle unstuck form of base git options
Message-ID: <adafd1a0c0d7d059d215d9fd1ea68579525efe6e.1371900318.git.john@keeping.me.uk>
URL: https://gitlist.dev/e/adafd1a0c0d7d059d215d9fd1ea68579525efe6e.1371900318.git.john%40keeping.me.uk

```
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

```

## John Keeping, 2013-06-22 11:25

Subject: [PATCH 2/2] completion: learn about --man-path
Message-ID: <bc83f64cf17851022e0344b3eb693beda1bdd8b6.1371900318.git.john@keeping.me.uk>
URL: https://gitlist.dev/e/bc83f64cf17851022e0344b3eb693beda1bdd8b6.1371900318.git.john%40keeping.me.uk
In-Reply-To: <adafd1a0c0d7d059d215d9fd1ea68579525efe6e.1371900318.git.john@keeping.me.uk>

```
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
 			"
 			;;
 		*)     __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, 2013-06-22 12:30

Subject: Re: [PATCH 1/2] completion: handle unstuck form of base git options
Message-ID: <20130622123033.GI20052@goldbirke>
URL: https://gitlist.dev/e/20130622123033.GI20052%40goldbirke
In-Reply-To: <adafd1a0c0d7d059d215d9fd1ea68579525efe6e.1371900318.git.john@keeping.me.uk>

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

Otherwise it makes sense.


Gábor


> 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, 2013-06-22 12:35

Subject: Re: [PATCH 1/2] completion: handle unstuck form of base git options
Message-ID: <20130622123533.GJ20052@goldbirke>
URL: https://gitlist.dev/e/20130622123533.GJ20052%40goldbirke
In-Reply-To: <20130622123033.GI20052@goldbirke>

```
On Sat, Jun 22, 2013 at 02:30:33PM +0200, SZEDER Gábor wrote:
> 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, 2013-06-28 08:20

Subject: Re: [PATCH 1/2] completion: handle unstuck form of base git options
Message-ID: <20130628082017.GE2232@serenity.lan>
URL: https://gitlist.dev/e/20130628082017.GE2232%40serenity.lan
In-Reply-To: <adafd1a0c0d7d059d215d9fd1ea68579525efe6e.1371900318.git.john@keeping.me.uk>

```
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:
> 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
> 

```

## SZEDER Gábor, 2013-06-30 11:41

Subject: Re: [PATCH 2/2] completion: learn about --man-path
Message-ID: <20130630114106.GE2294@goldbirke>
URL: https://gitlist.dev/e/20130630114106.GE2294%40goldbirke
In-Reply-To: <bc83f64cf17851022e0344b3eb693beda1bdd8b6.1371900318.git.john@keeping.me.uk>

```
Hi,

On Sat, Jun 22, 2013 at 12:25:18PM +0100, John Keeping wrote:
> 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>


>  			"
>  			;;
>  		*)     __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, 2013-06-30 22:59

Subject: Re: [PATCH 2/2] completion: learn about --man-path
Message-ID: <7vsizzi4rv.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vsizzi4rv.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20130630114106.GE2294@goldbirke>

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

```
