Re: [PATCH 10/13] test-lib-functions: add and use a "write_hook" wrapper
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-12-13 16:29:52
On Mon, Dec 13 2021, Eric Sunshine wrote:
On Sun, Dec 12, 2021 at 4:24 PM Ævar Arnfjörð Bjarmason [off-list ref] wrote:quoted
Add a "write_hook" wrapper for the common case of "write_script .git/hooks/<NAME>". 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 <redacted> ---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 + doIt's not clear whether the intention is to maintain the &&-chain in this function...quoted
+ case "$1" in + -C) + indir="$2" + shift + ;;... or not care about it since it's broken here before `shift`...quoted
+ -*) + 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.