Skip to content

Commit 3ae7d2b

Browse files
chriscoolgitster
authored andcommitted
perf/run: add conf_opts argument to get_var_from_env_or_config()
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05eb1c3 commit 3ae7d2b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

t/perf/run

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ get_var_from_env_or_config () {
105105
env_var="$1"
106106
conf_sec="$2"
107107
conf_var="$3"
108-
# $4 can be set to a default value
108+
conf_opts="$4" # optional
109+
# $5 can be set to a default value
109110

110111
# Do nothing if the env variable is already set
111112
eval "test -z \"\${$env_var+x}\"" || return
@@ -116,18 +117,18 @@ get_var_from_env_or_config () {
116117
if test -n "$GIT_PERF_SUBSECTION"
117118
then
118119
var="$conf_sec.$GIT_PERF_SUBSECTION.$conf_var"
119-
conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
120+
conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
120121
eval "$env_var=\"$conf_value\"" && return
121122
fi
122123
var="$conf_sec.$conf_var"
123-
conf_value=$(git config -f "$GIT_PERF_CONFIG_FILE" "$var") &&
124+
conf_value=$(git config $conf_opts -f "$GIT_PERF_CONFIG_FILE" "$var") &&
124125
eval "$env_var=\"$conf_value\"" && return
125126

126-
test -n "${4+x}" && eval "$env_var=\"$4\""
127+
test -n "${5+x}" && eval "$env_var=\"$5\""
127128
}
128129

129130
run_subsection () {
130-
get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" 3
131+
get_var_from_env_or_config "GIT_PERF_REPEAT_COUNT" "perf" "repeatCount" "--int" 3
131132
export GIT_PERF_REPEAT_COUNT
132133

133134
get_var_from_env_or_config "GIT_PERF_DIRS_OR_REVS" "perf" "dirsOrRevs"

0 commit comments

Comments
 (0)