Re: [PATCH] completion: complete refs after 'git restore -s'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ákos Uzonyi <uzonyi.akos@xxxxxxxxx> writes:

> From: Uzonyi Ákos <uzonyi.akos@xxxxxxxxx>
>
> Currently only the long version (--source=) supports completion.
>
> Add completion support to the short (-s) option too.

I am not too familiar with the completion library, but what makes
the "-s" option of restore so special?  I've scanned the entire file
and did not find that many special cases for short options that have
their longer counterpart supported already.

I do not know if the "feature" this wants to bring in is a good
idea---we may want to try to be more systematic (e.g. perhaps it
involves teaching the parse-options subsystem about equivalence of
short and long options, so that we can reuse existing support for
the the long option "--source=<TAB>" to complete "-s <TAB>"), if we
were to do something like this.  Singling out "-s" of "restore"
smells not quite right, as the approach would not scale well.

> Signed-off-by: Ákos Uzonyi <uzonyi.akos@xxxxxxxxx>
> ---
>  contrib/completion/git-completion.bash | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 8be4a0316e..50e6e82157 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2853,6 +2853,18 @@ _git_restore ()
>  	--*)
>  		__gitcomp_builtin restore
>  		;;
> +	*)
> +		local prevword prevword="${words[cword-1]}"

Why duplicated prevword here?  Did you mean 

	local prevword=${words[cword-1]}

instead?

> +
> +		case "$prevword" in
> +			-s)
> +				__git_complete_refs
> +				return
> +				;;
> +			*)
> +				;;
> +		esac
> +		;;

Wrong indentation.  In this file, as can be seen on the line "*)"
you added at the top of this hunk, the case arms like "-s)" and "*)"
must align with "case" and "esac" in this file.

>  	esac
>  }


Thanks.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux