From patchwork Wed Nov 27 19:53:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B582815AB for ; Wed, 27 Nov 2019 19:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95CEF2084D for ; Wed, 27 Nov 2019 19:53:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dwt3Lp8V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727327AbfK0Txh (ORCPT ); Wed, 27 Nov 2019 14:53:37 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:44302 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txg (ORCPT ); Wed, 27 Nov 2019 14:53:36 -0500 Received: by mail-pj1-f66.google.com with SMTP id w8so10533096pjh.11 for ; Wed, 27 Nov 2019 11:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IOdCZHq+8yw7YBBrvExEJd34tyBAih6z43dUJHDP6bw=; b=Dwt3Lp8VVW1UskMskDRPE5IU7vgzEvrDIdM8xeBVIfsf/3Oc3IkPYRbFIhX4kEa2xX xKqtSwGsnSpmYavYhXMZOrRW6KXiCFaezKtL2HZLsVc9MwZNjW3c5mY6WgMCm/kRlo8K PY6WFhp4dJBqDiyIV+a0r5+aEhaWDdcgC9FpuUiTr2yy1OxcPTrsXrM61rHXliGKR8Tf ot94KTAxdURTunagojVcjq67NBJB1TUVcNTV5Ebh9Wbkdm4w/L7o1m3IqghMw1KxWv4g d9tf5gCF+6QvdtSNSiXzUGBHOMJk4Mf01EHhPxPPbR0R/eR/izuogbpzljwi2Fm5OLop CQaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IOdCZHq+8yw7YBBrvExEJd34tyBAih6z43dUJHDP6bw=; b=oqxV8bnsI8Ya9ddgLA0WXU4IJLDKul/TwqcNcGDzMoreLcFkAkZKa4UMUDrPbL2Vdm R5dHlE4NSkYxz/kEVbJUfuw1Ftd5mE7K4f3OPIRxSpLPpyMTBOZcLCNveKHONW0ZKzI2 P/LYQgUca8RhOJq+xkViW3M5tB97y5aJkiWZCg3cptpzbc5CHmPLVuhmGQ3t2JosC/HJ JK8NhwJSi1DFLPxuLhl6VQy1umbYCaTdLrMmgtq2PZyr5Y2+yUHR2lfePQ3wgN1/STpW a08VT49AtULojUrz0nUte12Zzw255SR7p6AouvXDd3sBex8cDOh/PPt2Glj1g3urz/0W RGog== X-Gm-Message-State: APjAAAUa0k6ZrDv7Ro5XXtF9iSi0zmM34Izzpwdbo7J9Wyv6azK/31BF q1cziot4Hy2iq10d5nDZmh3BnYr4 X-Google-Smtp-Source: APXvYqzHMfqsDR/v2TAyXaj8CqAxiqeOAhyO5dtxP7UhlZ0kYaaNw5fjZrXm5joZh7Gah5HP57hKIQ== X-Received: by 2002:a17:902:b610:: with SMTP id b16mr5961995pls.70.1574884415914; Wed, 27 Nov 2019 11:53:35 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id l9sm4150214pgh.34.2019.11.27.11.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:35 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:33 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 13/26] t5317: use ! grep to check for no matching lines Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Several times in t5317, we would use `wc -l` to ensure that a grep result is empty. However, grep already has a way to do that... Its return code! Use `! grep` in the cases where we are ensuring that there are no matching lines. While at it, drop unnecessary invocations of `awk` and `sort` in each affected test since those commands do not influence the outcome. It's not clear why that extra work was being done in the first place, and the code's history doesn't shed any light on the matter since these tests were simply born this way[1], likely due to copy-paste programming. The unnecessary work wasn't noticed even when the code was later touched for various cleanups[2][3]. [1]: 9535ce7337 (pack-objects: add list-objects filtering, 2017-11-21) [2]: bdbc17e86a (tests: standardize pipe placement, 2018-10-05) [3]: 61de0ff695 (tests: don't swallow Git errors upstream of pipes, 2018-10-05) Helped-by: Eric Sunshine Signed-off-by: Denton Liu --- t/t5317-pack-objects-filter-objects.sh | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index a8bbad74e2..dc0446574b 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -45,12 +45,7 @@ test_expect_success 'verify blob:none packfile has no blobs' ' git -C r1 index-pack ../filter.pack && git -C r1 verify-pack -v ../filter.pack >verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l verify_result && - grep blob verify_result | - awk -f print_1.awk | - sort >observed && - - nr=$(wc -l