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

Re: [PATCH] completion: do not cache if --git-completion-helper fails

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 7, 2019, 16:35 UTC
Message-ID
<xmqqzhmtpd44.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20190607093034.816-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 10 quoted lines
>  	if [ -z "$options" ]; then
> +		local nocache=
>  		# leading and trailing spaces are significant to make
>  		# option removal work correctly.
> -		options=" $incl $(__git ${cmd/_/ } --git-completion-helper) "
> +		options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || nocache=t
> +
>  		for i in $excl; do
>  			options="${options/ $i / }"
>  		done

Is there a point in doing this loop if we are not going to eval after all? IOW...

> -		eval "$var=\"$options\""
> +		test -n "$nocache" || eval "$var=\"$options\""
>  	fi
... I am wondering why it is not more like this
	if options=" $incl $(__git ${cmd/_/ } --git-completion-helper) "
	then
		for i in $excl
		do
			options=...
		done
		eval "$var=..."
	fi

or just return from the function instead of introducing and setting a new variable, as only remaining thing the function does is to call __gitcomp with $options, but we know that we are giving up on completing this round.

Previous: Duy NguyenNext: Nguyễn Thái Ngọc Duy
Message 10 of 12 in “test: completion: tests for __gitcomp regression”
  1. test: completion: tests for __gitcomp regressionFelipe Contreras, Jun 7, 2019
  2. completion: do not cache if --git-completion-helper failsNguyễn Thái Ngọc Duy, Jun 7, 2019
  3. SZEDER GáborJun 7, 2019
  4. Felipe ContrerasJun 7, 2019
  5. Duy NguyenJun 12, 2019
  6. Felipe ContrerasJun 14, 2019
  7. Duy NguyenJun 14, 2019
  8. Felipe ContrerasJun 14, 2019
  9. Duy NguyenJun 16, 2019
  10. Junio C HamanoJun 7, 2019
  11. completion: do not cache if --git-completion-helper failsNguyễn Thái Ngọc Duy, Jun 12, 2019
  12. Junio C HamanoJun 12, 2019

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.