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

[PATCH v3 4/7] perf/run: add conf_opts argument to get_var_from_env_or_config()

From
Christian Couder <christian.couder@gmail.com>
Date
Jan 5, 2018, 09:12 UTC
Message-ID
<20180105091226.16083-5-chriscool@tuxfamily.org>
In-Reply-To
<20180105091226.16083-1-chriscool@tuxfamily.org>

Let's make it possible to use `git config` type specifiers like `--int` or `--bool`, so that config values are converted to the canonical form and easier to use.

This additional argument is now the fourth argument of get_var_from_env_or_config() instead of the fifth because we want the default value argument to be unset if it is not passed, and this is simpler if it is the last argument.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/perf/run | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/t/perf/run b/t/perf/run
index 43e4de49ef..214d658172 100755
--- a/t/perf/run
+++ b/t/perf/run
@@ -105,7 +105,8 @@ get_var_from_env_or_config () {
 	env_var="$1"
 	conf_sec="$2"
 	conf_var="$3"
-	# $4 can be set to a default value
+	conf_opts="$4" # optional
+	# $5 can be set to a default value
 
 	# Do nothing if the env variable is already set
 	eval "test -z \"\${$env_var+x}\"" || return
@@ -116,18 +117,18 @@ get_var_from_env_or_config () {
 	if test -n "$GIT_PERF_SUBSECTION"
 	then
 		var="$conf_sec.$GIT_PERF_SUBSECTION.$conf_var"
-		conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
+		conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
 		eval "$env_var=\"$conf_value\"" && return
 	fi
 	var="$conf_sec.$conf_var"
-	conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
+	conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
 	eval "$env_var=\"$conf_value\"" && return
 
-	test -n "${4+x}" && eval "$env_var=\"$4\""
+	test -n "${5+x}" && eval "$env_var=\"$5\""
 }
 
 run_subsection () {
-	get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" 3
+	get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" "--int" 3
 	export GIT_PERF_REPEAT_COUNT
 
 	get_var_from_env_or_config "GIT_PERF_DIRS_OR_REVS" "perf" "dirsOrRevs"
-- 
2.16.0.rc0.40.gbe5e688583
Previous: Christian CouderNext: Christian Couder
Message 6 of 8 in “Codespeed perf results”
  1. 0/7 Codespeed perf resultsChristian Couder, Jan 5, 2018
  2. 1/7 perf/aggregate: fix checking ENV{GIT_PERF_SUBSECTION}Christian Couder, Jan 5, 2018
  3. 2/7 perf/aggregate: refactor printing resultsChristian Couder, Jan 5, 2018
  4. 3/7 perf/aggregate: implement codespeed JSON outputChristian Couder, Jan 5, 2018
  5. 5/7 perf/run: learn about perf.codespeedOutputChristian Couder, Jan 5, 2018
  6. 4/7 perf/run: add conf_opts argument to get_var_from_env_or_config()Christian Couder, Jan 5, 2018
  7. 6/7 perf/run: learn to send output to codespeed serverChristian Couder, Jan 5, 2018
  8. 7/7 perf/run: read GIT_PERF_REPO_NAME from perf.repoNameChristian Couder, Jan 5, 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.