git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: felipe.contreras@gmail.com, git@vger.kernel.org, szeder.dev@gmail.com
Subject: Re: [PATCH] completion: do not cache if --git-completion-helper fails
Date: Fri, 07 Jun 2019 09:35:39 -0700	[thread overview]
Message-ID: <xmqqzhmtpd44.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190607093034.816-1-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Fri, 7 Jun 2019 16:30:34 +0700")

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

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


  parent reply	other threads:[~2019-06-07 16:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07  2:24 [PATCH] test: completion: tests for __gitcomp regression Felipe Contreras
2019-06-07  9:30 ` [PATCH] completion: do not cache if --git-completion-helper fails Nguyễn Thái Ngọc Duy
2019-06-07 10:02   ` SZEDER Gábor
2019-06-07 17:33     ` Felipe Contreras
2019-06-12  8:52       ` Duy Nguyen
2019-06-14  0:30         ` Felipe Contreras
2019-06-14  2:52           ` Duy Nguyen
2019-06-14  6:06             ` Felipe Contreras
2019-06-16  1:32               ` Duy Nguyen
2019-06-07 16:35   ` Junio C Hamano [this message]
2019-06-12  8:56   ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2019-06-12 17:36     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzhmtpd44.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).