Subject: Re: [PATCH v2] builtin/gc: fix crash when running `git maintenance start`

From: Junio C Hamano <[email-masked]>
Date: Wed, 09 Oct 2024 10:10:25 -0700

Patrick Steinhardt <[email-masked]> writes:

> diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
> index a66d0e089d..e75b485319 100755
> --- a/t/t7900-maintenance.sh
> +++ b/t/t7900-maintenance.sh
> @@ -646,6 +646,22 @@ test_expect_success !MINGW 'register and unregister with regex metacharacters' '
>  		maintenance.repo "$(pwd)/$META"
>  '
>  
> +test_expect_success 'start without GIT_TEST_MAINT_SCHEDULER' '
> +	test_when_finished "rm -rf systemctl.log script repo" &&
> +	mkdir script &&
> +	write_script script/systemctl <<-EOF &&
> +	echo "\$*" >>"$(pwd)"/systemctl.log
> +	EOF

We deliberately include one SP in the name of the trash directory
when we create it under t/ so that we can catch a bug easily when we
forget quoting "$TRASH_DIRECTORY", but otherwise the name under t/
is safe.  

But this use of "$(pwd)" is a bit iffy.  It is expanded when the
script is written, which means the script is designed to write to
the systemctl.log file in a directory whose absolute path is known
and hardcoded in the script.  We assume that the leading directories
down to the t/ directory from the root can also safely quoted by
simply enclosing inside "a pair of double quotes", which might be
iffy (obviously if $(pwd) had a double-quote in it, the quoting
would break).

I'll let it pass (and will forget blissfully if nobody screams).

Other than that, looking good.  It certainly is good that there is
something more widely supported than "cron" so that we can write
this test as a generic one, even if some of us might not want to
touch "systemd" in the real life ;-)

Thanks, will queue.