From patchwork Fri Nov 10 10:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13452279 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94B33134AF for ; Fri, 10 Nov 2023 10:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="sZjM+yS8"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LQg7ABng" Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F8DF26303 for ; Fri, 10 Nov 2023 02:01:19 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 987B53200A02; Fri, 10 Nov 2023 05:01:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 10 Nov 2023 05:01:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1699610476; x=1699696876; bh=Om ckioAytyB2LpBcxLEYi1pObbEKMhS/fQSbNZVplyI=; b=sZjM+yS8wBMDV+AJXA tWGTyTE8G+BUbcsGcJs6BzwQJws60Tjgywqn+5g4MJoOAWrk3wgQhVQD+I/0GBjf v6UslF9yY4NJsHK2lY0P0NepxDQF1C/vppFvsdrmdnUOyZuRaoQIUN4WZxJXugFD HKzTKvA5hc7K9U2Y9qSL9vJksiiQQVSEtFZZ2MObl3CEGtQOSwXwQQPV/p9pLlI3 36CiLmYsRwnNb8Ce+HzJnpPfhMx/lxF5eiX23830MkyGY26UGBu/LVrwF7X9602x ap0ExfmnBI8vTOWzTet7bpNQ3Sp3ALFfAP2rseN5QtNGNCdasO+5P7tH7CuTnPh5 z7ug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1699610476; x=1699696876; bh=OmckioAytyB2L pBcxLEYi1pObbEKMhS/fQSbNZVplyI=; b=LQg7ABng9YCuzKoXeKeVnF3kEcV+d JvcUTWUW0HdVP865QK7CxHBnzrxm3S6ckHmN26055IkJD2VQWV5gxi80uZ0f3axf BMVzb8PaSldkG2/q+87kQB5P+mRbyvdWjwl8TSS4lTOhIdjexxoHtH3w+yB15OZf xZK0wDulrH5DBHjXBLVt3Gx3hSHNibnQotafXuu5TgU9vfA0hxGjELMCQKUtEC+X oBFxW2Vn5OLu7dgFryNvuDRDf+pO+PvU0S0k/B8ZeNIe6aznKp30yvsUKdKzB/vW xeRmXN2chn/Q2zF9GJ7JjA0SbHfng8tnUo1HUb/51lC7WIe2jlnZOqT1A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvfedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Nov 2023 05:01:14 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 4325d579 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 10 Nov 2023 10:00:43 +0000 (UTC) Date: Fri, 10 Nov 2023 11:01:11 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Jeff King , Junio C Hamano Subject: [PATCH v2 0/4] Replace use of `test -o/a ` Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Hi, this is the second version of my patch series that replaces all uses of `test -o/a -a/-o ` contrib/subtree: stop using `-o` to test for number of args contrib/subtree: convert subtree type check to use case statement Makefile: stop using `test -o` when unlinking duplicate executables GIT-VERSION-GEN | 2 +- Makefile | 2 +- configure.ac | 2 +- contrib/subtree/git-subtree.sh | 34 +++++++++++++++++++++++----------- t/perf/perf-lib.sh | 2 +- t/perf/run | 9 +++++---- t/valgrind/valgrind.sh | 2 +- 7 files changed, 33 insertions(+), 20 deletions(-) Range-diff against v1: 1: c5e627eb3fe ! 1: 2967c8ebb46 global: convert trivial usages of `test -a/-o ` @@ Commit message these to instead instead concatenate multiple invocations of `test` via `&&` and `||`, respectively. + While not all of the converted instances can cause ambiguity, it is + worth getting rid of all of them regardless: + + - It becomes easier to reason about the code as we do not have to + argue why one use of `-a`/`-o` is okay while another one isn't. + + - We don't encourage people to use these expressions. + Signed-off-by: Patrick Steinhardt ## GIT-VERSION-GEN ## @@ GIT-VERSION-GEN: LF=' then VN=$(cat version) || VN="$DEF_VER" -elif test -d ${GIT_DIR:-.git} -o -f .git && -+elif ( test -d ${GIT_DIR:-.git} || test -f .git ) && ++elif { test -d "${GIT_DIR:-.git}" || test -f .git; } && VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null) && case "$VN" in *$LF*) (exit 1) ;; 2: b1ea45b8a88 ! 2: 977132d2236 contrib/subtree: stop using `-o` to test for number of args @@ Commit message of arguments we assert this via a single call to `test` with `-o`, which is discouraged by our coding guidelines. - Convert these cases to stop doing so. + Convert these cases to stop doing so. This requires us to decompose + assertions of the style `assert test $# = 2 -o $# = 3` into two calls + because we have no easy way to logically chain statements passed to the + assert function. Signed-off-by: Patrick Steinhardt 3: 7c54d9070fa = 3: 761cde1b341 contrib/subtree: convert subtree type check to use case statement 4: bc9489ca5b8 = 4: 5326d86888a Makefile: stop using `test -o` when unlinking duplicate executables base-commit: dadef801b365989099a9929e995589e455c51fed