From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 43F041F953 for ; Mon, 13 Dec 2021 14:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238240AbhLMOQL convert rfc822-to-8bit (ORCPT ); Mon, 13 Dec 2021 09:16:11 -0500 Received: from mail-pj1-f49.google.com ([209.85.216.49]:43643 "EHLO mail-pj1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231897AbhLMOQK (ORCPT ); Mon, 13 Dec 2021 09:16:10 -0500 Received: by mail-pj1-f49.google.com with SMTP id nh10-20020a17090b364a00b001a69adad5ebso13452567pjb.2 for ; Mon, 13 Dec 2021 06:16:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WsHpxrKjfqrWnCXcbgqOiAYjtiHMsHPKwwgYSOfiebQ=; b=j26DipbNW5d7+OaGhHx8fkFgQCo1bt1f8BdKonVeL1Mwik6xzJ4xp3uma7FdxT2msB WW7DwfEzrcsIt+ukioeRNpwjqNALTVFGL3kfTi1mIyXXaKuiestwevLLeHhRC3eLi4nY y8RciyozER+YBoUqc/LjFtEEva5P7SLnTscLtiE1+wfxpYIIa7FSDpRXs7LctsfdW11X djH+4VwbAwtnmiW6oRT3Pv4MfjEb0kp8G4QJ1ZSlU6Zurfab8b4EOGZVA6qfyWAa/2AS XuGdyeYNuIw/0SKPniYu4hhts5S/ta8p5kUIdLe1VnDSMco8MYubGN7Ok1ZV5jE+08A9 6k6A== X-Gm-Message-State: AOAM533wgZVpSpGdF9WXt9zWvT3MRPrQkGC+81n7ixnK3CCBZaQzXPxt ni+JMQhFH+qZUz6QDm6Lefpahnua0ww97DAGuGw= X-Google-Smtp-Source: ABdhPJyv5+1L0ISn0+q8vCXtq77esx8PQgu2ApVvp5CMWRa5yIC4ZnCQu4rcQKtmWCZASM91yXWs+SLjGJR4iMYgmhI= X-Received: by 2002:a17:90b:3558:: with SMTP id lt24mr13514611pjb.150.1639404970220; Mon, 13 Dec 2021 06:16:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Eric Sunshine Date: Mon, 13 Dec 2021 09:15:59 -0500 Message-ID: Subject: Re: [PATCH 10/13] test-lib-functions: add and use a "write_hook" wrapper To: =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Cc: Git List , Junio C Hamano , Derrick Stolee , Adam Spiers , Jeff King , Johannes Schindelin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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`. > +}