t/perf/run: preserve GIT_PERF_* from environment

If you run: GIT_PERF_LARGE_REPO=/some/path ./p1006-cat-file.sh it will use the repo in /some/path. But if you use the "run" helper script to aggregate and compare results, like this: GIT_PERF_LARGE_REPO=/some/path ./run HEAD^ HEAD p1006-cat-file.sh it will ignore that variable. This is because the presence of the LARGE_REPO variable in GIT-BUILD-OPTIONS overrides what's in the environment. This started with 4638e8806e (Makefile: use common template for GIT-BUILD-OPTIONS, 2024-12-06), which now writes even empty variables (though arguably it was wrong even before with a non-empty value, as we generally prefer the environment to take precedence over on-disk config). We had the same problem in perf-lib.sh itself, and we hacked around it with 32b74b9809 (perf: do allow `GIT_PERF_*` to be overridden again, 2025-04-04). That's what lets the direct invocation of "./p1006" work above. And in fact that was sufficient for "./run", too, until it started loading GIT-BUILD-OPTIONS itself in 5756ccd181 (t/perf: fix benchmarks with out-of-tree builds, 2025-04-28). Now it has the same problem: it clobbers any incoming GIT_PERF options from the environment. We can use the same hack here in the "run" script. It's quite ugly, but it's just short enough that I don't think it's worth trying to factor it out into a common shell library. In the long run, we might consider teaching GIT-BUILD-OPTIONS to be more gentle in overwriting existing entries. There are probably other GIT_TEST_* variables which would need the same treatment. And if and when we come up with a more complete solution, we can use it in both spots. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 6, 2026 at 05:16 UTC 79d301c7676e79a09e7a1c65ca754132e1770828
1 file changed +10
t/perf/run
+10
@@ -204,8 +204,18 @@ run_subsection () {
204 get_var_from_env_or_config "GIT_PERF_CODESPEED_OUTPUT" "perf" "codespeedOutput" "--bool"
205 get_var_from_env_or_config "GIT_PERF_SEND_TO_CODESPEED" "perf" "sendToCodespeed"
206
207 +# Preserve GIT_PERF settings from the environment when loading
208 +# GIT-BUILD-OPTIONS; see the similar hack in perf-lib.sh.
209 +git_perf_settings="$(env |
210 + sed -n "/^GIT_PERF_/{
211 + # escape all single-quotes in the value
212 + s/'/'\\\\''/g
213 + # turn this into an eval-able assignment
214 + s/^\\([^=]*=\\)\\(.*\\)/\\1'\\2'/p
215 + }")"
216 cd "$(dirname $0)"
217 . ../../GIT-BUILD-OPTIONS
218 +eval "$git_perf_settings"
219
220 if test -n "$TEST_OUTPUT_DIRECTORY"
221 then