All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, "Jeff King" <peff@peff.net>,
	"Thomas Rast" <tr@thomasrast.ch>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Christian Couder" <chriscool@tuxfamily.org>
Subject: Re: [PATCH 4/8] perf/run: use $default_value instead of $4
Date: Wed, 13 Dec 2017 12:40:30 -0800	[thread overview]
Message-ID: <xmqqbmj2wedd.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171213151344.2138-5-chriscool@tuxfamily.org> (Christian Couder's message of "Wed, 13 Dec 2017 16:13:40 +0100")

Christian Couder <christian.couder@gmail.com> writes:

> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
>  t/perf/run | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/perf/run b/t/perf/run
> index 43e4de49ef..bbd703dc4f 100755
> --- a/t/perf/run
> +++ b/t/perf/run
> @@ -105,7 +105,7 @@ get_var_from_env_or_config () {
>  	env_var="$1"
>  	conf_sec="$2"
>  	conf_var="$3"
> -	# $4 can be set to a default value
> +	default_value="$4" # optional
>  
>  	# Do nothing if the env variable is already set
>  	eval "test -z \"\${$env_var+x}\"" || return
> @@ -123,7 +123,7 @@ get_var_from_env_or_config () {
>  	conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
>  	eval "$env_var=\"$conf_value\"" && return
>  
> -	test -n "${4+x}" && eval "$env_var=\"$4\""
> +	test -n "${default_value+x}" && eval "$env_var=\"$default_value\""

This conversion changes the behaviour.  Because default_value is
always set by your change in the previous hunk, we end up always
doing this eval.

The original says "If $4 is set, then ${4+x} becomes x and if $4 is
not set, ${4+x} is empty, so let's check if ${4+x} is a non-empty
string to see if $4 is set.  If ${4+x} is a non-empty string, that
means $4 was set so we do the eval.

If you want to be able to use this helper to specify a default value
of an empty string (which the orignal that used $4 did), then the
previous hunk must be corrected so that it does not unconditionally
set default_value to $4.  Perhaps like

	if test -n "${4+x}"
	then
		default_value=$4
	else
		unset default_value || :
	fi

or something.

>  }
>  
>  run_subsection () {

  reply	other threads:[~2017-12-13 20:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 15:13 [PATCH 0/8] Codespeed perf results Christian Couder
2017-12-13 15:13 ` [PATCH 1/8] perf/aggregate: fix checking ENV{GIT_PERF_SUBSECTION} Christian Couder
2017-12-13 15:13 ` [PATCH 2/8] perf/aggregate: refactor printing results Christian Couder
2017-12-13 15:13 ` [PATCH 3/8] perf/aggregate: implement codespeed JSON output Christian Couder
2017-12-13 18:25   ` Eric Sunshine
2017-12-14  8:47     ` Christian Couder
2017-12-13 20:33   ` Junio C Hamano
2017-12-14  8:57     ` Christian Couder
2017-12-14 17:31       ` Junio C Hamano
2017-12-13 15:13 ` [PATCH 4/8] perf/run: use $default_value instead of $4 Christian Couder
2017-12-13 20:40   ` Junio C Hamano [this message]
2017-12-13 20:54     ` Junio C Hamano
2017-12-14  9:00       ` Christian Couder
2017-12-14  8:59     ` Christian Couder
2017-12-13 15:13 ` [PATCH 5/8] perf/run: add conf_opts argument to get_var_from_env_or_config() Christian Couder
2017-12-13 15:13 ` [PATCH 6/8] perf/run: learn about perf.codespeedOutput Christian Couder
2017-12-13 15:13 ` [PATCH 7/8] perf/run: learn to send output to codespeed server Christian Couder
2017-12-13 15:13 ` [PATCH 8/8] perf/run: read GIT_TEST_REPO_NAME from perf.repoName Christian Couder
2017-12-13 16:02 ` [PATCH 0/8] Codespeed perf results Philip Oakley
2017-12-13 16:18   ` Christian Couder

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

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

  git send-email \
    --in-reply-to=xmqqbmj2wedd.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=tr@thomasrast.ch \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.