git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 4/4] completion: simplify __gitcomp*

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 3, 2012, 20:23 UTC
Message-ID
<7vty37oedr.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1328214625-3576-5-git-send-email-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 13 quoted lines
> @@ -495,11 +495,7 @@ fi
>  # 4: A suffix to be appended to each possible completion word (optional).
>  __gitcomp ()
>  {
> -	local cur_="$cur"
> -
> -	if [ $# -gt 2 ]; then
> -		cur_="$3"
> -	fi
> +	local cur_="${3:-$cur}"
>  	case "$cur_" in
>  	--*=)
>  		COMPREPLY=()

I think this rewrite is wrong, even though it may not make a difference to the current callers (I didn't check). Drop the colon from ${3:-...}.

Show 18 quoted lines
> @@ -524,18 +520,8 @@ __gitcomp ()
>  #    appended.
>  __gitcomp_nl ()
>  {
> -	local s=$'\n' IFS=' '$'\t'$'\n'
> -	local cur_="$cur" suffix=" "
> -
> -	if [ $# -gt 2 ]; then
> -		cur_="$3"
> -		if [ $# -gt 3 ]; then
> -			suffix="$4"
> -		fi
> -	fi
> -
> -	IFS=$s
> -	COMPREPLY=($(compgen -P "${2-}" -S "$suffix" -W "$1" -- "$cur_"))
> +	local IFS=$'\n'
> +	COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3:-$cur}"))
So is this.

Fixing the above two gives me what I've already sent in $gmane/189683, so...

Previous: Felipe ContrerasNext: SZEDER Gábor
Message 6 of 11 in “completion: couple of cleanups”
  1. 0/4 completion: couple of cleanupsFelipe Contreras, Feb 2, 2012
  2. Junio C HamanoFeb 3, 2012
  3. Felipe ContrerasFeb 6, 2012
  4. Junio C HamanoFeb 6, 2012
  5. Felipe ContrerasFeb 6, 2012
  6. Junio C HamanoFeb 3, 2012
  7. SZEDER GáborFeb 4, 2012
  8. Junio C HamanoFeb 5, 2012
  9. Felipe ContrerasFeb 5, 2012
  10. SZEDER GáborFeb 6, 2012
  11. Felipe ContrerasFeb 6, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.