Re: [PATCH 10/13] test-lib-functions: add and use a "write_hook" wrapper
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Dec 13, 2021, 14:15 UTC
- Message-ID
- <CAPig+cSkiFd27o8uACdX9ftg=N2XukqNSU_Tt+7rWT08JD7CAQ@mail.gmail.com>
- In-Reply-To
- <patch-10.13-ca55471d134-20211212T201308Z-avarab@gmail.com>
On Sun, Dec 12, 2021 at 4:24 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 15 quoted lines
> 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 <avarab@gmail.com>
> ---
> 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...
Show 5 quoted lines
> + case "$1" in > + -C) > + indir="$2" > + shift > + ;;
... or not care about it since it's broken here before `shift`...
Show 13 quoted lines
> + -*) > + 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`.
> +}