From: Ævar Arnfjörð Bjarmason Date: Mon, 13 Dec 2021 16:29:34 GMT Subject: Re: [PATCH 10/13] test-lib-functions: add and use a "write_hook" wrapper Message-ID: <211213.868rwo8o3q.gmgdl@evledraar.gmail.com> In-Reply-To: On Mon, Dec 13 2021, Eric Sunshine wrote: > On Sun, Dec 12, 2021 at 4:24 PM Ævar Arnfjörð Bjarmason > wrote: >> Add a "write_hook" wrapper for the common case of "write_script >> .git/hooks/". This also accepts a "-C" option like >> "test_commit". Let's convert various trivial cases of "write_script" >> over to it. >> [...] >> Signed-off-by: Ævar Arnfjörð Bjarmason >> --- >> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh >> @@ -551,6 +551,32 @@ write_script () { >> +## Usage: write-hook pre-receive >> +## Usage: write-hook -C some-dir pre-receive >> +write_hook () { >> + indir= && >> + while test $# != 0 >> + do > > It's not clear whether the intention is to maintain the &&-chain in > this function... > >> + case "$1" in >> + -C) >> + indir="$2" >> + shift >> + ;; > > ... or not care about it since it's broken here before `shift`... > >> + -*) >> + BUG "invalid write_hook: $1" >> + ;; >> + *) >> + break >> + ;; >> + esac && >> + shift >> + done && >> + git_dir=$(git -C "$indir" rev-parse --absolute-git-dir) && >> + hook_dir="$git_dir/hooks" && >> + hook_file="$hook_dir/$1" >> + write_script "$hook_file" > > ... and here before `write_script`. Thanks, those should all use &&-chaining. Will fix.