From patchwork Thu Feb 21 19:28:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10824681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B3851575 for ; Thu, 21 Feb 2019 19:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F000B2DEA2 for ; Thu, 21 Feb 2019 19:29:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3FC731D9B; Thu, 21 Feb 2019 19:29:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80C962DEA2 for ; Thu, 21 Feb 2019 19:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726273AbfBUT3E (ORCPT ); Thu, 21 Feb 2019 14:29:04 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53942 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbfBUT3D (ORCPT ); Thu, 21 Feb 2019 14:29:03 -0500 Received: by mail-wm1-f67.google.com with SMTP id e74so10088199wmg.3 for ; Thu, 21 Feb 2019 11:29:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j5D9OoOe0Xr2OQHa2pYMKmHQkJXZW/yqiXHHgMpb3Cc=; b=ontvspfKgi9EOcHcLvrk60xfsH2nPgnnRUS9r03G3t9dedRFCiIW10ku+o1P0loK79 8roA9SpErfXEkdGelSymmF04HWTzn4gfsK/8r6vskA8kyX0p/lt6yH/pvttN2rNjEOB1 JsnLOgBeXcyeGgJeFZgUPi3qqSRLjbko5ZD4COfroMWY/IZLwFSicCBj7ylfnSP22qOy 96hdYmWoWOmTORFPOn4LotJzSgxUJOxFfCD1eaP6qjnG0o+oDqu++vLItmfhBVhG6rIg y3AfyIFhWMse1l5wkbhpV1fzIvddKp0AOQbb+/iE0j/yzutxK5otYwHhvFQAzOJ3jDFT bwTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j5D9OoOe0Xr2OQHa2pYMKmHQkJXZW/yqiXHHgMpb3Cc=; b=ZpUVwDPRt+lumr5e8D3HQgW96AbC4h++5BnNwE7Km6aLHcaLkXbY3nUnNk68wF8jwn X05BmRBkopBUPju3aR8kDI9Sc0vdtqg7GSVdelW8r5IF4yYJ83be8KhuAbnilXqGfjda U+e0PisSPTgVEohaJkBpvXLqqiHLyAUy+9K5m57mg55X5nonMqUTG1fGKL6l86XbqH2p HVGGw2rOcLnaP0Ydxa9EE+C4Uz/Epy91La7i38APm2Q/PENH6cX7joC3jeVExXqm0isi T86TTH+mDgF1yjf7tyx4TyND6V5iTtM9jx7604alM5hDiOSoVa+ztDKcn0EkOttHUCSk MSOA== X-Gm-Message-State: AHQUAub8KD1rfHFKF6xlVV3ES6mN/opz21JCB5LmpPMk1wKkriSYIsYE bMxLheyLocu/UFfxc/jzwg5aArj+ X-Google-Smtp-Source: AHgI3IZ0qP1QWicd6YoxnGn03sznYwsLGBHxn5J77YtXspKCDcvNbzc8a4xtFdgMMyFiZja51T1tuQ== X-Received: by 2002:a1c:7f0c:: with SMTP id a12mr63540wmd.89.1550777341101; Thu, 21 Feb 2019 11:29:01 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n2sm35237429wrq.58.2019.02.21.11.29.00 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 21 Feb 2019 11:29:00 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Sebastian Staudt , Josh Steadmon , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/2] tests: fix unportable "\?" and "\+" regex syntax Date: Thu, 21 Feb 2019 20:28:48 +0100 Message-Id: <20190221192849.6581-2-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix widely supported but non-POSIX basic regex syntax introduced in [1] and [2]. On GNU, NetBSD and FreeBSD the following works: $ echo xy >f $ grep 'xy\?' f; echo $? xy 0 The same goes for "\+". The "?" and "+" syntax is not in the BRE syntax, just in ERE, but on some implementations it can be invoked by prefixing the meta-operator with "\", but not on OpenBSD: $ uname -a OpenBSD obsd.my.domain 6.2 GENERIC#132 amd64 $ grep --version grep version 0.9 $ grep 'xy\?' f; echo $? 1 Let's fix this by moving to ERE syntax instead, where "?" and "+" are universally supported: $ grep -E 'xy?' f; echo $? xy 0 1. 2ed5c8e174 ("describe: setup working tree for --dirty", 2019-02-03) 2. c801170b0c ("t6120: test for describe with a bare repository", 2019-02-03) Signed-off-by: Ævar Arnfjörð Bjarmason --- t/t6120-describe.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index ee5b03ee18..2b883d8174 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -146,7 +146,7 @@ check_describe A-* HEAD test_expect_success 'describe works from outside repo using --git-dir' ' git clone --bare "$TRASH_DIRECTORY" "$TRASH_DIRECTORY/bare" && git --git-dir "$TRASH_DIRECTORY/bare" describe >out && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+$" out ' check_describe "A-*[0-9a-f]" --dirty @@ -156,7 +156,7 @@ test_expect_success 'describe --dirty with --work-tree' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+$" out ' test_expect_success 'set-up dirty work tree' ' @@ -170,7 +170,7 @@ test_expect_success 'describe --dirty with --work-tree (dirty)' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+-dirty$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+-dirty$" out ' check_describe "A-*[0-9a-f].mod" --dirty=.mod @@ -180,7 +180,7 @@ test_expect_success 'describe --dirty=.mod with --work-tree (dirty)' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty=.mod >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+.mod$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+.mod$" out ' test_expect_success 'describe --dirty HEAD' ' From patchwork Thu Feb 21 19:28:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 10824683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 374A31390 for ; Thu, 21 Feb 2019 19:29:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27FF92DEA2 for ; Thu, 21 Feb 2019 19:29:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BCE831DA8; Thu, 21 Feb 2019 19:29:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95D0E2DEA2 for ; Thu, 21 Feb 2019 19:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726360AbfBUT3G (ORCPT ); Thu, 21 Feb 2019 14:29:06 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38167 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726198AbfBUT3F (ORCPT ); Thu, 21 Feb 2019 14:29:05 -0500 Received: by mail-wm1-f68.google.com with SMTP id v26so10383671wmh.3 for ; Thu, 21 Feb 2019 11:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n0Q+QAff76GfhL89YDmI0kJqjN6CgmIygA79rwBjInM=; b=o+qNul56Aw1bumaa8uRmwr1IX7pjTIVnHLnimr2waWlM0+c5uYeeBXM0as4otweqtB ErP90wfGJId3Hl0AvgktlamkCPkKATV/Dh8n229r42Pi18s6ZNzKdEA0ixfHXnTQqKni a1ujE8r4jh6ErVIT+F3kLVrIcINxhnBR31nDyuy/zBAx9glHsdaFqX330dmV3NWIoqhg 42YvPZvj8A8zETDsyFtziRNxgFuxTeORumhbuDwefx3F4gkfuZdIecj1tbjiGzWlPR1I S/JS7mqEM21XBawyy7b5ySdPB7eXkw4+W00ToR81fSzEXeuyExRP/UOZYtORQvW0n7tT GxAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n0Q+QAff76GfhL89YDmI0kJqjN6CgmIygA79rwBjInM=; b=jXCmrlhq0kagOeWl+i8NtwpVwzMh/D/4pGE6HGXERKryeOjZPsFCfs5GJwdN067VGj 3GAW5yIfu1mVrEy4RFyEoGfEwEPZjY17XpOKL7sgM+A+++hCmek/CaJ8qj606b1PGeVW TuHu+4R+xGttnH9SpJorUpUS2HeymHfrJmgvuQQtCElMskoGynWWEjZ5FcigqVXXs51R eR7ZwEihwDAj/odRD6XM+H5QaIc5SMxjtqMP5IWyywgiTdXP0IH78XLpq0Zvaqk/zSEO cUlaCbxNeBkywnaTsr25jU4kGuMaRi3f1vB8F6px8vXlssR9QP8XyqJcnpN8M5PY3PT4 9Z3Q== X-Gm-Message-State: AHQUAubrdIDGJJiirXo9kHsc7Ub4Ttl1C8PYjlrtwuq/czVSIZSxOOd/ xNHqujZiF1L5DQZ+F+74RMqVMFZw X-Google-Smtp-Source: AHgI3IbLcHdl0wmxk0DszvsdGqApXCoS4H0i79/VfY+MthM7kFyX+qo+8p7SitoruKU1QHEvycWAeA== X-Received: by 2002:a1c:f406:: with SMTP id z6mr57759wma.107.1550777343812; Thu, 21 Feb 2019 11:29:03 -0800 (PST) Received: from vm.nix.is ([2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id n2sm35237429wrq.58.2019.02.21.11.29.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 21 Feb 2019 11:29:03 -0800 (PST) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Sebastian Staudt , Josh Steadmon , =?utf-8?q?SZEDER_G=C3=A1bor?= , =?utf-8?b?w4Z2YXIg?= =?utf-8?b?QXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/2] commit-graph tests: fix cryptic unportable "dd" invocation Date: Thu, 21 Feb 2019 20:28:49 +0100 Message-Id: <20190221192849.6581-3-avarab@gmail.com> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change an unportable invocation of "dd" that truncated the commit-graph to call Perl's truncate() function instead. In POSIX it is unspecified what happens when count=0 is provided[1]. The NetBSD "dd" behavior differs from GNU (and seemingly other BSDs), which as left this test broken since d2b86fbaa1 ("commit-graph: fix buffer read-overflow", 2019-01-15). In POSIX the truncate(2) and ftruncate(2) functions are portable. We've used the latter since 271421cd34 ("Update partial HTTP transfers.", 2005-09-30), but the truncate(1) command-line tool is GNU-specific. Thus let's use Perl's version of it. We could also just introduce a "test-tool truncate" in the future if we wanted to avoid shelling out to perl. On Linux and NetBSD we don't need the "if -s $ARGV[0] > $ARGV[1]" condition I'm adding. We never have a $zero_pos longer than the file being truncated. But let's have that condition to future-proof the code, and because "the behavior is undefined if LENGTH is greater than the length of the file" (perldoc -f truncate). 1. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/dd.html Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- t/t5318-commit-graph.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index d4bd1522fe..d99bea6cce 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -382,7 +382,8 @@ corrupt_graph_and_verify() { test_when_finished mv commit-graph-backup $objdir/info/commit-graph && cp $objdir/info/commit-graph commit-graph-backup && printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc && - dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 && + perl -we 'truncate $ARGV[0], $ARGV[1] if -s $ARGV[0] > $ARGV[1]' \ + $objdir/info/commit-graph $zero_pos && generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" && test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err &&