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

Re: [RFC PATCH 1/1] completion: load completion file for external subcommand

From
Florian Gamböck <mail@floga.de>
Date
Apr 9, 2018, 07:29 UTC
Message-ID
<20180409072909.GA30684@arbeitsviech>
In-Reply-To
<xmqq37059uez.fsf@gitster-ct.c.googlers.com>
On 2018-04-09 07:59, Junio C Hamano wrote:
Show 15 quoted lines
> >  	local completion_func="_git_${command//-/_}"
> > +	if ! declare -f $completion_func >/dev/null 2>/dev/null; then
> > +		declare -f __load_completion >/dev/null 2>/dev/null &&
> > +			__load_completion "git-$command"
> 
> wouldn't the above be easier to read if it were
> 
> 	if ! declare ... $completion_func ... && declare -f __load_completion
> 	then
> 		__load_completion "git-$command"
> 	fi
> 
> or is there a reason why it is better to &&-chain the check for
> __load_completion with its use?  Same comment applies to the other
> hunk.
Good point. I could go even further and ditch the if-construct:
    ! declare -f $completion_func && declare -f __load_completion &&
        __load_completion "git-$command"

I originally intended to do a if-else-construct, which I re-thought halfway through. I will change that in the next iteration.

Thank you!
-- 
Regards

Florian
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 13 in “completion: Dynamic completion loading”
  1. 0/1 completion: Dynamic completion loadingFlorian Gamböck, Apr 8, 2018
  2. 1/1 completion: Load completion file for external subcommandFlorian Gamböck, Apr 8, 2018
  3. Florian GamböckApr 8, 2018
  4. Stefan BellerApr 9, 2018
  5. Florian GamböckApr 9, 2018
  6. SZEDER GáborApr 19, 2018
  7. 1/1 completion: load completion file for external subcommandFlorian Gamböck, Apr 8, 2018
  8. Junio C HamanoApr 8, 2018
  9. Florian GamböckApr 9, 2018
  10. Junio C HamanoApr 9, 2018
  11. Florian GamböckApr 9, 2018
  12. Junio C HamanoApr 9, 2018
  13. Florian GamböckApr 10, 2018

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.