From patchwork Wed Nov 27 19:53:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264811 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 9E1671863 for ; Wed, 27 Nov 2019 19:53:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7ECA62084D for ; Wed, 27 Nov 2019 19:53:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W4pEZQsJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727176AbfK0TxH (ORCPT ); Wed, 27 Nov 2019 14:53:07 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:39815 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0TxH (ORCPT ); Wed, 27 Nov 2019 14:53:07 -0500 Received: by mail-pj1-f67.google.com with SMTP id v93so7284060pjb.6 for ; Wed, 27 Nov 2019 11:53:06 -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=/8oQyuhlgHZAJtCYHSIRwkFMjgd735KXwMjjOYt4/fU=; b=W4pEZQsJnKN47HATTruI/xTUbxecFPcUdcsT9UruhO0XXTS8Vmy6kOzujfs30c96Sm NxCQaC6vjktcU3gNEaDy1+62Ewl9QkPz55woJNC7MnpHfCSGutqY0yKgh465p+P2AIoP z9GnkfwXQvZ9mf5/KDUvpvfYE3xTZFUQc61iaHaCqQovXHojPifWoAvY9LQiA24ashX4 TQqZfxUbXc+a39rbKldRGDoh3GBJbYHoirSaU/36LXAFBzCWAQ+NvvYhsE7t5TzSuQNM ivnu2Xbj3XaGxqpldVkBAzEJOMiH3K4bCoQdYxTFoOInwBDZ2ExsKzBlcGWRh1meIGTL rw3g== 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=/8oQyuhlgHZAJtCYHSIRwkFMjgd735KXwMjjOYt4/fU=; b=TJbuD+z+1en7uHmG0Dfi7k4iXmsaDbgdY0rUO7mW5khSGf3E370Pyf2NxyYJOxRwv7 2u4svKOxWQK8Ri3VhWfVkqvzFT0b7Rb8zUilhy0ZGqUzI34dGtODg5lsVohTNHgoB86r UiRhr4vMK/eXSPanLIFcz6j5EZ8tuoM2zZsBqnH+jYH87jsDrwITW+X/yJzq2GlPU865 lMjND3Se337fowuucc7rYbZ8ozXC21rUug+ZaD4M9bElWdI1OGEJzaH5d/fZUd0h8Vht f3H3yDPtMTfa70VLBZwdZM0vRlgjeAhaeROvPScqL9fsXUE4eczPaVPWnEpgwv+GX18k Jllw== X-Gm-Message-State: APjAAAXvfQqy7GCM6BnmlK3sRw9gai9BunPdQIbCM2fQBatJVTvnFV7Q qa3egG3ZSjGEI+tItYlD1h61UNfA X-Google-Smtp-Source: APXvYqyUSooxvdq/2XFY6WCSIZtjmMTlPjpM8FewHWTLL2QT2RYWT1N7PSPAQBGg5jiKRo+2ZyfqqA== X-Received: by 2002:a17:902:860a:: with SMTP id f10mr3845825plo.326.1574884386056; Wed, 27 Nov 2019 11:53:06 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id j126sm18339934pfg.4.2019.11.27.11.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:05 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:03 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 01/26] lib-bash.sh: move `then` onto its own line Message-ID: <9085cc00af10408d9425cfdff5a8b2c49008ae7b.1574884302.git.liu.denton@gmail.com> 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 The code style for tests is to have statements on their own line if possible. Move the `then` onto its own line so that it conforms with the test style. Signed-off-by: Denton Liu --- t/lib-bash.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/lib-bash.sh b/t/lib-bash.sh index 2be955fafb..b0b6060929 100644 --- a/t/lib-bash.sh +++ b/t/lib-bash.sh @@ -2,10 +2,12 @@ # to run under Bash; primarily intended for tests of the completion # script. -if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then +if test -n "$BASH" && test -z "$POSIXLY_CORRECT" +then # we are in full-on bash mode true -elif type bash >/dev/null 2>&1; then +elif type bash >/dev/null 2>&1 +then # execute in full-on bash mode unset POSIXLY_CORRECT exec bash "$0" "$@" From patchwork Wed Nov 27 19:53:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264813 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 2AB32138C for ; Wed, 27 Nov 2019 19:53:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A1FC20835 for ; Wed, 27 Nov 2019 19:53:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UZ6/qnaU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbfK0TxK (ORCPT ); Wed, 27 Nov 2019 14:53:10 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41873 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0TxJ (ORCPT ); Wed, 27 Nov 2019 14:53:09 -0500 Received: by mail-pf1-f193.google.com with SMTP id s18so3058342pfd.8 for ; Wed, 27 Nov 2019 11:53:09 -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=zgQrv7WEr9BNerWgrMuku+xWg7Wefls9OMP9Y4CHDT8=; b=UZ6/qnaUmoRlrwlzwXHem5SX8u580wdI5JZGGWzNxTiBzxecLF+HYOSHe+afIgXtno +42/GvyTMpwjvmBinFpsfX5li0sFP3bb335lh4jXOCCJtn+jrK7TMAQul4C6saZumCSg Gf9qd9uJNu6PsJC9Vz7IzwcWPvQsO6glML5aHyxNCX5yZFlXVK4kOk99FJuZQCCiF/A4 O+GBZSWJg0zvEntUwc6p7YNZt5fw93erUbX8v7voUFaZJsvblU3GQt6yz16zLDHVMQ5G XH/Xd96/x7AMIzStib/u0Bo0/df1thWgXyKDbqfKr2ICBjRD1hvmT4XW4LoA0fAhyrtn D4iA== 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=zgQrv7WEr9BNerWgrMuku+xWg7Wefls9OMP9Y4CHDT8=; b=lMSmiKZII6xIqihva+nCGJDv/TgTtT5vMkFIkQ9cWsA5IMCCtsTvSHTaa2v1u8tcYe QPjHx3aBL4T9hfPtr2PubvNRjtXRKTuXyKPRaynftQRllr358+lg1tOrDaysTQ/hws3V G1bZ0lL2PNxGE7Jb6kCteBr+NpYWDH1r8ladGqYNoIoBJ4CCn2fBQO+kpkUc63z+NKla qgSqURiasGOxSTP45vCMAkZKaOV16pxaQsbMlq9IVEs5IXmKsjSFHE793LwD1jFr77+k ZAMAedkz+vXhbxaywqgOZHc2z4Xlm/nd3fukrrHaBYDBULi2Pd0Wg/uHxGW7MahoM7I1 VpXA== X-Gm-Message-State: APjAAAW8ZP0/TQgcEMEYjXQ3oR9E5/6WDjFToXrgS86dDYlSd3bnNwRq lWgVrjwW0WlyQh8RDRXS6SJyl21g X-Google-Smtp-Source: APXvYqzv3tcf+bQXPDbh+Kbe6S0ILlR7py+3BE5YYlVAgRRtmOHCHQJSL2AcH6yLqC5Vjj9M/095jg== X-Received: by 2002:aa7:8dcf:: with SMTP id j15mr50153077pfr.233.1574884388497; Wed, 27 Nov 2019 11:53:08 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id f30sm17181010pga.20.2019.11.27.11.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:07 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:06 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 02/26] apply-one-time-sed.sh: modernize style Message-ID: <86f625c65e00b24d1de183c3a993e6acb7c8325e.1574884302.git.liu.denton@gmail.com> 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 Convert `[ ... ]` to use `test` and test for the existence of a regular file (`-f`) instead of any file (`-e`). Move the `then`s onto their own lines so that it conforms with the general test style. Instead of redirecting input into sed, allow it to open its own input. Use `cmp -s` instead of `diff` since we only care about whether the two files are equal and `diff` is overkill for this. Signed-off-by: Denton Liu --- t/lib-httpd/apply-one-time-sed.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/t/lib-httpd/apply-one-time-sed.sh b/t/lib-httpd/apply-one-time-sed.sh index fcef728925..bf7689d020 100644 --- a/t/lib-httpd/apply-one-time-sed.sh +++ b/t/lib-httpd/apply-one-time-sed.sh @@ -7,11 +7,13 @@ # # This can be used to simulate the effects of the repository changing in # between HTTP request-response pairs. -if [ -e one-time-sed ]; then +if test -f one-time-sed +then "$GIT_EXEC_PATH/git-http-backend" >out - sed "$(cat one-time-sed)" out_modified + sed "$(cat one-time-sed)" out >out_modified - if diff out out_modified >/dev/null; then + if cmp -s out out_modified + then cat out else cat out_modified From patchwork Wed Nov 27 19:53:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264815 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 5D459138C for ; Wed, 27 Nov 2019 19:53:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AF6D2084D for ; Wed, 27 Nov 2019 19:53:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YE+HKBkz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727230AbfK0TxN (ORCPT ); Wed, 27 Nov 2019 14:53:13 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:41143 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727193AbfK0TxN (ORCPT ); Wed, 27 Nov 2019 14:53:13 -0500 Received: by mail-pg1-f194.google.com with SMTP id l26so1315310pgb.8 for ; Wed, 27 Nov 2019 11:53:11 -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=r8wt0iElzEdlUVR3u3fJA/vaW3ImQKr4auWa7LRPo7c=; b=YE+HKBkzB93REg5U3doRq1ynKzvjVNRQiTPrh2XIjcYjnm5L6/8x/Yf9thmz2VLpCY IOZMzrkMI1iRq972z4r9M6kgN/YM3WjffkTX3Vg6kmNwOtvKcrqu8D/T5M5GsX/edkdq ZJ5lc9Oycfwa/RLvcZXg0MdIPhSvaw3dNFRs8RGNDjPTf/HgbsxAz58GybktLNOF9Xot 7kQX5xfQ81PPWhFGbRvP8U+KxwUhqFHOQ9DagDAjAU15RwQ1HAUeRhfRJ623RrneADN1 QJ3LVdsdURaNIn0hMAuJrdBixM+BYUI4Nllg46OimRp6r0uBIO70Jm04Cp4J6JGN9wsw s8cA== 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=r8wt0iElzEdlUVR3u3fJA/vaW3ImQKr4auWa7LRPo7c=; b=X8vmlpbK6Xret8e8/kzOYGmxy8Z1QdbGfh0RWh4Kh+xCTB/vTIA6G8X3LOUZF4hn3o svi7aomXYiUeRwvYpzK+qYcqX4g44PKF6sO6r8KGFoOnrL8PQOdlKRH8yo5GM7i7rUva +dhu2fcmYezFMIemf37cK3h0Rmit5VodVkj/2sEL0Tc6rEy2yv1T5Tj/POvK29v4cYTf BGYIdOTDj0gk8pw/i2JdobNr3Zm0qVCzaWFKi3luInIJEBjmtilVao8GIG2wV32GrX1B klN48RjBNU44smvlZU+QuodLjmEKnwBHOt7PDbALF4pPDYcaFX6VQ4a/2nF94uyBMun0 NvHA== X-Gm-Message-State: APjAAAWfEsdiuegZfyc8rMD64MRB9pc8prfk6UsLDdEP/u8msgXTDSsI SfB0keEJgLKwx2axlsP6KNZYqOgu X-Google-Smtp-Source: APXvYqxHsTBB9WzvWy5CuW8Hmlu8YcFOG6QvDHe3U/jtgl57YeJt1TJXxJ8ngjf2bMrExCvC9+dVvw== X-Received: by 2002:a63:e647:: with SMTP id p7mr7098902pgj.47.1574884390985; Wed, 27 Nov 2019 11:53:10 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id e8sm17519161pga.17.2019.11.27.11.53.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:10 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:08 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 03/26] t0014: remove git command upstream of pipe Message-ID: <3844e00367de57ec09b1e3282280fd20dd807c0b.1574884302.git.liu.denton@gmail.com> 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 Before, the `git frotz` command would fail but its return code was hidden since it was in the upstream of a pipe. Break the pipeline into two commands so that the return code is no longer lost. Also, mark `git frotz` with test_must_fail since it's supposed to fail. Signed-off-by: Denton Liu --- t/t0014-alias.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index 2694c81afd..8d3d9144c0 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -38,8 +38,8 @@ test_expect_success 'looping aliases - internal execution' ' #' test_expect_success 'run-command formats empty args properly' ' - GIT_TRACE=1 git frotz a "" b " " c 2>&1 | - sed -ne "/run_command:/s/.*trace: run_command: //p" >actual && + test_must_fail env GIT_TRACE=1 git frotz a "" b " " c 2>actual.raw && + sed -ne "/run_command:/s/.*trace: run_command: //p" actual.raw >actual && echo "git-frotz a '\'''\'' b '\'' '\'' c" >expect && test_cmp expect actual ' From patchwork Wed Nov 27 19:53:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264817 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 8E0B815AB for ; Wed, 27 Nov 2019 19:53:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DA762082D for ; Wed, 27 Nov 2019 19:53:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PSVwLkQW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727237AbfK0TxP (ORCPT ); Wed, 27 Nov 2019 14:53:15 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45197 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0TxO (ORCPT ); Wed, 27 Nov 2019 14:53:14 -0500 Received: by mail-pl1-f193.google.com with SMTP id w7so10275080plz.12 for ; Wed, 27 Nov 2019 11:53:14 -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=BJOtIL+cfbhl9dwPpTN/bZ6NZM7pqVzyL6qjSsZmjfU=; b=PSVwLkQWI2yLuMw/shdyg7ZsBUzHICSpK+0cUABlFeVjUWDI8ydrKKEcJK7ngTmmqg MYRJY6gLTvV7WEcC//oSposLIqS7K1KeAkAkcWocmoNeO6/y5V6T5bk9ngPZ7aQqS8wz 4DP+uaJoRzS5R5O9y582Ftvt4tjoiVU3IgO8ANWvZWO9G4tj02t2D3IOTNkKqDwFBQV4 jOVP5Sia/s53DFfGNv0t5Yo8pBfxWJELa0el2/p96s3F0SQRWjz937Y72BGI9FddDaey POum52w7dsj2fyse8wnyDSoGRfyoMqinmy2ncRf7xs3/bt9Ua0hcP7n4KFSnWOfwlXP4 Jk2A== 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=BJOtIL+cfbhl9dwPpTN/bZ6NZM7pqVzyL6qjSsZmjfU=; b=RhF1z8UXxEyPksajAc967YINGAliLlF9LDy9wHiuZqOuy6R9XK8277lxzhLbF32OGQ s6omrJXap0BTwxv3S361bjU738j1jYNi6fADTE4fbvo6dVWL5fXkb1REZjV4798Wo0+Y jb5lkyiHdnj9harZL+a6U7Mtp+k2VuEqg1TogUFHMGlkU8G2xz6Ylpxd4DVBi/JrLLl9 c8PAGAcYsSlyZnEuRM3IBy14b93oJa7EkP5It2eRBzN4fl4q4yHMfjgRAFRBVme/f1al NcFJRmPR8XZ0FAGNNmPWd3Mx1noes/bqO6HYLXZFOfrp/U93SMiYduGC9z9ELAUcq3rp JoaQ== X-Gm-Message-State: APjAAAWcOkh21GoceTwl5iBE7bcm37IWn1B2DFCPsTjzc+Rv7/y5bzss tNn78T3wlUD62wCmoWTNHynp0BAd X-Google-Smtp-Source: APXvYqwHwhg36RZ7poLYU72AUv5xLUyhKXSssk9UqgcuGmkiBc0WXAy4LrijbGc1Kt+LXCA7LSBi0g== X-Received: by 2002:a17:90a:77c8:: with SMTP id e8mr7824816pjs.83.1574884393450; Wed, 27 Nov 2019 11:53:13 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id a25sm16919261pff.50.2019.11.27.11.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:12 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:11 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 04/26] t0090: stop losing return codes of git commands Message-ID: <7d33586b214f8dfd8e027b3bc618ca908799b560.1574884302.git.liu.denton@gmail.com> 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 In generate_expected_cache_tree_rec(), there are currently two instances of `git ls-files` in the upstream of a pipe. In the case where the upstream git command fails, its return code will be lost. Extract the `git ls-files` into its own call so that if it ever fails, its return code is not lost. Signed-off-by: Denton Liu --- t/t0090-cache-tree.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh index ce9a4a5f32..5a633690bf 100755 --- a/t/t0090-cache-tree.sh +++ b/t/t0090-cache-tree.sh @@ -21,9 +21,10 @@ generate_expected_cache_tree_rec () { parent="$2" && # ls-files might have foo/bar, foo/bar/baz, and foo/bar/quux # We want to count only foo because it's the only direct child - subtrees=$(git ls-files|grep /|cut -d / -f 1|uniq) && + git ls-files >files && + subtrees=$(grep / files|cut -d / -f 1|uniq) && subtree_count=$(echo "$subtrees"|awk -v c=0 '$1 != "" {++c} END {print c}') && - entries=$(git ls-files|wc -l) && + entries=$(wc -l X-Patchwork-Id: 11264819 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 C03D515AB for ; Wed, 27 Nov 2019 19:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8ED712084D for ; Wed, 27 Nov 2019 19:53:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q9Y9UncP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbfK0TxR (ORCPT ); Wed, 27 Nov 2019 14:53:17 -0500 Received: from mail-pl1-f182.google.com ([209.85.214.182]:32964 "EHLO mail-pl1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0TxR (ORCPT ); Wed, 27 Nov 2019 14:53:17 -0500 Received: by mail-pl1-f182.google.com with SMTP id ay6so10322126plb.0 for ; Wed, 27 Nov 2019 11:53:16 -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=+ns3Wsm0v8U1P5UtUChzWERj0SEo4IKy9kvD2LP/Zvo=; b=Q9Y9UncPnW4VVUvU2S0WVndVKcGX30e9BB9+Hndgqzx5Y1B0a/bdCHXIpiJgLGX1Qp kPm5Zgs6x+X8LtbtCXyyxGiFS9KGA/hFVugZxtNUZSyELQNVH+2hErdp0CWhMtNjx/2u +B/H8762E9E3sdkJj7YAappC5EPEFC4d8ckmnNsUZSVD8HFWD3jDtEVtbxXoTSLub+/J 8GZyFBhj9jsrp4m3lTrqjIylqiUa6uXkx6FrQJVNHZpDyxjjT9csG/1cU6GYTKQQvvpV 9yxybPOvtOuGZJV7VbWvqLec7EhHIveL3YASE5MFiEZx7j+aWQiW1po9Wxqkxkp5CzW1 ZCEQ== 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=+ns3Wsm0v8U1P5UtUChzWERj0SEo4IKy9kvD2LP/Zvo=; b=e9Kh0aOuZmfpLJiwNehtHOaPjVqdp2cZ3iIGplTYnh7Xb+3ouxyUTJrflC0ZEXva9X /mwaGMAQFgFmR8H4bW2IOVHDAzQk2+2hYpTwKUEUcCKO/S5R+i61U6GkGYYTyo/BBKL6 uZrc61SnpwleUwzqM6c0UHRGOqAiTkM+NbpmP0GN0rWwwgDojZ5hqU5m3COR70xwp68Z AC2sz8vpANxm451Tgj3iDLD0j35izbnvctD7U5AHsIEv4Star1n4DEB8M36A0h7MCYOD nsk6ZwomQE6xnPd5EaChaUIcZv2qJGVJTmQRk6I6ZQklGsJ5GcQBjOSTYeMhtyP/E78Z fiNQ== X-Gm-Message-State: APjAAAXIz+soy4ISIasjm76jYDa+UGly524V//LjmpCdxeGElOlGBouY iMtelRoXiY6l7uabBNYsPKoAWeHm X-Google-Smtp-Source: APXvYqzgr72Q4ngODgNzrHwL1zu6iOppEXaEmHKqbsT69KiFgsnSw+Z0R4fu1gndgBF/e58ViQBALg== X-Received: by 2002:a17:90a:5d17:: with SMTP id s23mr7770075pji.55.1574884395834; Wed, 27 Nov 2019 11:53:15 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id y17sm17295330pfl.92.2019.11.27.11.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:15 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:13 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 05/26] t3301: stop losing return codes of git commands 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 Currently, there are two ways where the return codes of git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream. The other way is when a command is in a non-assignment command substitution. The return code will be lost in favour of the surrounding command's. Rewrite instances of this so that git commands are either run on their own or in an assignment-only command substitution. This patch fixes a real buggy test: in 'copy note with "git notes copy"', `git notes` was mistyped as `git note`. Signed-off-by: Denton Liu --- t/t3301-notes.sh | 230 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 163 insertions(+), 67 deletions(-) diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index d66a5f6faa..8f43303007 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh @@ -54,7 +54,9 @@ test_expect_success 'create notes' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b4" = "$(git notes show)" && + echo b4 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -79,14 +81,21 @@ test_expect_success 'edit existing notes' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b3" = "$(git notes show)" && + echo b3 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' test_expect_success 'show notes from treeish' ' - test "b3" = "$(git notes --ref commits^{tree} show)" && - test "b4" = "$(git notes --ref commits@{1} show)" + echo b3 >expect && + git notes --ref commits^{tree} show >actual && + test_cmp expect actual && + + echo b4 >expect && + git notes --ref commits@{1} show >actual && + test_cmp expect actual ' test_expect_success 'cannot edit notes from non-ref' ' @@ -99,7 +108,9 @@ test_expect_success 'cannot "git notes add -m" where notes already exists' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b3" = "$(git notes show)" && + echo b3 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -109,7 +120,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f -m"' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b1" = "$(git notes show)" && + echo b1 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -119,7 +132,9 @@ test_expect_success 'add w/no options on existing note morphs into edit' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b2" = "$(git notes show)" && + echo b2 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -129,7 +144,9 @@ test_expect_success 'can overwrite existing note with "git notes add -f"' ' test_path_is_missing .git/NOTES_EDITMSG && git ls-tree -r refs/notes/commits >actual && test_line_count = 1 actual && - test "b1" = "$(git notes show)" && + echo b1 >expect && + git notes show >actual && + test_cmp expect actual && git show HEAD^ && test_must_fail git notes show HEAD^ ' @@ -146,7 +163,8 @@ test_expect_success 'show notes' ' Notes: ${indent}b1 EOF - ! (git cat-file commit HEAD | grep b1) && + git cat-file commit HEAD >commits && + ! grep b1 commits && git log -1 >actual && test_cmp expect actual ' @@ -472,9 +490,11 @@ test_expect_success 'removing with --stdin --ignore-missing' ' test_expect_success 'list notes with "git notes list"' ' commit_2=$(git rev-parse 2nd) && commit_3=$(git rev-parse 3rd) && + note_2=$(git rev-parse refs/notes/commits:$commit_2) && + note_3=$(git rev-parse refs/notes/commits:$commit_3) && sort -t" " -k2 >expect <<-EOF && - $(git rev-parse refs/notes/commits:$commit_2) $commit_2 - $(git rev-parse refs/notes/commits:$commit_3) $commit_3 + $note_2 $commit_2 + $note_3 $commit_3 EOF git notes list >actual && test_cmp expect actual @@ -486,9 +506,7 @@ test_expect_success 'list notes with "git notes"' ' ' test_expect_success 'list specific note with "git notes list "' ' - cat >expect <<-EOF && - $(git rev-parse refs/notes/commits:$commit_3) - EOF + git rev-parse refs/notes/commits:$commit_3 >expect && git notes list HEAD^^ >actual && test_cmp expect actual ' @@ -512,10 +530,11 @@ test_expect_success 'append to existing note with "git notes append"' ' test_expect_success '"git notes list" does not expand to "git notes list HEAD"' ' commit_5=$(git rev-parse 5th) && + note_5=$(git rev-parse refs/notes/commits:$commit_5) && sort -t" " -k2 >expect_list <<-EOF && - $(git rev-parse refs/notes/commits:$commit_2) $commit_2 - $(git rev-parse refs/notes/commits:$commit_3) $commit_3 - $(git rev-parse refs/notes/commits:$commit_5) $commit_5 + $note_2 $commit_2 + $note_3 $commit_3 + $note_5 $commit_5 EOF git notes list >actual && test_cmp expect_list actual @@ -721,7 +740,8 @@ test_expect_success 'Allow notes on non-commits (trees, blobs, tags)' ' git notes show HEAD: >actual && test_cmp expect actual && echo "Note on a blob" >expect && - filename=$(git ls-tree --name-only HEAD | head -n1) && + git ls-tree --name-only HEAD >files && + filename=$(head -n1 files) && git notes add -m "Note on a blob" HEAD:$filename && git notes show HEAD:$filename >actual && test_cmp expect actual && @@ -745,10 +765,13 @@ test_expect_success 'create note from other note with "git notes add -C"' ' Notes: ${indent}order test EOF - git notes add -C $(git notes list HEAD^) && + note=$(git notes list HEAD^) && + git notes add -C $note && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'create note from non-existing note with "git notes add -C" fails' ' @@ -777,11 +800,12 @@ test_expect_success 'create note from blob with "git notes add -C" reuses blob i Notes: ${indent}This is a blob object EOF - blob=$(echo "This is a blob object" | git hash-object -w --stdin) && - git notes add -C $blob && + echo "This is a blob object" | git hash-object -w --stdin >blob && + git notes add -C $(cat blob) && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$blob" + git notes list HEAD >actual && + test_cmp blob actual ' test_expect_success 'create note from other note with "git notes add -c"' ' @@ -797,7 +821,8 @@ test_expect_success 'create note from other note with "git notes add -c"' ' Notes: ${indent}yet another note EOF - MSG="yet another note" git notes add -c $(git notes list HEAD^^) && + note=$(git notes list HEAD^^) && + MSG="yet another note" git notes add -c $note && git log -1 >actual && test_cmp expect actual ' @@ -822,7 +847,8 @@ test_expect_success 'append to note from other note with "git notes append -C"' ${indent} ${indent}yet another note EOF - git notes append -C $(git notes list HEAD^) HEAD^ && + note=$(git notes list HEAD^) && + git notes append -C $note HEAD^ && git log -1 HEAD^ >actual && test_cmp expect actual ' @@ -839,7 +865,8 @@ test_expect_success 'create note from other note with "git notes append -c"' ' Notes: ${indent}other note EOF - MSG="other note" git notes append -c $(git notes list HEAD^) && + note=$(git notes list HEAD^) && + MSG="other note" git notes append -c $note && git log -1 >actual && test_cmp expect actual ' @@ -858,7 +885,8 @@ test_expect_success 'append to note from other note with "git notes append -c"' ${indent} ${indent}yet another note EOF - MSG="yet another note" git notes append -c $(git notes list HEAD) && + note=$(git notes list HEAD) && + MSG="yet another note" git notes append -c $note && git log -1 >actual && test_cmp expect actual ' @@ -878,7 +906,9 @@ test_expect_success 'copy note with "git notes copy"' ' git notes copy 8th 4th && git log 3rd..4th >actual && test_cmp expect actual && - test "$(git note list 4th)" = "$(git note list 8th)" + git notes list 4th >expect && + git notes list 8th >actual && + test_cmp expect actual ' test_expect_success 'copy note with "git notes copy" with default' ' @@ -899,14 +929,30 @@ test_expect_success 'copy note with "git notes copy" with default' ' git notes copy HEAD^ && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'prevent overwrite with "git notes copy"' ' test_must_fail git notes copy HEAD~2 HEAD && + cat >expect <<-EOF && + commit $commit + Author: A U Thor + Date: Thu Apr 7 15:23:13 2005 -0700 + + ${indent}11th + + Notes: + ${indent}other note + ${indent} + ${indent}yet another note + EOF git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD^)" + git notes list HEAD^ >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'allow overwrite with "git notes copy -f"' ' @@ -924,7 +970,9 @@ test_expect_success 'allow overwrite with "git notes copy -f"' ' git notes copy -f HEAD~3 HEAD && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD~3)" + git notes list HEAD~3 >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'allow overwrite with "git notes copy -f" with default' ' @@ -944,7 +992,9 @@ test_expect_success 'allow overwrite with "git notes copy -f" with default' ' git notes copy -f HEAD~2 && git log -1 >actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" + git notes list HEAD~2 >expect && + git notes list HEAD >actual && + test_cmp expect actual ' test_expect_success 'cannot copy note from object without notes' ' @@ -979,13 +1029,21 @@ test_expect_success 'git notes copy --stdin' ' ${indent} ${indent}yet another note EOF - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --stdin && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --stdin actual && test_cmp expect actual && - test "$(git notes list HEAD)" = "$(git notes list HEAD~2)" && - test "$(git notes list HEAD^)" = "$(git notes list HEAD~3)" + git notes list HEAD~2 >expect && + git notes list HEAD >actual && + test_cmp expect actual && + git notes list HEAD~3 >expect && + git notes list HEAD^ >actual && + test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' @@ -1006,9 +1064,13 @@ test_expect_success 'git notes copy --for-rewrite (unconfigured)' ' ${indent}14th EOF - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1041,17 +1103,23 @@ test_expect_success 'git notes copy --for-rewrite (enabled)' ' EOF test_config notes.rewriteMode overwrite && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD~3) $(git rev-parse HEAD^) && - echo $(git rev-parse HEAD~2) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD^) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD~2) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' test_expect_success 'git notes copy --for-rewrite (disabled)' ' test_config notes.rewrite.bar false && - echo $(git rev-parse HEAD~3) $(git rev-parse HEAD) | - git notes copy --for-rewrite=bar && + from=$(git rev-parse HEAD~3) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=bar actual && test_cmp expect actual ' @@ -1071,8 +1139,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' git notes add -f -m"a fresh note" HEAD^ && test_config notes.rewriteMode overwrite && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1080,8 +1150,10 @@ test_expect_success 'git notes copy --for-rewrite (overwrite)' ' test_expect_success 'git notes copy --for-rewrite (ignore)' ' test_config notes.rewriteMode ignore && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1103,8 +1175,10 @@ test_expect_success 'git notes copy --for-rewrite (append)' ' git notes add -f -m"another fresh note" HEAD^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1131,9 +1205,13 @@ test_expect_success 'git notes copy --for-rewrite (append two to one)' ' git notes add -f -m"append 2" HEAD^^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - (echo $(git rev-parse HEAD^) $(git rev-parse HEAD) && - echo $(git rev-parse HEAD^^) $(git rev-parse HEAD)) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + from=$(git rev-parse HEAD^^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >>copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1142,8 +1220,10 @@ test_expect_success 'git notes copy --for-rewrite (append empty)' ' git notes remove HEAD^ && test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1163,8 +1243,10 @@ test_expect_success 'GIT_NOTES_REWRITE_MODE works' ' test_config notes.rewriteMode concatenate && test_config notes.rewriteRef "refs/notes/*" && git notes add -f -m"replacement note 1" HEAD^ && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | - GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo && + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && + GIT_NOTES_REWRITE_MODE=overwrite git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1184,9 +1266,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF works' ' git notes add -f -m"replacement note 2" HEAD^ && test_config notes.rewriteMode overwrite && test_unconfig notes.rewriteRef && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && GIT_NOTES_REWRITE_REF=refs/notes/commits:refs/notes/other \ - git notes copy --for-rewrite=foo && + git notes copy --for-rewrite=foo actual && test_cmp expect actual ' @@ -1195,9 +1279,11 @@ test_expect_success 'GIT_NOTES_REWRITE_REF overrides config' ' git notes add -f -m"replacement note 3" HEAD^ && test_config notes.rewriteMode overwrite && test_config notes.rewriteRef refs/notes/other && - echo $(git rev-parse HEAD^) $(git rev-parse HEAD) | + from=$(git rev-parse HEAD^) && + to=$(git rev-parse HEAD) && + echo "$from" "$to" >copy && GIT_NOTES_REWRITE_REF=refs/notes/commits \ - git notes copy --for-rewrite=foo && + git notes copy --for-rewrite=foo actual && grep "replacement note 3" actual ' @@ -1212,26 +1298,36 @@ test_expect_success 'git notes copy diagnoses too many or too few parameters' ' test_expect_success 'git notes get-ref expands refs/heads/master to refs/notes/refs/heads/master' ' test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && - test "$(git notes --ref=refs/heads/master get-ref)" = "refs/notes/refs/heads/master" + echo refs/notes/refs/heads/master >expect && + git notes --ref=refs/heads/master get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (no overrides)' ' test_unconfig core.notesRef && sane_unset GIT_NOTES_REF && - test "$(git notes get-ref)" = "refs/notes/commits" + echo refs/notes/commits >expect && + git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (core.notesRef)' ' test_config core.notesRef refs/notes/foo && - test "$(git notes get-ref)" = "refs/notes/foo" + echo refs/notes/foo >expect && + git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (GIT_NOTES_REF)' ' - test "$(GIT_NOTES_REF=refs/notes/bar git notes get-ref)" = "refs/notes/bar" + echo refs/notes/bar >expect && + GIT_NOTES_REF=refs/notes/bar git notes get-ref >actual && + test_cmp expect actual ' test_expect_success 'git notes get-ref (--ref)' ' - test "$(GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref)" = "refs/notes/baz" + echo refs/notes/baz >expect && + GIT_NOTES_REF=refs/notes/bar git notes --ref=baz get-ref >actual && + test_cmp expect actual ' test_expect_success 'setup testing of empty notes' ' From patchwork Wed Nov 27 19:53:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264821 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 DCA23138C for ; Wed, 27 Nov 2019 19:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC31420835 for ; Wed, 27 Nov 2019 19:53:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H9kXxbhe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727287AbfK0TxT (ORCPT ); Wed, 27 Nov 2019 14:53:19 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:38781 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726729AbfK0TxT (ORCPT ); Wed, 27 Nov 2019 14:53:19 -0500 Received: by mail-pj1-f65.google.com with SMTP id f7so10551499pjw.5 for ; Wed, 27 Nov 2019 11:53:18 -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=Dxh2jaW1UxAziQYQjHScRCLmQiudoN4gja7P1jegEhY=; b=H9kXxbheIjylpxQKrx0g7wpmQ7z9gbWH95Lp7rIhNqBLmkOl+V6FeDj+YfVxZCxNZ5 KRYToU9RYE93ZPVy0fbjmOFv9OZbH2vhPL/uT0pcS5gsbGLFTxJXfifkM4m022Lufm1L 3GK99VZ3xsUpSfNxOwT3x/yK2lbkFRh38tF1D/s+OCwaiOyh3pyTWRuDaBnWbG2Ykltw aZStoqvmCx8G+Bfv5inCg6T3cBfOqgjjvBCEWAhF53ARPhaIfehONBwddh5nPGTK/2ci a32mjTNn3bt9eUs4V8+Ghnx3SVRoSi5xM3iN+qaLCrLkQVFfgHM5l7h02SjHqks84Ina Cemw== 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=Dxh2jaW1UxAziQYQjHScRCLmQiudoN4gja7P1jegEhY=; b=EmHw3Znl2kzTWnsxVXSrIf0VD0fMuVynh/VTinQIPlofxywBFV1tUgMDj3s2O4pMbm DdPFADc1FIE9rQCFAR2C3fFPJjLY1R3ox/A2jNUUmtFROSw1h2HuLlzCSVVw9raWyDjf eC2iXLsYMx41qdX1K06eMzkS4p4dUZ3ZH9DvlaE+mO+dKdq/ViJAG0HZHh0xMwaHG4iM gbdC7ubKItBQZNCk3AkUGP3s1Q4yRbnbMB6HfoGcPqrIDcz6ZYhVkpOqtvQjMFH649iT HXTZrtHEHj2X6/IxRBgxuErPIYhH7412R4jSo7AKOT0Z8gobPo6yls2ioMF69npts6qI jPNw== X-Gm-Message-State: APjAAAUYius9T4kWoGg+3OROOjrU/eCMoPvzG/nwvH4ANkoIh+qA7NlY jyoO8VL95BmDPgGpS39lHxqaYX52 X-Google-Smtp-Source: APXvYqxnHwFpulAWHpboIvraajbotzZTZKCECvvfKIFfJmMwYZezckfLitc4EaII7zMWfVx8wGlxvQ== X-Received: by 2002:a17:90a:34c7:: with SMTP id m7mr7966262pjf.103.1574884398042; Wed, 27 Nov 2019 11:53:18 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id x4sm7293833pgg.61.2019.11.27.11.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:17 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:16 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 06/26] t3600: use test_line_count() where possible 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 Since we have a helper function that can test the number of lines in a file that gives better debugging information on failure, use test_line_count() to test the number of lines. Signed-off-by: Denton Liu --- t/t3600-rm.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 8c8cca5bfb..f6e659b7e9 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -113,9 +113,10 @@ test_expect_success '"rm" command printed' ' echo frotz >test-file && git add test-file && git commit -m "add file for rm test" && - git rm test-file >rm-output && - test $(grep "^rm " rm-output | wc -l) = 1 && - rm -f test-file rm-output && + git rm test-file >rm-output.raw && + grep "^rm " rm-output.raw >rm-output && + test_line_count = 1 rm-output && + rm -f test-file rm-output.raw rm-output && git commit -m "remove file from rm test" ' From patchwork Wed Nov 27 19:53:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264823 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 DA24915AB for ; Wed, 27 Nov 2019 19:53:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA01420835 for ; Wed, 27 Nov 2019 19:53:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cqu7+fS4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbfK0TxX (ORCPT ); Wed, 27 Nov 2019 14:53:23 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:37072 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0TxV (ORCPT ); Wed, 27 Nov 2019 14:53:21 -0500 Received: by mail-pj1-f67.google.com with SMTP id bb19so6999085pjb.4 for ; Wed, 27 Nov 2019 11:53:21 -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=/2KT3kKWIIcN5EEEvD1lTeDl+prBaH3cSls3K6bAnXc=; b=cqu7+fS4yikeY645gXSbHy87iCBV6Dl+U8OELlOyy6/EAREZ2QCcUhdd6d9mmdURMm Mab4N7TgjxR6a1Rh3PHOPUZH1jAhH9FZVgGygGoHLMvNQJkW6Qa/Uh7STHwsh0YiXol2 qAEVWITnd09H4Bmu0Npxsi5AlZJ9GzPH0EXXhBJ3762tQARTbMJQhmXWBXKAasMQnJTR VkPH0jlwU07WP6xTffONsvDPPlrNxuTVeASKK4Fqti089iWp7Y8Ufkbqc0Yh+WfPBv7T TJptY498OU/CS6uJBAz5EYNpyN6QvW4xDNdlWr0W8zoHKdcKt+s/oP7PpGJKL3tTeqkI Pw6w== 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=/2KT3kKWIIcN5EEEvD1lTeDl+prBaH3cSls3K6bAnXc=; b=kq3WPNTb+EqtJN/dDqK5MScRO2bEcRGePV/TbFdgtUOFsbodAucKmshtJdTdXwRaCG fybIHn9icLbnY3z4vWQgFRWC6ZB5z53hiONt40eFHHR9QctRvn4ZW3oZ6ZksryQfBztZ HqIEY9fp1xCVNvPfglt8gn42A4t0j3+x8BBfn7p2sg7VOj8N6CUFN7x+AhyGeUJtBAnL q50lpktPlCvrYZmdMmkSaCHSw9aUC+wTWfKcX4FWcgrdiMjyXtPL9TBCCDuNQAWuoJCM qhIU8qKfIop6AJIQJKjSntyicczpfAXd3NJE1oFcaY2RfCMU06YOZkx6qyYVcWHxGr9a mGRg== X-Gm-Message-State: APjAAAWQ56P6jfaWG1/GVb7AN0YkEYSp9Fl6ojMUDE2P6P1u8t3dUaYw Qp0w9PRKejhRcCpXRDyvuM6p0t8U X-Google-Smtp-Source: APXvYqxs6ib+woWrF6+oN+jbWwy8xqlNTbBMsqQmk8TJwQNseG6ZsL+f4ACIfkcRwCRAyIPFAKnPBA== X-Received: by 2002:a17:902:8e87:: with SMTP id bg7mr6002146plb.134.1574884400565; Wed, 27 Nov 2019 11:53:20 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id s7sm2312703pfe.22.2019.11.27.11.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:19 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:18 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 07/26] t3600: stop losing return codes of git commands 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 When a command is in a non-assignment command substitution, the return code will be lost in favour of the surrounding command's. As a result, if a git command fails, we won't know about it. Rewrite instances of this so that git commands are either run in an assignment-only command substitution so that their return codes aren't lost. Signed-off-by: Denton Liu --- t/t3600-rm.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index f6e659b7e9..0c3bf10edd 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -304,7 +304,8 @@ EOF test_expect_success 'rm removes empty submodules from work tree' ' mkdir submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" submod && git config -f .gitmodules submodule.sub.url ./. && git config -f .gitmodules submodule.sub.path submod && git submodule init && @@ -623,7 +624,8 @@ test_expect_success 'setup subsubmodule' ' git submodule update && ( cd submod && - git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod && + hash=$(git rev-parse HEAD) && + git update-index --add --cacheinfo 160000 "$hash" subsubmod && git config -f .gitmodules submodule.sub.url ../. && git config -f .gitmodules submodule.sub.path subsubmod && git submodule init && From patchwork Wed Nov 27 19:53:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264825 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 5410E138C for ; Wed, 27 Nov 2019 19:53:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 333532082D for ; Wed, 27 Nov 2019 19:53:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oygJPds4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbfK0Tx1 (ORCPT ); Wed, 27 Nov 2019 14:53:27 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40956 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Tx0 (ORCPT ); Wed, 27 Nov 2019 14:53:26 -0500 Received: by mail-pg1-f193.google.com with SMTP id e17so11450110pgd.7 for ; Wed, 27 Nov 2019 11:53:25 -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=p7VPx+FtrqEcEOfcK3GddzAjZhHm6Shlg+PLWPLbqfs=; b=oygJPds4I5RTrUX5H4reC2aeVns6RAM6dajdgz3R6Ck+O2uoCcKx7elvrY0U/kxfpz wvK9V6RO8bsoG+0kaNjva1b41lX51PBt2qLuAUi9Tb6/Zd5k9LVLjOGOXucOJ3V7WuH6 HFTFakB4iWlFR13ilYKhasXRcItNiCmU3FRlKuz0ljxHGHSzqbcvxiYSFjsaVKiBW1Kq qy/V7KQTQZKHE31olKlSzOJeJiiAM8btpZzHzhMdSEdgvm9gxvNb7yNQSk31RK1SCSsK ZM7r26xiI2ms3fqk3l/90hxUtFpQ/b18qxElV3Oj+oIt2pQ7iJflK3zI08+hgHVP01qH Mw6w== 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=p7VPx+FtrqEcEOfcK3GddzAjZhHm6Shlg+PLWPLbqfs=; b=OErG/noDquCKM5/0cU52evrJNbv4OvNPGekDBElIcHkm9Jhpijy01QsUFT1ClJKiVX ZDA0w5dBWM1+CRtI9i6W85zDYZCCgxTPxRHAM3KY8eETYPKlHy/OMD2EM4i/qKHSC1Gb pszKqsdK2KRtBDRBQoTpCcBpiHCw+4qfifmninq8uQmzHzUX/vz/ybFz2EKunZquFe8J P9R46B6xyyhMlofYGNRN0SJHaqA2sxQPwKslId5A8S9WnrrgtX8YCnWZc93vqrBgY2Gy aAZt4YFbXRULJFYxrklwGBJ3PCc9lXdMkXOXdxbYtO++7+glSUHHY56UbacztzHnlj3t rrFQ== X-Gm-Message-State: APjAAAXrz9aDzfVO6jPZirCJJlySs9285wnlXMooMxn51u2y/DQQKfJy jmj+n4dz2spDyn6MD5kfQQ2em2mm X-Google-Smtp-Source: APXvYqw/+RGR1b76PD7LQncg7QsqocAxwA8rdkwndB9HoEsK6uHkPUHA8uViHHefY0lkPkm5QhvBgg== X-Received: by 2002:a63:f54a:: with SMTP id e10mr6436587pgk.401.1574884404270; Wed, 27 Nov 2019 11:53:24 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id j23sm17218641pfe.95.2019.11.27.11.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:22 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:20 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 08/26] t3600: comment on inducing SIGPIPE in `git rm` 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 Add a comment about intentionally inducing SIGPIPE since this is unusual and future developers should be aware. Also, even though we are trying to refactor git commands out of the upstream of pipes, we cannot do it here since we rely on it being upstream to induce SIGPIPE. Comment on that as well so that future developers do not try to change it. Signed-off-by: Denton Liu --- t/t3600-rm.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 0c3bf10edd..0ea858d652 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -251,6 +251,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft' ' echo "100644 $hash 0 some-file-$i" i=$(( $i + 1 )) done | git update-index --index-info && + # git command is intentionally placed upstream of pipe to induce SIGPIPE git rm -n "some-file-*" | : && test_path_is_missing .git/index.lock ' From patchwork Wed Nov 27 19:53:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264829 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 85BA61863 for ; Wed, 27 Nov 2019 19:53:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5CB6020863 for ; Wed, 27 Nov 2019 19:53:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DeV7ZguG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727310AbfK0Tx2 (ORCPT ); Wed, 27 Nov 2019 14:53:28 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45217 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Tx1 (ORCPT ); Wed, 27 Nov 2019 14:53:27 -0500 Received: by mail-pl1-f194.google.com with SMTP id w7so10275399plz.12 for ; Wed, 27 Nov 2019 11:53:27 -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=yQSbzla2VsXVGIGD/kDLshGkcMr2JlalSddTEq6v7J0=; b=DeV7ZguGDnuuNkenDYlpFNGy+lFakrL31tJaN32FhkBuT0wrx9n2rZLJpImLBgW1S5 YPACKr8mLcP5Hknc2oqhAiZq591fLe2J/lv0JSrO9dG68nv6XnjME8qB51fUYTVBck5j xgeQt2vqAuSJlS6XoGyHUW3pMAyxVe2adY+YmabfGoQ6lmkyYeDbQhxKDlyugytKKJb+ lyDCtFltf3VYban3p7ypvYS5di1K7Ch0lTJHDcD3asLxyIJ2H66wU5bNYL5ZG8gMgWA0 RDo6mu3TJTvPuCp4Mpn60l+7WCyCfyZFmIisFlyEHooXB7DzqTy/SjIT9CVf0f/0xFax s6og== 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=yQSbzla2VsXVGIGD/kDLshGkcMr2JlalSddTEq6v7J0=; b=hhstD8kEcqeGXUzPYfV+77+IfYO7cGiD3wr5axYdUCupXexI1DI0e4gyaRZ3XsPvYK XqCnRTX98djbbVHQxGnEOgrO5BVteUV7MbdNtsONk9ed8zbD779B1ZhqSgvQd4SEx7LO 7HzieX65Ya78B7/f9Syn9uE68SfEzH8d6erGadAbckC23OPBiYNZI45q80MzT//CVpK0 rnEeXaAf7htXvTMngNm07JXnJgd2ndAF6yXNgfXtybBFfChDxg1U2fmyOAvP+cYaEdLR xFjAQn6e0N4krt/ZoAVaYZolGLK5RO4x+SIJxswxiJ93OavqMDNlI5zcR5mUd4dEftRa huYA== X-Gm-Message-State: APjAAAWnNPnklHKxGTU26yMIW89B9U8DLws6lJAgkAjr8v5jOQM9f6Ej P4UMRCcVvpXC7i26qZaRXbbYNBoy X-Google-Smtp-Source: APXvYqyvYq6SJn2TH0HmMeJAEF576b0XP7TQnTgvoPl0PLn5Apn0t85cNSsTVx4r9XNOzp7dse7cFA== X-Received: by 2002:a17:902:4a:: with SMTP id 68mr6034372pla.158.1574884406648; Wed, 27 Nov 2019 11:53:26 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id 136sm17849396pfb.49.2019.11.27.11.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:26 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:24 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 09/26] t4015: stop losing return codes of git commands Message-ID: <22ea5d736e98205c08716c0d898d280be7f6cbef.1574884302.git.liu.denton@gmail.com> 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 Currently, there are two ways where the return codes of git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream. The other way is when a command is in a non-assignment command substitution. The return code will be lost in favour of the surrounding command's. Rewrite instances of this so that git commands are either run on their own or in an assignment-only command substitution. Signed-off-by: Denton Liu --- t/t4015-diff-whitespace.sh | 119 ++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 47 deletions(-) diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index eadaf57262..7fb83c8eff 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -16,7 +16,8 @@ test_expect_success "Ray Lehtiniemi's example" ' } while (0); EOF git update-index --add x && - before=$(git rev-parse --short $(git hash-object x)) && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && cat <<-\EOF >x && do @@ -25,7 +26,8 @@ test_expect_success "Ray Lehtiniemi's example" ' } while (0); EOF - after=$(git rev-parse --short $(git hash-object x)) && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && cat <<-EOF >expect && diff --git a/x b/x @@ -63,7 +65,8 @@ test_expect_success 'another test, without options' ' EOF git update-index x && - before=$(git rev-parse --short $(git hash-object x)) && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && tr "_" " " <<-\EOF >x && _ whitespace at beginning @@ -73,7 +76,8 @@ test_expect_success 'another test, without options' ' unchanged line CR at end EOF - after=$(git rev-parse --short $(git hash-object x)) && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && tr "Q_" "\015 " <<-EOF >expect && diff --git a/x b/x @@ -526,13 +530,15 @@ test_expect_success 'ignore-blank-lines: mix changes and blank lines' ' test_expect_success 'check mixed spaces and tabs in indent' ' # This is indented with SP HT SP. echo " foo();" >x && - git diff --check | grep "space before tab in indent" + test_must_fail git diff --check >check && + grep "space before tab in indent" check ' test_expect_success 'check mixed tabs and spaces in indent' ' # This is indented with HT SP HT. echo " foo();" >x && - git diff --check | grep "space before tab in indent" + test_must_fail git diff --check >check && + grep "space before tab in indent" check ' test_expect_success 'check with no whitespace errors' ' @@ -753,20 +759,23 @@ test_expect_success 'check tab-in-indent excluded from wildcard whitespace attri test_expect_success 'line numbers in --check output are correct' ' echo "" >x && echo "foo(); " >>x && - git diff --check | grep "x:2:" + test_must_fail git diff --check >check && + grep "x:2:" check ' test_expect_success 'checkdiff detects new trailing blank lines (1)' ' echo "foo();" >x && echo "" >>x && - git diff --check | grep "new blank line" + test_must_fail git diff --check >check && + grep "new blank line" check ' test_expect_success 'checkdiff detects new trailing blank lines (2)' ' { echo a; echo b; echo; echo; } >x && git add x && { echo a; echo; echo; echo; echo; } >x && - git diff --check | grep "new blank line" + test_must_fail git diff --check >check && + grep "new blank line" check ' test_expect_success 'checkdiff allows new blank lines' ' @@ -794,14 +803,16 @@ test_expect_success 'whitespace-only changes reported across renames' ' git reset --hard && for i in 1 2 3 4 5 6 7 8 9; do echo "$i$i$i$i$i$i"; done >x && git add x && - before=$(git rev-parse --short $(git hash-object x)) && + hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$hash_x") && git commit -m "base" && sed -e "5s/^/ /" x >z && git rm x && git add z && - after=$(git rev-parse --short $(git hash-object z)) && - git diff -w -M --cached | - sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" >actual && + hash_z=$(git hash-object z) && + after=$(git rev-parse --short "$hash_z") && + git diff -w -M --cached >actual.raw && + sed -e "/^similarity index /s/[0-9][0-9]*/NUM/" actual.raw >actual && cat <<-EOF >expect && diff --git a/x b/z similarity index NUM% @@ -840,7 +851,8 @@ test_expect_success 'combined diff with autocrlf conversion' ' git config core.autocrlf true && test_must_fail git merge master && - git diff | sed -e "1,/^@@@/d" >actual && + git diff >actual.raw && + sed -e "1,/^@@@/d" actual.raw >actual && ! grep "^-" actual ' @@ -864,11 +876,14 @@ test_expect_success 'diff that introduces a line with only tabs' ' git config core.whitespace blank-at-eol && git reset --hard && echo "test" >x && - before=$(git rev-parse --short $(git hash-object x)) && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -m "initial" x && echo "{NTN}" | tr "NT" "\n\t" >>x && - after=$(git rev-parse --short $(git hash-object x)) && - git diff --color | test_decode_color >current && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && + git diff --color >current.raw && + test_decode_color current && cat >expected <<-EOF && diff --git a/x b/x @@ -891,17 +906,19 @@ test_expect_success 'diff that introduces and removes ws breakages' ' echo "0. blank-at-eol " && echo "1. blank-at-eol " } >x && - before=$(git rev-parse --short $(git hash-object x)) && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -a --allow-empty -m preimage && { echo "0. blank-at-eol " && echo "1. still-blank-at-eol " && echo "2. and a new line " } >x && - after=$(git rev-parse --short $(git hash-object x)) && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && - git diff --color | - test_decode_color >current && + git diff --color >current.raw && + test_decode_color current && cat >expected <<-EOF && diff --git a/x b/x @@ -925,14 +942,16 @@ test_expect_success 'ws-error-highlight test setup' ' echo "0. blank-at-eol " && echo "1. blank-at-eol " } >x && - before=$(git rev-parse --short $(git hash-object x)) && + old_hash_x=$(git hash-object x) && + before=$(git rev-parse --short "$old_hash_x") && git commit -a --allow-empty -m preimage && { echo "0. blank-at-eol " && echo "1. still-blank-at-eol " && echo "2. and a new line " } >x && - after=$(git rev-parse --short $(git hash-object x)) && + new_hash_x=$(git hash-object x) && + after=$(git rev-parse --short "$new_hash_x") && cat >expect.default-old <<-EOF && diff --git a/x b/x @@ -974,32 +993,32 @@ test_expect_success 'ws-error-highlight test setup' ' test_expect_success 'test --ws-error-highlight option' ' - git diff --color --ws-error-highlight=default,old | - test_decode_color >current && + git diff --color --ws-error-highlight=default,old >current.raw && + test_decode_color current && test_cmp expect.default-old current && - git diff --color --ws-error-highlight=all | - test_decode_color >current && + git diff --color --ws-error-highlight=all >current.raw && + test_decode_color current && test_cmp expect.all current && - git diff --color --ws-error-highlight=none | - test_decode_color >current && + git diff --color --ws-error-highlight=none >current.raw && + test_decode_color current && test_cmp expect.none current ' test_expect_success 'test diff.wsErrorHighlight config' ' - git -c diff.wsErrorHighlight=default,old diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=default,old diff --color >current.raw && + test_decode_color current && test_cmp expect.default-old current && - git -c diff.wsErrorHighlight=all diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=all diff --color >current.raw && + test_decode_color current && test_cmp expect.all current && - git -c diff.wsErrorHighlight=none diff --color | - test_decode_color >current && + git -c diff.wsErrorHighlight=none diff --color >current.raw && + test_decode_color current && test_cmp expect.none current ' @@ -1007,18 +1026,18 @@ test_expect_success 'test diff.wsErrorHighlight config' ' test_expect_success 'option overrides diff.wsErrorHighlight' ' git -c diff.wsErrorHighlight=none \ - diff --color --ws-error-highlight=default,old | - test_decode_color >current && + diff --color --ws-error-highlight=default,old >current.raw && + test_decode_color current && test_cmp expect.default-old current && git -c diff.wsErrorHighlight=default \ - diff --color --ws-error-highlight=all | - test_decode_color >current && + diff --color --ws-error-highlight=all >current.raw && + test_decode_color current && test_cmp expect.all current && git -c diff.wsErrorHighlight=all \ - diff --color --ws-error-highlight=none | - test_decode_color >current && + diff --color --ws-error-highlight=none >current.raw && + test_decode_color current && test_cmp expect.none current ' @@ -1038,7 +1057,8 @@ test_expect_success 'detect moved code, complete file' ' git mv test.c main.c && test_config color.diff.oldMoved "normal red" && test_config color.diff.newMoved "normal green" && - git diff HEAD --color-moved=zebra --color --no-renames | test_decode_color >actual && + git diff HEAD --color-moved=zebra --color --no-renames >actual.raw && + test_decode_color actual && cat >expected <<-EOF && diff --git a/main.c b/main.c new file mode 100644 @@ -1141,9 +1161,12 @@ test_expect_success 'detect malicious moved code, inside file' ' bar(); } EOF - after_main=$(git rev-parse --short $(git hash-object main.c)) && - after_test=$(git rev-parse --short $(git hash-object test.c)) && - git diff HEAD --no-renames --color-moved=zebra --color | test_decode_color >actual && + hash_main=$(git hash-object main.c) && + after_main=$(git rev-parse --short "$hash_main") && + hash_test=$(git hash-object test.c) && + after_test=$(git rev-parse --short "$hash_test") && + git diff HEAD --no-renames --color-moved=zebra --color >actual.raw && + test_decode_color actual && cat <<-EOF >expected && diff --git a/main.c b/main.c index $before_main..$after_main 100644 @@ -1192,7 +1215,8 @@ test_expect_success 'plain moved code, inside file' ' test_config color.diff.oldMovedAlternative "blue" && test_config color.diff.newMovedAlternative "yellow" && # needs previous test as setup - git diff HEAD --no-renames --color-moved=plain --color | test_decode_color >actual && + git diff HEAD --no-renames --color-moved=plain --color >actual.raw && + test_decode_color actual && cat <<-EOF >expected && diff --git a/main.c b/main.c index $before_main..$after_main 100644 @@ -1771,7 +1795,8 @@ test_expect_success 'move detection with submodules' ' ! grep BRED decoded_actual && # nor did we mess with it another way - git diff --submodule=diff --color | test_decode_color >expect && + git diff --submodule=diff --color >expect.raw && + test_decode_color expect && test_cmp expect decoded_actual && rm -rf bananas && git submodule deinit bananas From patchwork Wed Nov 27 19:53:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264833 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 76BD11863 for ; Wed, 27 Nov 2019 19:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57D362084D for ; Wed, 27 Nov 2019 19:53:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iJYnVLb9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbfK0Txc (ORCPT ); Wed, 27 Nov 2019 14:53:32 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:35161 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbfK0Txa (ORCPT ); Wed, 27 Nov 2019 14:53:30 -0500 Received: by mail-pg1-f193.google.com with SMTP id l24so2985863pgk.2 for ; Wed, 27 Nov 2019 11:53:29 -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=UZjQuhshmUTYkNjRds66IUkGFQ5n+5vfrrW8eCRBASk=; b=iJYnVLb96Y21h7oyfsJWf0PC+0e+D95bIoPYTKcu7usV+nctcL0XbOE4uuNUDE6ngd rwDKS6sT6z4BMVUjQwBEiC4//epuO2j75yW7HeyqDcTeDDY4GqF/vAvT2fPSfhew5EqE 5mGygSyTUP2GEegzlbPvGHpGB5yKIQoRXYg22P998oplxzq1sRYzJA4PkODS3lzp1Jx+ jbeKJIUf1Yi4G2zS86VYxy+47hmD4wqlZMshgsDymdHpLT7p+gz463cIc8ToeQHKvOmu sfUvigDZE18NdYatKuKmmNX+Of5DUqPcANGyv8kZwasoFlVulgFnpVl188+CBBJsikpk QICg== 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=UZjQuhshmUTYkNjRds66IUkGFQ5n+5vfrrW8eCRBASk=; b=g2ILGHRdJ9jXHn3vkP6f9GSYUK+LFuJjxklczdqgnzAsV8zYFrO8WUzNpja2ZsprEU laLjvT9xKTroHFQkhD4qQmYh1gpkQBJPoR+P3AeeWazmoK3hNJgcED69BeO31SlbsWao jsqWKThDVlHgW6ND7vLm2aHBBrrg32y9Ne/aMHSzGZ8xx8xHwY/QOEIm1u3EqqyJwVeH R/m6bYturYg7/mc4i7jGEMKgo0i+1uTTWeTPlGPoqDtRmJe7T5NnoVFDRiVLObCZW5Yu hfyHzGYBWoGcyW9lfz6hNj7Uir9PfxF1CySrtMhLTyad2LJxEqeLtEgAlPZASrikCcUO 6SyA== X-Gm-Message-State: APjAAAVpyx5CUyGuv04NHPCBQt6uXIThD3J6lRaMo9wzewhg1qxao/dW y3NGnLVaYy0twS3rDHRQLyQW1M43 X-Google-Smtp-Source: APXvYqxM3B4NhuZfXvMSAS6vbRvxmYS1XGHGZUjg/3tmUa8FR/s9TKtBFVlMzs/6eEgHKPZ+q4d+EQ== X-Received: by 2002:a63:a452:: with SMTP id c18mr6992080pgp.188.1574884408940; Wed, 27 Nov 2019 11:53:28 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id e7sm17772561pfe.173.2019.11.27.11.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:28 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:26 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 10/26] t4015: use test_write_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 Instead of rolling our own method to write out some lines into a file, use the existing test_write_lines(). Signed-off-by: Denton Liu --- t/t4015-diff-whitespace.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 7fb83c8eff..4c540b1d70 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -771,9 +771,9 @@ test_expect_success 'checkdiff detects new trailing blank lines (1)' ' ' test_expect_success 'checkdiff detects new trailing blank lines (2)' ' - { echo a; echo b; echo; echo; } >x && + test_write_lines a b "" "" >x && git add x && - { echo a; echo; echo; echo; echo; } >x && + test_write_lines a "" "" "" "" >x && test_must_fail git diff --check >check && grep "new blank line" check ' From patchwork Wed Nov 27 19:53:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264831 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 DB01F138C for ; Wed, 27 Nov 2019 19:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB47D20835 for ; Wed, 27 Nov 2019 19:53:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gUr0TzoU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727319AbfK0Txd (ORCPT ); Wed, 27 Nov 2019 14:53:33 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36453 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txc (ORCPT ); Wed, 27 Nov 2019 14:53:32 -0500 Received: by mail-pl1-f194.google.com with SMTP id d7so10304989pls.3 for ; Wed, 27 Nov 2019 11:53:31 -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=s+25cXUitbRIILBQxNigN1bTyahqYM675wyaEPunVdE=; b=gUr0TzoUTQoEuCEDE9ZYOSLBJlAhD9gSGzN6V2FTWX+7ymOh7mVNycUq8qOX2QxTWK 3TMSRCQd+5bBpspvFjFcdJr/x3KKWPwOk9cHsrYQnOB740lxeqF7/3dz4p2p1swIY+Rs ApCDM0gra+vKGNyLEExjkRhkpr6S5jI/qKYb5IOCnhD0SAyBNRVTCHZIx6MIEIf2fEFD UcClDX6s2yEXKBqva1MagNLGBruCvk5HHgqXn03xZwdSq3ohLcIxY1e4Efv2qKp/OFpU wuLDCvuh+4bD77uuYSRU10mJow+6hlVUuMl0/kJlpYaaY+4MwZQfvh1dGhbHKc2qbRQ4 KMDw== 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=s+25cXUitbRIILBQxNigN1bTyahqYM675wyaEPunVdE=; b=spJko3zX5rXQWU9eV6qGtPLIIGq5NozxPV9w+UHDa1aQtf2tXBDeGd1ZNTfJzkAQwc Wij3QrtoDYl5HighqgE3Ay59pndNNPG5p9gWl0Ji/Fi8SWFNNaz5h+q3QZO2tjnBopfv kcKAVYjMKwQZEFeNMTJpQ+y8glKp/e07PoOHFWkqWp6GIVOAHrlC9Yw64eLcVl09wHG2 gZsEzIigV8VZxVz2lmxxXGGUjjquXHg3O7zyg6WZVeAiCE5jdRK0/t9e5LuIxDY0Ks2h X3RNBTq/MJzufMTlVck1tdwKQbO5GcAMAGMWtNmxNBXowPcRqKUJ8JcWuerjACHujb5k mkCg== X-Gm-Message-State: APjAAAWc70UtFJlPcEbtS71S834vpzCRn9raUw46YlXHBhHuR08lS08Z R4ANaHjPs1vUHjWnM7EYSKojNlAW X-Google-Smtp-Source: APXvYqzxaXzFEA1o0MulhgBfhT6UOr9gT5FrOpHW7KDzoU92ZUYu6VfZD656VjzhzhgXR2tzwudGEw== X-Received: by 2002:a17:90a:1a8a:: with SMTP id p10mr7866016pjp.6.1574884411178; Wed, 27 Nov 2019 11:53:31 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id 20sm16868413pgw.71.2019.11.27.11.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:30 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:29 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 11/26] t4138: stop losing return codes of git commands 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 In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream so that we will know if a command fails. Signed-off-by: Denton Liu --- t/t4138-apply-ws-expansion.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh index 3b636a63a3..b19faeb67a 100755 --- a/t/t4138-apply-ws-expansion.sh +++ b/t/t4138-apply-ws-expansion.sh @@ -17,8 +17,8 @@ test_expect_success setup ' printf "\t%s\n" 1 2 3 >after && printf "%64s\n" a b c >>after && printf "\t%s\n" 4 5 6 >>after && - git diff --no-index before after | - sed -e "s/before/test-1/" -e "s/after/test-1/" >patch1.patch && + test_expect_code 1 git diff --no-index before after >patch1.patch.raw && + sed -e "s/before/test-1/" -e "s/after/test-1/" patch1.patch.raw >patch1.patch && printf "%64s\n" 1 2 3 4 5 6 >test-1 && printf "%64s\n" 1 2 3 a b c 4 5 6 >expect-1 && @@ -33,8 +33,8 @@ test_expect_success setup ' x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after && - git diff --no-index before after | - sed -e "s/before/test-2/" -e "s/after/test-2/" >patch2.patch && + test_expect_code 1 git diff --no-index before after >patch2.patch.raw && + sed -e "s/before/test-2/" -e "s/after/test-2/" patch2.patch.raw >patch2.patch && printf "%64s\n" a b c d e f >test-2 && printf "%64s\n" a b c >expect-2 && x=1 && @@ -56,8 +56,8 @@ test_expect_success setup ' x=$(( $x + 1 )) done && printf "\t%s\n" d e f >>after && - git diff --no-index before after | - sed -e "s/before/test-3/" -e "s/after/test-3/" >patch3.patch && + test_expect_code 1 git diff --no-index before after >patch3.patch.raw && + sed -e "s/before/test-3/" -e "s/after/test-3/" patch3.patch.raw >patch3.patch && printf "%64s\n" a b c d e f >test-3 && printf "%64s\n" a b c >expect-3 && x=0 && @@ -84,8 +84,8 @@ test_expect_success setup ' printf "\t%02d\n" $x >>after x=$(( $x + 1 )) done && - git diff --no-index before after | - sed -e "s/before/test-4/" -e "s/after/test-4/" >patch4.patch && + test_expect_code 1 git diff --no-index before after >patch4.patch.raw && + sed -e "s/before/test-4/" -e "s/after/test-4/" patch4.patch.raw >patch4.patch && >test-4 && x=0 && while test $x -lt 50 From patchwork Wed Nov 27 19:53:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264835 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 D7E2015AB for ; Wed, 27 Nov 2019 19:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8B9B2084D for ; Wed, 27 Nov 2019 19:53:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="r1nP2d+D" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727322AbfK0Txf (ORCPT ); Wed, 27 Nov 2019 14:53:35 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:38805 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txe (ORCPT ); Wed, 27 Nov 2019 14:53:34 -0500 Received: by mail-pj1-f65.google.com with SMTP id f7so10551876pjw.5 for ; Wed, 27 Nov 2019 11:53:34 -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=hPjOtMuhVEA7iflpjkkJ1vyj/H80ZOpy/zTnsTLGS+g=; b=r1nP2d+D6XtOZKvgz95He6ztB/FTLlSBekkwtSnR2RTUAJokBDSeyoMERZGpSzaDQd Uu3avs6YRiQt1PSMe5MkOOotsS8MSAC5PeaQa+LXO4+KQZy4Hiq4AftLUyr8fDDsl9yU wUawlbghb2yyKoo5190IibAduY5X+me4ODllzcGBg1l8H6cJiSE6jzsWz7iH7IrTF4/k YyiZENk6QmKhlXjFpl4qPRvY46aCPVw4qhe8pLdf3f722jI+sSLDJORTX9H87aJQrVSG fOhEOW3pcFQetlHSh7ONgxk6Urx1MWgN4yFameI3D1Bde8Dpkq/ODuesjUpJ9fws3v4X eXPA== 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=hPjOtMuhVEA7iflpjkkJ1vyj/H80ZOpy/zTnsTLGS+g=; b=ng+2IecG741efyo32ewwIjSFkhioCs1mCwoWMHk5JpmmIXZwIHd0nYoYmWUcfN+Olb 1TrdDLeQ8DW9N77DKYZ4C42Ua7ZXL5rpi9IqClUxe7EhWMx7/OGDO6E+A8GrrRNjUlxT a/vIFahpybFdt07BlhrPuaB60t84cNYx6YbuyAGbw0gS3SbF3Yjvg7YAejIt3BQGrpPk LQe63ofszmHTOXc0he+slPJPcG1HEMonMy63D1Az0FsOzqslc9sd1LiRRsNpKZLJCfkn 62tvJP8GtF6Ex9k6ZtrgGez3hO3JLrWPTKVXtLR+tKwZpZb4dSVOjc9VIOtYUtXoU/Hk 1+6g== X-Gm-Message-State: APjAAAWYCwjlKm3A29QHdjhPe1qNsC78R+TRm0UwHim796Lcgs7B46mT /xHJdeHJTmpYIyIH0Q+Cgmumqqk8 X-Google-Smtp-Source: APXvYqxNwpMInDILdQw/K/ufY2ryRhUpVwp/5c3CXUUpkXJjnd3hVxKcgjbEx+Sqx1v/jH+u33a2IQ== X-Received: by 2002:a17:90a:e90:: with SMTP id 16mr8090068pjx.65.1574884413653; Wed, 27 Nov 2019 11:53:33 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id w62sm17862877pfb.15.2019.11.27.11.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:32 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:31 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 12/26] t5317: stop losing return codes of git commands Message-ID: <1e08c2b68ba041f5bc94695481ddbd106e9bb4f4.1574884302.git.liu.denton@gmail.com> 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 Currently, there are two ways where the return codes of git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream. The other way is when a command is in a non-assignment command substitution. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that git commands output to a file and surrounding commands only call command substitutions with non-git commands. Signed-off-by: Denton Liu --- t/t5317-pack-objects-filter-objects.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/t/t5317-pack-objects-filter-objects.sh b/t/t5317-pack-objects-filter-objects.sh index 2d2f5d0229..a8bbad74e2 100755 --- a/t/t5317-pack-objects-filter-objects.sh +++ b/t/t5317-pack-objects-filter-objects.sh @@ -72,7 +72,8 @@ test_expect_success 'get an error for missing tree object' ' echo foo >r5/foo && git -C r5 add foo && git -C r5 commit -m "foo" && - del=$(git -C r5 rev-parse HEAD^{tree} | sed "s|..|&/|") && + git -C r5 rev-parse HEAD^{tree} >tree && + del=$(sed "s|..|&/|" tree) && rm r5/.git/objects/$del && test_must_fail git -C r5 pack-objects --revs --stdout 2>bad_tree <<-EOF && HEAD @@ -230,10 +231,9 @@ test_expect_success 'verify explicitly specifying oversized blob in input' ' awk -f print_2.awk ls_files_result | sort >expected && - git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k >filter.pack <<-EOF && - HEAD - $(git -C r2 rev-parse HEAD:large.10000) - EOF + echo HEAD >objects && + git -C r2 rev-parse HEAD:large.10000 >>objects && + git -C r2 pack-objects --revs --stdout --filter=blob:limit=1k filter.pack && git -C r2 index-pack ../filter.pack && git -C r2 verify-pack -v ../filter.pack >verify_result && @@ -377,7 +377,8 @@ test_expect_success 'verify sparse:oid=OID' ' awk -f print_2.awk ls_files_result | sort >expected && - oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) && + git -C r4 ls-files -s pattern >staged && + oid=$(awk -f print_2.awk staged) && git -C r4 pack-objects --revs --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF && HEAD EOF 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 X-Patchwork-Id: 11264839 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 3830D138C for ; Wed, 27 Nov 2019 19:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 180BD20835 for ; Wed, 27 Nov 2019 19:53:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HN3fMeo/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727333AbfK0Txj (ORCPT ); Wed, 27 Nov 2019 14:53:39 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45881 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txj (ORCPT ); Wed, 27 Nov 2019 14:53:39 -0500 Received: by mail-pf1-f195.google.com with SMTP id z4so11613529pfn.12 for ; Wed, 27 Nov 2019 11:53:38 -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=N6fKgQgEvJL8D6EyU1tI4ExWrDmNqbq0vn2FWS4Ii9c=; b=HN3fMeo/pwswSgt6BbhsW43IxbU7gEvEV/kdYPJCdJ+YwMCu5iqZNE6hRI1aLnGgUo G5Rf/Vae8eh24sQ0mEc2TIQOP1jXaVdf4c93V9UcyGyVVxGWN65GSdd+jfbgY62pFEWM EtC4k1kXjFVO8z1R23wzhK1WimXh0d3HmKwogTBgEbKiL0KIPB+aJd4lY0TI/tPrH5no Py+W4ABkCJtsNn4j8r95255b1e9tHjNuiC0pJI9Dg263UG1pDXjdFh/x4nKR3h2HKUTt VwPz12LaEDxgyV9iadovzXM/YlMEwXu5/lkJ5c2teelNomj2nBuJnNw4NfnyG5p5L/fA FAgg== 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=N6fKgQgEvJL8D6EyU1tI4ExWrDmNqbq0vn2FWS4Ii9c=; b=ijRCGWZAU8E+UBQW6dWM0GuXfKCFKIeU2EqlgOROkwWQN2cnrlwkoXkkXD2IPhRcxI 0+9N0MUM3WtfRnNJl61cYeOlwQ6PYt02HYTbLHOjJp976szld9IqeuXPg7IqhbOpqsMS 1ZvbP21UHPFsVfU02wElGEeg91qX7wOOKydXbzU0pizZxc7T5KAXqxDHO487IiLuKV0Y /N31HJHg5G/opJIhSmnMJx4vsqeRacHhgdyONmdpFDEzXF8NAr3bt4xnLGU7IKTkxeGY f5aRfzqGbzciK4ntaAyNmd7yisCgyFEbE8LleEnn0VA778SpcI4JrTZXk9y8Igo0Qodh Nc/Q== X-Gm-Message-State: APjAAAUw5aOY1PJOhe2sBIVzBHDUIeQynWXNoQQpZzLBkHcLyv4CzVe+ L7ws2WpxaOWDuftiFhgDQOzhdA3F X-Google-Smtp-Source: APXvYqzL2/5Bsqx0q5zaKM9DoXHo3hFEc/kvw9+JvhISGYTYzsF7mw2I+/24aiahQB0lqvJ4bxcasQ== X-Received: by 2002:aa7:9a96:: with SMTP id w22mr50882017pfi.162.1574884418230; Wed, 27 Nov 2019 11:53:38 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id m7sm19149971pfb.153.2019.11.27.11.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:37 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:36 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 14/26] t5703: simplify one-time-sed generation logic Message-ID: <291caf9bc11574b8f2ce8dcbaeb5d369c597a8c8.1574884302.git.liu.denton@gmail.com> 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 In inconsistency(), we had two `git rev-parse` invocations in the upstream of a pipe within a command substitution. In case this invocation ever failed, its exit code would be swallowed up and we would not know about it. Pull the command substitutions out into variable assignments so that their return codes are not lost. Drop the pipe into `tr` because the $(...) substitution already takes care of stripping out newlines, so the `tr` invocations in the code are superfluous. Finally, given the way the tests actually employ "one-time-sed" via $(cat one-time-sed) in t/lib-httpd/apply-one-time-sed.sh, convert the `printf` into an `echo`. This makes it consistent with the final "server loses a ref - ref in want" test, which does use `echo` rather than `printf`. Helped-by: Eric Sunshine Signed-off-by: Denton Liu --- t/t5703-upload-pack-ref-in-want.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index 3a2c143c6d..88338c4e09 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -312,10 +312,9 @@ inconsistency () { # repository appears to change during negotiation, for example, when # different servers in a load-balancing arrangement serve (stateless) # RPCs during a single negotiation. - printf "s/%s/%s/" \ - $(git -C "$REPO" rev-parse $1 | tr -d "\n") \ - $(git -C "$REPO" rev-parse $2 | tr -d "\n") \ - >"$HTTPD_ROOT_PATH/one-time-sed" + oid1=$(git -C "$REPO" rev-parse $1) && + oid2=$(git -C "$REPO" rev-parse $2) && + echo "s/$oid1/$oid2/" >"$HTTPD_ROOT_PATH/one-time-sed" } test_expect_success 'server is initially ahead - no ref in want' ' From patchwork Wed Nov 27 19:53:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264841 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 3C4A315AB for ; Wed, 27 Nov 2019 19:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1CEA12084D for ; Wed, 27 Nov 2019 19:53:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ths7dby9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbfK0Txm (ORCPT ); Wed, 27 Nov 2019 14:53:42 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:42144 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txl (ORCPT ); Wed, 27 Nov 2019 14:53:41 -0500 Received: by mail-pj1-f68.google.com with SMTP id y21so10544829pjn.9 for ; Wed, 27 Nov 2019 11:53:41 -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=dG4dj4XQmimGj9PkcTvsBFkUdgdXGBCaOXccLieZ0MU=; b=Ths7dby9XdSD/11q9nhnm294CsGpbWyTWbwSui3A+CiOeMB7L9up20SjucQYDadWdt /CJEksjMSupvsfkrKDMzjykfBOZgQmPz/e5D7XTK8p+0cw2ATjfSiyeACAiPc3EHE9Oq +TyQWzQqTH1NO565bT/tGID0OQs249a3jLyxCn7TcxorkN6FKVn7FZwSaizyHgkBiAyV sVryY0THL6nP7N0odeb123a2Y5qhN0OBbc5y45kVDcR02H7Fe1y4OgO6OHf7gilitth0 uXvz3C6UM0DtbxAiWJGyUGmFD+K3PoiRBout/4P4j5YIL6mG/ZaKGLwLtDJtrLs7Yk6V fwoQ== 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=dG4dj4XQmimGj9PkcTvsBFkUdgdXGBCaOXccLieZ0MU=; b=Qm4yMfCj+llFYKTx7Tu95G2a0Zdz/xqCVt1b891UAMvyfzXZXpPqcgQpNRCuWHNc7G gFFZAzDcqxr5F3+l2tHYyPAKRPlaQJ6sx0LWkl2o/niSnUAkUPd5EycZ1KW1YylrnaMw Mm227Hd26sIkb6gcfED4bzOnNcX4FSDVK4mur5T2iF+6y91cET7w26HTE4o6V9GlaOzT OdQax9NKpEctDmFB30/C0vLt9h1aefi7EDYIsZLCBG/KsRN29onKA0BfE2JY2jiJ/cFQ C3kDwvxBQrUc3K/maQOw+6S9BC8nFRHYB4uvyyoV9JiIkcHuENAYdEyON2wKXVMUvbe8 JoLg== X-Gm-Message-State: APjAAAXpnZ5S7c95FsYKCj8MubNk6Ids8U1K9FC02uqExVNpO7Dm7mgT u5y4OzEeqLBbk/P99RMLKHBGsAhm X-Google-Smtp-Source: APXvYqxG6BxYBbWuWYHg2uK1Bcd+FHnrYM04S4VD+E6ARydC3tqpha16O2TplWBm6yVxoCsDIKRB9Q== X-Received: by 2002:a17:902:74c7:: with SMTP id f7mr5551430plt.231.1574884420425; Wed, 27 Nov 2019 11:53:40 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id x7sm17398027pfa.107.2019.11.27.11.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:39 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:38 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 15/26] t5703: stop losing return codes of git commands 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 Currently, there are two ways where the return codes of git commands are lost. The first way is when a command is in the upstream of a pipe. In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream. The other way is when a command is in a non-assignment command substitution. The return code will be lost in favour of the surrounding command's. Rewrite instances of this such that git commands are in an assignment-only command substitution. Signed-off-by: Denton Liu --- t/t5703-upload-pack-ref-in-want.sh | 46 +++++++++++++++++++----------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index 88338c4e09..1424fabd4a 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -18,14 +18,16 @@ get_actual_commits () { p }' o.pack && git index-pack o.pack && - git verify-pack -v o.idx | grep commit | cut -c-40 | sort >actual_commits + git verify-pack -v o.idx >objs && + grep commit objs | cut -c-40 | sort >actual_commits } check_output () { get_actual_refs && test_cmp expected_refs actual_refs && get_actual_commits && - test_cmp expected_commits actual_commits + sort expected_commits >sorted_commits && + test_cmp sorted_commits actual_commits } # c(o/foo) d(o/bar) @@ -75,17 +77,19 @@ test_expect_success 'invalid want-ref line' ' ' test_expect_success 'basic want-ref' ' + oid=$(git rev-parse f) && cat >expected_refs <<-EOF && - $(git rev-parse f) refs/heads/master + $oid refs/heads/master EOF - git rev-parse f | sort >expected_commits && + git rev-parse f >expected_commits && + oid=$(git rev-parse a) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/master - have $(git rev-parse a) + have $oid done 0000 EOF @@ -95,19 +99,22 @@ test_expect_success 'basic want-ref' ' ' test_expect_success 'multiple want-ref lines' ' + oid_c=$(git rev-parse c) && + oid_d=$(git rev-parse d) && cat >expected_refs <<-EOF && - $(git rev-parse c) refs/heads/o/foo - $(git rev-parse d) refs/heads/o/bar + $oid_c refs/heads/o/foo + $oid_d refs/heads/o/bar EOF - git rev-parse c d | sort >expected_commits && + git rev-parse c d >expected_commits && + oid=$(git rev-parse b) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/o/foo want-ref refs/heads/o/bar - have $(git rev-parse b) + have $oid done 0000 EOF @@ -117,10 +124,11 @@ test_expect_success 'multiple want-ref lines' ' ' test_expect_success 'mix want and want-ref' ' + oid=$(git rev-parse f) && cat >expected_refs <<-EOF && - $(git rev-parse f) refs/heads/master + $oid refs/heads/master EOF - git rev-parse e f | sort >expected_commits && + git rev-parse e f >expected_commits && test-tool pkt-line pack >in <<-EOF && command=fetch @@ -138,17 +146,19 @@ test_expect_success 'mix want and want-ref' ' ' test_expect_success 'want-ref with ref we already have commit for' ' + oid=$(git rev-parse c) && cat >expected_refs <<-EOF && - $(git rev-parse c) refs/heads/o/foo + $oid refs/heads/o/foo EOF >expected_commits && + oid=$(git rev-parse c) && test-tool pkt-line pack >in <<-EOF && command=fetch 0001 no-progress want-ref refs/heads/o/foo - have $(git rev-parse c) + have $oid done 0000 EOF @@ -211,13 +221,14 @@ test_expect_success 'fetching with exact OID' ' rm -rf local && cp -r "$LOCAL_PRISTINE" local && + oid=$(git -C "$REPO" rev-parse d) && GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \ - $(git -C "$REPO" rev-parse d):refs/heads/actual && + "$oid":refs/heads/actual && git -C "$REPO" rev-parse "d" >expected && git -C local rev-parse refs/heads/actual >actual && test_cmp expected actual && - grep "want $(git -C "$REPO" rev-parse d)" log + grep "want $oid" log ' test_expect_success 'fetching multiple refs' ' @@ -239,13 +250,14 @@ test_expect_success 'fetching ref and exact OID' ' rm -rf local && cp -r "$LOCAL_PRISTINE" local && + oid=$(git -C "$REPO" rev-parse b) && GIT_TRACE_PACKET="$(pwd)/log" git -C local fetch origin \ - master $(git -C "$REPO" rev-parse b):refs/heads/actual && + master "$oid":refs/heads/actual && git -C "$REPO" rev-parse "master" "b" >expected && git -C local rev-parse refs/remotes/origin/master refs/heads/actual >actual && test_cmp expected actual && - grep "want $(git -C "$REPO" rev-parse b)" log && + grep "want $oid" log && grep "want-ref refs/heads/master" log ' From patchwork Wed Nov 27 19:53:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264843 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 DD06615AB for ; Wed, 27 Nov 2019 19:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BCF252082D for ; Wed, 27 Nov 2019 19:53:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kWYtY0HH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727345AbfK0Txo (ORCPT ); Wed, 27 Nov 2019 14:53:44 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43617 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txn (ORCPT ); Wed, 27 Nov 2019 14:53:43 -0500 Received: by mail-pg1-f194.google.com with SMTP id b1so11447194pgq.10 for ; Wed, 27 Nov 2019 11:53:43 -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=vH2YiKkHoEktTT4rNpGzF4Qp9y3oAMQj3787bOmrsp0=; b=kWYtY0HHj9sCpliIlb8m4s8R1qb9Z5lwmwdJH9Xt0Ml0pVpPjFPi8XfV7ENfXDroJ1 AnylJLjo9QSShXR9DvLyBvzPIYQbnABpHBBzmhOIeveW8ucdnsoyBQ9meG0cYXPx+fpF AcywPxugCcuY044tfFM9vOVS9hdb2BAhk347D6CXwsa8pTocgGHMqvCUKSNOtFRxabl+ o08enGtmVZ5N3aL9vNlyydMKHWwwixqCjDb1UmB3aB+0W8/SvDY8QO1djL8KG4Ke1ynS 1xys/U6Mu/KA7inGdtZu+ruJp4+BtJFwYl2P+e9EDQFb3RG36AVeM/nThZLf1QkCuCwj x/Rg== 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=vH2YiKkHoEktTT4rNpGzF4Qp9y3oAMQj3787bOmrsp0=; b=hOAEPVH7M47A96v6QZmLKxsZfSiK7vImb2Rf5kShZ5DSZEm/0uYLhiT7Du2TqGMkCI LnS/ADMRMpj4vA1AGX5LgVyOkvDpXcdvWv3rHz/WDHz2XJIoZ7KrHdzjeR00nwK7B4Fc lLuc3v6qg5XPARQQGwlzymQZfofdyE4JQScPZ8ci5230VHm0Fk7woIX2rGx81qk/gO5q sxxUWzkxvYPvM9le6a7v1cgos+qajte6J03wC3mt6N7zhKi1pkVn9FLqUNHY8EXUaM/e NvsbUQmg4cGeiM3l/xCpPE+ERz2GxWbnym3zVYTb8nCrJBoHClJxEhojlN9dTyGrqvkR x/Sg== X-Gm-Message-State: APjAAAX5n+q7U5aFB9DmUM3JuVSKi34Pc7aCqhueU4s9JZQufhVitneR ZX/ucJYE0Os5cL3jJe51zsCtFvzv X-Google-Smtp-Source: APXvYqwwWSHGDG0vyYrX3E8V8bSuwPADTiIA2ltLetBeynvinAnOIvnLhuTx0P9NVghJx+E21RwdPw== X-Received: by 2002:a63:fa0d:: with SMTP id y13mr6842015pgh.18.1574884422845; Wed, 27 Nov 2019 11:53:42 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id j14sm4198104pgs.57.2019.11.27.11.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:42 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:40 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 16/26] t7501: remove spaces after redirect operators Message-ID: <5eb7117fbef4c39aecbdbd25c9e1f0a637c4b0de.1574884302.git.liu.denton@gmail.com> 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 For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. `>file`, not `> file`). Remove these spaces wherever they appear. Signed-off-by: Denton Liu --- t/t7501-commit-basic-functionality.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index f1349af56e..5765d33c53 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -150,7 +150,7 @@ test_expect_success 'setup: commit message from file' ' test_expect_success 'amend commit' ' cat >editor <<-\EOF && #!/bin/sh - sed -e "s/a file/an amend commit/g" < "$1" > "$1-" + sed -e "s/a file/an amend commit/g" <"$1" >"$1-" mv "$1-" "$1" EOF chmod 755 editor && @@ -263,7 +263,7 @@ test_expect_success 'using message from other commit' ' test_expect_success 'editing message from other commit' ' cat >editor <<-\EOF && #!/bin/sh - sed -e "s/amend/older/g" < "$1" > "$1-" + sed -e "s/amend/older/g" <"$1" >"$1-" mv "$1-" "$1" EOF chmod 755 editor && @@ -367,7 +367,7 @@ test_expect_success 'amend commit to fix author' ' -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ expected && git commit --amend --author="$author" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' @@ -382,7 +382,7 @@ test_expect_success 'amend commit to fix date' ' -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ expected && git commit --amend --date="$newtick" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' @@ -448,7 +448,7 @@ test_expect_success 'signoff gap' ' git commit -s -m "welcome $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( echo welcome && echo && @@ -468,7 +468,7 @@ test_expect_success 'signoff gap 2' ' We have now $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( echo welcome && echo && @@ -489,7 +489,7 @@ test_expect_success 'signoff respects trailer config' ' non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( echo subject && echo && @@ -506,7 +506,7 @@ Myfooter: x" && non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" > actual && + git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && ( echo subject && echo && @@ -560,14 +560,14 @@ test_expect_success 'amend commit to fix author' ' -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ expected && git commit --amend --author="$author" && - git cat-file -p HEAD > current && + git cat-file -p HEAD >current && test_cmp expected current ' test_expect_success 'git commit with dirty index' ' - echo tacocat > elif && - echo tehlulz > chz && + echo tacocat >elif && + echo tehlulz >chz && git add chz && git commit elif -m "tacocat is a palindrome" && git show --stat | grep elif && From patchwork Wed Nov 27 19:53:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264845 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 B3A51138C for ; Wed, 27 Nov 2019 19:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 889DB20835 for ; Wed, 27 Nov 2019 19:53:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ukbrJUyM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727350AbfK0Txr (ORCPT ); Wed, 27 Nov 2019 14:53:47 -0500 Received: from mail-pg1-f175.google.com ([209.85.215.175]:45941 "EHLO mail-pg1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txr (ORCPT ); Wed, 27 Nov 2019 14:53:47 -0500 Received: by mail-pg1-f175.google.com with SMTP id k1so11438605pgg.12 for ; Wed, 27 Nov 2019 11:53:45 -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=5J2Kfgd0IMTB5KtGw7AQr8y2Occ9OOTYJigPQz2KI7w=; b=ukbrJUyMpSWPbIpP/SnXauo8ye05WilxlSCgLvvun3TSlAaq+lLw7w+0crQnyeWhhH BbcDZKK78lsvsMq2iYP2HBK0OiZgkXtiPmlLeK8+9y/mHdFtRdWZ+e3KHtlzb4g0bs9q q7LImG/w/Fk/e9skbW8lB+OjaSYp7oyD6aMsFNg3Ofrnvj8hSKA2BA8m8C3KwuIQBa2I 7POmg0Sp4JjFbZMYMGpdAksDu+XMyZYpqRSAYkJSl405HJDP/LuaCq6HnUQw06+dRnpi 2EDWDEVEHGLwUptgaLknWCcdANvKcuqRkSp63QUDYqA86vjPQnTJrLW68+XL+zt3x2Ud 3qqw== 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=5J2Kfgd0IMTB5KtGw7AQr8y2Occ9OOTYJigPQz2KI7w=; b=ZCvLFhKE17BTpV4UN71IKdg82ZQmcKwhZp4hqoUkqubR+9Wd6C9LB1qQ0xG7Nn5eno qJpZCcDkdAYvcmTAkDKivMdVWSLD/MBAfyJeiXzFZ8YczunY8frlzhz+Mxx3mHIv6nx7 ikRACOZWag9BJr0WRmNsDfK5eg6pI8Oozjl8lw7sPBle5rju5wx3PLwCgItMlAMYkjYf 4MQnEVXjkzb/C3IscMKXPnQhfd+qF15XGvu2W0Wdosa1PEgn5kXg+fiPZFACP6brmCzF kZyn5LobrbMzRERz5/pS7lqsMrUz6nM0WuPYpxkbUihdOLZ2iMW+fiUTh+EFjEGGOjz4 DqiQ== X-Gm-Message-State: APjAAAXua7UyCUBDrzJGPvZgv9Q6PgTh/nAbKAh73Y3O0sJV3eD8X8fZ aICRgXXXbo8Ew2zjK//SgYvVyFgB X-Google-Smtp-Source: APXvYqxHsST+tyoZVqoaG1LwpY0SB5RVlsyxitg7nsHB/7393OrFTlLjvOI5xv1tpfctt685/ji26A== X-Received: by 2002:aa7:8252:: with SMTP id e18mr10329613pfn.261.1574884425192; Wed, 27 Nov 2019 11:53:45 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id x2sm17474497pfn.167.2019.11.27.11.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:44 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:43 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 17/26] t7501: stop losing return codes of git commands 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 In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream so that we will know if a command fails. In the 'interactive add' test case, we prepend a `test_must_fail` to `git commit --interactive`. When there are no changes to commit, `git commit` will exit with status code 1. Following along with the rest of the file, we use `test_must_fail` to test for this case. Signed-off-by: Denton Liu --- t/t7501-commit-basic-functionality.sh | 69 +++++++++++++++------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh index 5765d33c53..110b4bf459 100755 --- a/t/t7501-commit-basic-functionality.sh +++ b/t/t7501-commit-basic-functionality.sh @@ -285,9 +285,8 @@ test_expect_success 'overriding author from command line' ' ' test_expect_success PERL 'interactive add' ' - echo 7 | - git commit --interactive | - grep "What now" + echo 7 | test_must_fail git commit --interactive >out && + grep "What now" out ' test_expect_success PERL "commit --interactive doesn't change index if editor aborts" ' @@ -362,10 +361,10 @@ test_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $oldtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --author="$author" && git cat-file -p HEAD >current && test_cmp expected current @@ -377,10 +376,10 @@ test_expect_success 'amend commit to fix date' ' test_tick && newtick=$GIT_AUTHOR_DATE && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $newtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --date="$newtick" && git cat-file -p HEAD >current && test_cmp expected current @@ -409,12 +408,13 @@ test_expect_success 'sign off (1)' ' echo 1 >positive && git add positive && git commit -s -m "thank you" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo thank you && echo && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual @@ -428,13 +428,14 @@ test_expect_success 'sign off (2)' ' git commit -s -m "thank you $existing" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo thank you && echo && echo $existing && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual @@ -448,13 +449,14 @@ test_expect_success 'signoff gap' ' git commit -s -m "welcome $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo welcome && echo && echo $alt && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual ' @@ -468,15 +470,16 @@ test_expect_success 'signoff gap 2' ' We have now $alt" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo welcome && echo && echo We have now && echo $alt && echo && - git var GIT_COMMITTER_IDENT | - sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" + git var GIT_COMMITTER_IDENT >ident && + sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /" ident ) >expected && test_cmp expected actual ' @@ -489,7 +492,8 @@ test_expect_success 'signoff respects trailer config' ' non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo subject && echo && @@ -506,7 +510,8 @@ Myfooter: x" && non-trailer line Myfooter: x" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo subject && echo && @@ -538,7 +543,8 @@ test_expect_success 'multiple -m' ' >negative && git add negative && git commit -m "one" -m "two" -m "three" && - git cat-file commit HEAD | sed -e "1,/^\$/d" >actual && + git cat-file commit HEAD >commit && + sed -e "1,/^\$/d" commit >actual && ( echo one && echo && @@ -555,10 +561,10 @@ test_expect_success 'amend commit to fix author' ' oldtick=$GIT_AUTHOR_DATE && test_tick && git reset --hard && - git cat-file -p HEAD | + git cat-file -p HEAD >commit && sed -e "s/author.*/author $author $oldtick/" \ - -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" > \ - expected && + -e "s/^\(committer.*> \).*$/\1$GIT_COMMITTER_DATE/" \ + commit >expected && git commit --amend --author="$author" && git cat-file -p HEAD >current && test_cmp expected current @@ -570,8 +576,10 @@ test_expect_success 'git commit with dirty index' ' echo tehlulz >chz && git add chz && git commit elif -m "tacocat is a palindrome" && - git show --stat | grep elif && - git diff --cached | grep chz + git show --stat >stat && + grep elif stat && + git diff --cached >diff && + grep chz diff ' test_expect_success 'same tree (single parent)' ' @@ -584,7 +592,8 @@ test_expect_success 'same tree (single parent)' ' test_expect_success 'same tree (single parent) --allow-empty' ' git commit --allow-empty -m "forced empty" && - git cat-file commit HEAD | grep forced + git cat-file commit HEAD >commit && + grep forced commit ' From patchwork Wed Nov 27 19:53:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264847 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 2097915AB for ; Wed, 27 Nov 2019 19:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 00DDE2084D for ; Wed, 27 Nov 2019 19:53:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L6rZhfjV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727358AbfK0Txt (ORCPT ); Wed, 27 Nov 2019 14:53:49 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:44319 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txs (ORCPT ); Wed, 27 Nov 2019 14:53:48 -0500 Received: by mail-pj1-f67.google.com with SMTP id w8so10533342pjh.11 for ; Wed, 27 Nov 2019 11:53:48 -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=oSYv3IDSDLX8QBH2hFjskq7DU0N5bdk2cfFPPNtUL5s=; b=L6rZhfjVHjHgFJQCBqGhyiKZtu3jprO9RWGgOlp2FaqGcOuNQMOoTmlRPxEBi+kEHR 65/LxFx9Ess6IWCv60jCRyGXuWmlwux+8k4MOP5wOwIh6LbAa3gTODFyi3Cy2Q1xKSb7 WbEegOcBwSinjvleZV8E1dPmL/4OoYaRKIRnkMpj61OeEe9GOMpK7sBEDVpIt1y8JRtT qiGD/OWzBJqs4KruBkva5j9332yPhCe4fbOAT1YNBn7JPXmVsXwRIidwnSDRdC+GaeQb NTcYtyaYLppK6pLYPGtVtHlIfTHtPL7RA/ehglD+pRNqUN1DP/QDKs5b30woC2jJ4U8F iqDg== 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=oSYv3IDSDLX8QBH2hFjskq7DU0N5bdk2cfFPPNtUL5s=; b=arp+n0skpiDoGx6HP2BsaChIhmdR3pBjy8WgA1cydew4rANjqbIqNifTpdFqeSMzd+ 2mTwQPdwxE3t7XjKFsiVieerJLWGECtHfHMoJQsgnTi16GIy/XEmogbUPJTZH4J/KOAO BAFV7KLmrBxvITfgu130TFsLhRloH0VNXaaCr6IZBiEmrWSxbNv2hTWNALf5kaKYEcQt p7uTxM7dLTXu9bXa1HcoJuxf4UxHfODzFDq3nSNmxFV1rKrtL6sjY7f5I19Ka2dXeD2j WkHTx7IgxNmRkNE8GBOsA7b46JPkbdmX7e2UOeoUz0NB5eXEfFwz7+AEQJWpGmkgQK0j n3nA== X-Gm-Message-State: APjAAAU32/REE2mElTthrsSpD/eN3D3AewsER7LIcROyDp5Lk8JGBGL7 qcmwcD3+i5k0qaFGr5/5/b3O2Lpb X-Google-Smtp-Source: APXvYqzM5OOp5+oAqN1uvAmhM+6Bsxz5WLoYfx4/lGvNf62yzou/PZcBejTwOCRfrTshee96zTq/6g== X-Received: by 2002:a17:90a:fb53:: with SMTP id iq19mr8027518pjb.138.1574884427422; Wed, 27 Nov 2019 11:53:47 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id 9sm7326601pfx.177.2019.11.27.11.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:46 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:45 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 18/26] t7700: drop redirections to /dev/null 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 Since output is silenced when running without `-v` and debugging output is useful with `-v`, remove redirections to /dev/null as it is not useful. In one case where the output of stdout is consumed, redirect the output of test_commit to stderr. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 4e855bc21b..e1a689d6a9 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -5,7 +5,7 @@ test_description='git repack works correctly' . ./test-lib.sh commit_and_pack() { - test_commit "$@" >/dev/null && + test_commit "$@" 1>&2 && SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack /dev/null && + git pack-objects pack && # The second pack will contain the excluded object packsha1=$(git rev-list --objects --all | grep file2 | git pack-objects pack) && @@ -235,7 +235,7 @@ test_expect_success 'incremental repack does not complain' ' test_expect_success 'bitmaps can be disabled on bare repos' ' git -c repack.writeBitmaps=false -C bare.git repack -ad && - bitmap=$(ls bare.git/objects/pack/*.bitmap 2>/dev/null || :) && + bitmap=$(ls bare.git/objects/pack/*.bitmap || :) && test -z "$bitmap" ' From patchwork Wed Nov 27 19:53:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264849 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 BD39415AB for ; Wed, 27 Nov 2019 19:53:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D03A2084D for ; Wed, 27 Nov 2019 19:53:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uTY0pBMt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727377AbfK0Txw (ORCPT ); Wed, 27 Nov 2019 14:53:52 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46453 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfK0Txu (ORCPT ); Wed, 27 Nov 2019 14:53:50 -0500 Received: by mail-pl1-f196.google.com with SMTP id k20so5835051pll.13 for ; Wed, 27 Nov 2019 11:53:50 -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=TTGArOLNSDO/W+ec6Zao4SyPEJrHIiSW7J0frH7zG98=; b=uTY0pBMt5HUOzG5/HtC4PJmwh4rFQLIQZnc7Sd0CbT9R2B/ub05WeMtZulutMNOqIU qk5lD+la6c/NOxwc0QpHuO1W5NWBl0tNKZw/aVpRA5h+XquikYEgx3ctVf0JUFbXgeI1 sdMKw9oCfs4JhI3dQH+j6BV3/jeU+1phAZQDWZ++SsH3X+VhsA3mcZ643mQjgg7GsoyE sw/dptNRrf+6GtJ+pk7Hiso1F6r9Weq6WnznTXFxcqVMtOcsfMaSTnz8U9RTAqdqu3ec PgSsjzDwHkgUm8dLZeqSUSyUPL58dIEjy8EXzbNZK2mWYUzmmrwgS9f2oIkystHOFhXU nC5w== 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=TTGArOLNSDO/W+ec6Zao4SyPEJrHIiSW7J0frH7zG98=; b=SUwfOu7Z087ZqeWrt7FVDNOQCOwpPBsdqybeI8sg2YjHsBjYaMybZYu9PWkXsQiUUD ubDpJy92uGroCql0EZgCIHEF1/TonYr5iluf/TO+CGWJwTGtn7KAYZrboZBWvYyhjAtu vYGD7CYwtlezBbKGqtwuok5bEJURhQqzy61u/2FwKwl3ktfVV6i1yL5vhftOUPCgrvWi Amf+7oFVpDBUYLTQguPeYIE2jeKwVjlChX3QYpcLBCvhWR6QOTNCZynGxu+1EjTLVXiA 2w/JV97I9QbboWblfwA+BJFllkK8ZWacGZ/4+1WOFz78HEGrnkb5um1bnHgAh4Rs0T3U bS8g== X-Gm-Message-State: APjAAAWCq08LEvagJAdOvC7rGHa5xtW2yl6Xkn6qaP6w+xQtalZ8HNtQ jYHlJaW2pQDEsi8fn/XXUBt7NMtT X-Google-Smtp-Source: APXvYqxF+at9mEgdx2fs8Cp59IYFM7bl2DhquWIO7ZVvvCWmQsGvaiT9Jx/p/RR8+Er/WAlH4BL10A== X-Received: by 2002:a17:90a:cb16:: with SMTP id z22mr8300423pjt.71.1574884429567; Wed, 27 Nov 2019 11:53:49 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id a21sm7681343pjv.20.2019.11.27.11.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:49 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:47 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 19/26] t7700: remove spaces after redirect operators Message-ID: <58ae066d12144a226ceb7617a3597c5799a2cd58.1574884302.git.liu.denton@gmail.com> 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 For shell scripts, the usual convention is for there to be no space after redirection operators, (e.g. `>file`, not `> file`). Remove these spaces wherever they appear. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index e1a689d6a9..8936928387 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -11,8 +11,8 @@ commit_and_pack() { } test_expect_success 'objects in packs marked .keep are not repacked' ' - echo content1 > file1 && - echo content2 > file2 && + echo content1 >file1 && + echo content2 >file2 && git add . && test_tick && git commit -m initial_commit && @@ -75,8 +75,8 @@ test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' test_expect_success 'loose objects in alternate ODB are not repacked' ' mkdir alt_objects && - echo $(pwd)/alt_objects > .git/objects/info/alternates && - echo content3 > file3 && + echo $(pwd)/alt_objects >.git/objects/info/alternates && + echo content3 >file3 && objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && git add file3 && test_tick && @@ -111,7 +111,7 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' ' rm -f .git/objects/pack/* && - echo new_content >> file1 && + echo new_content >>file1 && git add file1 && test_tick && git commit -m more_content && @@ -169,12 +169,12 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | egrep "^$csha1 " | sort | uniq | wc -l) && - echo > .git/objects/info/alternates && + echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' ' - echo $(pwd)/alt_objects > .git/objects/info/alternates && + echo $(pwd)/alt_objects >.git/objects/info/alternates && echo "$csha1" | git pack-objects --non-empty --all --reflog pack && rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && @@ -186,7 +186,7 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | egrep "^$csha1 " | sort | uniq | wc -l) && - echo > .git/objects/info/alternates && + echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' @@ -196,7 +196,7 @@ test_expect_success 'objects made unreachable by grafts only are kept' ' H0=$(git rev-parse HEAD) && H1=$(git rev-parse HEAD^) && H2=$(git rev-parse HEAD^^) && - echo "$H0 $H2" > .git/info/grafts && + echo "$H0 $H2" >.git/info/grafts && git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all && git repack -a -d && git cat-file -t $H1 From patchwork Wed Nov 27 19:53:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264851 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 C4972138C for ; Wed, 27 Nov 2019 19:53:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A528720835 for ; Wed, 27 Nov 2019 19:53:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="epliJ1zm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727387AbfK0Txx (ORCPT ); Wed, 27 Nov 2019 14:53:53 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39673 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727372AbfK0Txx (ORCPT ); Wed, 27 Nov 2019 14:53:53 -0500 Received: by mail-pg1-f193.google.com with SMTP id b137so9149088pga.6 for ; Wed, 27 Nov 2019 11:53:52 -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=d1AG+rPKY26gU4AjXr/WO4BMUs1TbXq2102nCb0bGWo=; b=epliJ1zmXDobUIEkRtE+g/vAkVBKa4ZIXVP+OGwJPDhBYNWowxcFOL5Byy/u65ChPQ augnm9JsbDZP8c4FDvjHRkd911NO5lkGkLbqCP6Swv46E1zx0zrzW1fQ5vd42Lcvu48/ y62kw+9LVvk1JirQyxYytBj1Aoiu+U9EpOvKUyzt5uCG/7MXs7EzjQV+Km0CNeWA7FHQ ENaKBhkAkV5pEnaTPeImgeJSlpiW+Pbm2csoV5dLl+25AARPyboQkVt1oDhXLwFy5Le5 VZus+AM8t2lpYGnAmwVJquPUcQqFVPPh5R3Iwg1DvrtWoe+4JDqZlFZc0YYu80aOzgbB QD8A== 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=d1AG+rPKY26gU4AjXr/WO4BMUs1TbXq2102nCb0bGWo=; b=GjU4YQclxuD2uxABdVssn49J/sPoHiJLE8Owa84zprdbtx7iNL1eDpYLpHvd4hBUb3 c7Kqu4SUKWysPlMWZ4hq9YnpQ7mPfnnO4Ne4pxwtDtgRrTGrzqVezSdh2eeFr4pWpuyG gmEgny0si61ryj0bi9bi5Yc4gAq1e9JGwMyuiMkk9o2x5mun+ck7n1jj/R+IA55vlkHi lLRQcX90oQ+bQJBmn2VNw87sF+6zawzD3QniksFCzUO9PIaAUAl61y+0pEIA/mOS+ovc 28QZUyHoKdTdmgENzfWFZ99Bhdw+fkBetoqxeDC5a1+kvewOaG8VuIhuXz3j5Rm0T05H f3AQ== X-Gm-Message-State: APjAAAU/odXf023P0c4+SJYi5/fKOiwrGF+AQntsMXA6YPRpOY82r449 eqwrH1C4hEADgcas2bvlkNLAsRBK X-Google-Smtp-Source: APXvYqw0KQI7MAWYYHk/RYxww4w3ZojL3/qg+4nvkX+KuObKJF8KbWk+2VRzD+KKtMKDU/4AMu6aSw== X-Received: by 2002:a62:e716:: with SMTP id s22mr48969836pfh.258.1574884431861; Wed, 27 Nov 2019 11:53:51 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id y14sm18087001pff.69.2019.11.27.11.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:51 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:49 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 20/26] t7700: move keywords onto their own line Message-ID: <82bf24d06ab663d404a717ae9091dd272d1c3396.1574884302.git.liu.denton@gmail.com> 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 The code style for tests is to have statements on their own line if possible. Move keywords onto their own line so that they conform with the test style. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 51 +++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 8936928387..a96e876c4e 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -29,10 +29,12 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && - for p in .git/objects/pack/*.idx; do + for p in .git/objects/pack/*.idx + do idx=$(basename $p) test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then + if git verify-pack -v $p | egrep "^$objsha1" + then found_duplicate_object=1 echo "DUPLICATE OBJECT FOUND" break @@ -45,10 +47,12 @@ test_expect_success 'writing bitmaps via command-line can duplicate .keep object # build on $objsha1, $packsha1, and .keep state from previous git repack -Adbl && test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx; do + for p in .git/objects/pack/*.idx + do idx=$(basename $p) test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then + if git verify-pack -v $p | egrep "^$objsha1" + then found_duplicate_object=1 echo "DUPLICATE OBJECT FOUND" break @@ -61,10 +65,12 @@ test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' # build on $objsha1, $packsha1, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx; do + for p in .git/objects/pack/*.idx + do idx=$(basename $p) test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1"; then + if git verify-pack -v $p | egrep "^$objsha1" + then found_duplicate_object=1 echo "DUPLICATE OBJECT FOUND" break @@ -83,8 +89,10 @@ test_expect_success 'loose objects in alternate ODB are not repacked' ' git commit -m commit_file3 && git repack -a -d -l && git prune-packed && - for p in .git/objects/pack/*.idx; do - if git verify-pack -v $p | egrep "^$objsha1"; then + for p in .git/objects/pack/*.idx + do + if git verify-pack -v $p | egrep "^$objsha1" + then found_duplicate_object=1 echo "DUPLICATE OBJECT FOUND" break @@ -99,10 +107,13 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is git repack -a && myidx=$(ls -1 .git/objects/pack/*.idx) && test -f "$myidx" && - for p in alt_objects/pack/*.idx; do + for p in alt_objects/pack/*.idx + do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then + done | while read sha1 rest + do + if ! ( git verify-pack -v $myidx | grep "^$sha1" ) + then echo "Missing object in local pack: $sha1" return 1 fi @@ -119,10 +130,13 @@ test_expect_success 'packed obs in alt ODB are repacked when local repo has pack git repack -a -d && myidx=$(ls -1 .git/objects/pack/*.idx) && test -f "$myidx" && - for p in alt_objects/pack/*.idx; do + for p in alt_objects/pack/*.idx + do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then + done | while read sha1 rest + do + if ! ( git verify-pack -v $myidx | grep "^$sha1" ) + then echo "Missing object in local pack: $sha1" return 1 fi @@ -144,10 +158,13 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' git repack -a -d && myidx=$(ls -1 .git/objects/pack/*.idx) && test -f "$myidx" && - for p in alt_objects/pack/*.idx; do + for p in alt_objects/pack/*.idx + do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest; do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ); then + done | while read sha1 rest + do + if ! ( git verify-pack -v $myidx | grep "^$sha1" ) + then echo "Missing object in local pack: $sha1" return 1 fi From patchwork Wed Nov 27 19:53:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264853 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 0D757138C for ; Wed, 27 Nov 2019 19:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E09C12082D for ; Wed, 27 Nov 2019 19:53:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ICjysmm8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbfK0Tx4 (ORCPT ); Wed, 27 Nov 2019 14:53:56 -0500 Received: from mail-pf1-f169.google.com ([209.85.210.169]:40779 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727372AbfK0Txz (ORCPT ); Wed, 27 Nov 2019 14:53:55 -0500 Received: by mail-pf1-f169.google.com with SMTP id i187so7452476pfc.7 for ; Wed, 27 Nov 2019 11:53:54 -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=5Hu/LIm/VDUQszegUkq9qsUTerKLJT8Ea6zTzzQS+Xs=; b=ICjysmm82uduerNofI7iluZEJlIil0GGV9AaIKxQQ1CCI7TZe85R9sRihMRI+nsZ5l ban1Z5vQPZnpV5KZggr1UHtMZ06zZlNIojz+A+Nmhbxgo1qTR2eUUn+wtoboNljbVwbM 0FZKf3eKegtyfkcosnG0UeiUuSB+gI/hleZ28voEfJPJpCRX685WaV9mX98EQQERzrJA KpmCfFRcMG8BuLQCBKhZI0oCpPdqTGAFhJ71tqxHMe2p4/VVFn78puvqoUhUM9WMVFTe kh4BO7WxVzudZGZdu2upLIGsky2bJ7TM1hRJ8OdkXXt6c1D0syQ9VLoLe6fgsqncixVC z4ug== 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=5Hu/LIm/VDUQszegUkq9qsUTerKLJT8Ea6zTzzQS+Xs=; b=dy/dQg0xkMCcHrncg4/v/hbr1Uzu3LBe4jzQ43MXIpUQlyDPNVUAYGtg23NCDmhbmm 8nq4GtsqcpA2oyFJOC8TXr0lvTI5xTDMuYNcL4s6MgMYngLdXBsCY8sOxCOyOtPZrx0q Xztip2o900rAVtwl+vFf5FiVFX/4lFqz81/XTHzG5RASMOTfTRzxuDL4hvKDXpVHynTk Mef45vzcOGOvHahqCPvHnMGH9y5iRuunmEx/42TdFYnTgn964OTIe4qq9STh8HA4G2vG 7NUVNkoVM6owVKtu2gcFyFrXCluA6EZufNK+k2Zx+ZSJ9b0/ey0ORcVaQ1z71pqUfve8 iEeQ== X-Gm-Message-State: APjAAAWeXqCoh1w8iRg+xM3b1n0yRVPuQiI0hpvoQhCuXXAgEOMlLrtg kFyQJP+ahsbg1gEJghcpTLBlxRbg X-Google-Smtp-Source: APXvYqx7KR1hHlSGAVJ3YoijSJvgiYLDidea9jW7IeDVDrI+ouvwAv3/lidkG4cFU5bbpsOIcl5MZg== X-Received: by 2002:a62:ac06:: with SMTP id v6mr48189270pfe.210.1574884434090; Wed, 27 Nov 2019 11:53:54 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id e8sm17017607pgj.80.2019.11.27.11.53.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:53 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:52 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 21/26] t7700: s/test -f/test_path_is_file/ Message-ID: <251de77677a9eda0d13c3f5668fa456ad4a52902.1574884302.git.liu.denton@gmail.com> 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 Since we have debugging-friendly alternatives to `test -f`, replace instances of `test -f` with `test_path_is_file` so that if a command ever fails, we get better debugging information. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index a96e876c4e..1d14ddcbdb 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -106,7 +106,7 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is mv .git/objects/pack/* alt_objects/pack && git repack -a && myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && + test_path_is_file "$myidx" && for p in alt_objects/pack/*.idx do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" @@ -129,7 +129,7 @@ test_expect_success 'packed obs in alt ODB are repacked when local repo has pack git repack && git repack -a -d && myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && + test_path_is_file "$myidx" && for p in alt_objects/pack/*.idx do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" @@ -148,7 +148,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' for p in alt_objects/pack/*.pack do base_name=$(basename $p .pack) && - if test -f alt_objects/pack/$base_name.keep + if test_path_is_file alt_objects/pack/$base_name.keep then rm alt_objects/pack/$base_name.keep else @@ -157,7 +157,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' done && git repack -a -d && myidx=$(ls -1 .git/objects/pack/*.idx) && - test -f "$myidx" && + test_path_is_file "$myidx" && for p in alt_objects/pack/*.idx do git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" From patchwork Wed Nov 27 19:53:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264855 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 64E2F15AB for ; Wed, 27 Nov 2019 19:53:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44E3A20835 for ; Wed, 27 Nov 2019 19:53:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RXg2KDvS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727428AbfK0Tx6 (ORCPT ); Wed, 27 Nov 2019 14:53:58 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43636 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0Tx5 (ORCPT ); Wed, 27 Nov 2019 14:53:57 -0500 Received: by mail-pg1-f194.google.com with SMTP id b1so11447514pgq.10 for ; Wed, 27 Nov 2019 11:53:57 -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=SprpPHFts+yK6L/4hjzS3PhdnhVvYxKd7dbVJf8t4vk=; b=RXg2KDvSV46WRBxtuSJai8DD/xDlRZdlh0qK3EP8G0e8xxBTcctYIwT3I2nZeTP4N0 Sv3lGHnS3zM2+xTYttVAnFfaQFlJdyaurC/db652JGr259uEIWso9xomp4lT+GTOwoQS YTviI37USXIb82JNxuYs0RqnQKGmI3lDwH6bug6ME38tb373kR7dwhkENWuwfOBP0JBw aINQMQa2XHNT3yYhxRo/5oUskS23Nid5/5jEa02gzB/Yl7vrv3Y3STg9K8QwJ9P0Mlfx Hfa3BQbUH6KWWv0VA/8s3lWiwFdbv8dXlcE0MWFjHic09H0cQPyegvqlXY1uT1bj2A+z NVdg== 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=SprpPHFts+yK6L/4hjzS3PhdnhVvYxKd7dbVJf8t4vk=; b=lNm+yGtg1ru0ZXaS001nhOtcVNwwkzBfdwx39s+f4V+tMFhmmpKhM5GTixPrK/SJ/P PRwS6/BIM/+V8re1FaOFPr9QTC5fVJBkGMUEm/0Mq28CxnhTtWTEmLdqiMTESjZhUI3C m+BtxgOpoJkF75cOBtvsfIIOdrkzhe8q5hLY+RnMiUHi9Ub34fpclO1Gvd0B/M3zRrKQ Bj55HGi7Rrq+ucIS072Ou7YEzKGA+UH5Zzce80j1KhMKegzoQUNMt2cjdszo3I2behDg Q/ugKoGlkw/7Di0iExe9XqpRkvELnSO6xemI0LcokyFUN3JJ8b1SDLJBtS+TOa3p0lz9 q6lw== X-Gm-Message-State: APjAAAVIE/kgqErSANoiWu30FM8nQYp6IUvvAHOaEUYGXEKMeFjAqcdK HV6A1rg7vUpmO2VeVnwYjPbCZya8 X-Google-Smtp-Source: APXvYqw9hzSnQpAsLx2OfAXC5fIPw33kyzR4cIW1McV1xYMBsPCuFGhLRT8jK7wfI5Zn2Cn/QBAelQ== X-Received: by 2002:a63:1365:: with SMTP id 37mr3691564pgt.28.1574884436405; Wed, 27 Nov 2019 11:53:56 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id e10sm8112455pfm.3.2019.11.27.11.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:55 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:54 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 22/26] t7700: consolidate code into test_no_missing_in_packs() 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 The code to test that objects were not missing from the packfile was duplicated many times. Extract the duplicated code into test_no_missing_in_packs() and use that instead. Refactor the resulting extraction so that if any git commands fail, their return codes are not silently lost. We were using sed to filter lines. Although not incorrect, this is exactly what grep is built for. Replace this invocation of sed with grep so that we use the correct tool for the job. Instead of verifying each file of `alt_objects/pack/*.idx` individually in a for-loop, batch them together into one verification step. The original testing construct was O(n^2): it used a grep in a loop to test whether any objects were missing in the packfile. Rewrite this to sort the files then use `comm -23` so that finding missing lines from the original file is done more efficiently. While we're at it, add a space to `commit_and_pack ()` for style. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 55 +++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 40 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 1d14ddcbdb..4bcd9fcc80 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -4,12 +4,23 @@ test_description='git repack works correctly' . ./test-lib.sh -commit_and_pack() { +commit_and_pack () { test_commit "$@" 1>&2 && SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack orig.raw && + grep "^[0-9a-f]\{40\}" orig.raw | cut -d" " -f1 | sort >orig && + git verify-pack -v $myidx >dest.raw && + cut -d" " -f1 dest.raw | sort >dest && + comm -23 orig dest >missing && + test_must_be_empty missing +} + test_expect_success 'objects in packs marked .keep are not repacked' ' echo content1 >file1 && echo content2 >file2 && @@ -105,19 +116,7 @@ test_expect_success 'packed obs in alt ODB are repacked even when local repo is mkdir alt_objects/pack && mv .git/objects/pack/* alt_objects/pack && git repack -a && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alt ODB are repacked when local repo has packs' ' @@ -128,19 +127,7 @@ test_expect_success 'packed obs in alt ODB are repacked when local repo has pack git commit -m more_content && git repack && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' @@ -156,19 +143,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' fi done && git repack -a -d && - myidx=$(ls -1 .git/objects/pack/*.idx) && - test_path_is_file "$myidx" && - for p in alt_objects/pack/*.idx - do - git verify-pack -v $p | sed -n -e "/^[0-9a-f]\{40\}/p" - done | while read sha1 rest - do - if ! ( git verify-pack -v $myidx | grep "^$sha1" ) - then - echo "Missing object in local pack: $sha1" - return 1 - fi - done + test_no_missing_in_packs ' test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' From patchwork Wed Nov 27 19:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264857 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 4AD6415AB for ; Wed, 27 Nov 2019 19:54:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29E7E2082D for ; Wed, 27 Nov 2019 19:54:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XrgmezLU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727432AbfK0TyA (ORCPT ); Wed, 27 Nov 2019 14:54:00 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39685 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0TyA (ORCPT ); Wed, 27 Nov 2019 14:54:00 -0500 Received: by mail-pg1-f193.google.com with SMTP id b137so9149248pga.6 for ; Wed, 27 Nov 2019 11:54:00 -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=FTtG2eg54HJ8MNXH5T8m8riTIBnJQi+iLgrelc3/uXs=; b=XrgmezLU3qXvF5GtEBR9dO/IUJ82cwYFq6Di9BuQFt12tmc2tsbI4o3iz7zyLJzBan cn7wO/jAMTvTn79hXY251I4dG+a7DJQ2Rxrw+Upvrv+4RlTK2yv1HekdQSQ7+awnZUmU ARrdg8O7xx+b7L+rbrtVQP6m1SGUctbAOJpwfLf0dBclVFAf41nSgF8woUXTOf9ebiMX VSVHRPBuFai5d2OlBLQwUj9829nq6H2f/fAuv25Vi/d3aZCzWHU8OX1987GXoM0ZekSo IBfr64AUd8Yhgs/v0dPke0f3SsXi0XAILNnoTYMWS8ZdIK9w/QaBdDPltJUvDgkJEJXU UfNw== 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=FTtG2eg54HJ8MNXH5T8m8riTIBnJQi+iLgrelc3/uXs=; b=F3fO9afanCtZ/pnl+JmtkvIMcHZSx2FOvbG0J7HMjKq3504sRxsTrTpbttONazmIk0 lkY8beF/seG4P097InMkIdot+FEmmi0c78LTmMYpZmUI8kCa+0r1HpCALrtoflPnspCx w0VzVXOruUn728lRzTXx1B/90VtszPPgPTkqYgA9cywxw9xl65Y3Sn8OJJcYIbadpGn8 g2xrznuPTXznxiHVxyX84hQbKvSaiCgd5TONgeA2hdVJClnaseb+5M50uRQZzuHho8WH TMp5E1x3HFLl3/YS8KPU2x1QAJc1t59fvlf2iXyfoUugPbsbGOkFJrN/KsqSotlaI7h5 5vfg== X-Gm-Message-State: APjAAAUp+SyKk6dwZ6Zi30BOzAdniP4zZTbUa/sMpJ2HphY0ZjdCMobV TLZhMtGb0slOzDnv/F179L8Sh8u4 X-Google-Smtp-Source: APXvYqxpukd674Pf1Qnp4SBfsufYvdLairz7HQ09zqh5FCZ94lpG/Sy61xunMLwF/VO9Ui250W5LuQ== X-Received: by 2002:a63:e316:: with SMTP id f22mr6915329pgh.102.1574884439257; Wed, 27 Nov 2019 11:53:59 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id x190sm17542528pfc.89.2019.11.27.11.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:53:58 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:56 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 23/26] t7700: consolidate code into test_has_duplicate_object() 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 The code to test that objects were not duplicated from the packfile was duplicated many times. Extract the duplicated code into test_has_duplicate_object() and use that instead. Refactor the resulting extraction so that if the git command fails, the return code is not silently lost. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 71 +++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 4bcd9fcc80..5bbed02fe5 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -21,6 +21,25 @@ test_no_missing_in_packs () { test_must_be_empty missing } +# we expect $packsha1 and $objsha1 to be defined +test_has_duplicate_object () { + want_duplicate_object="$1" + found_duplicate_object=false + for p in .git/objects/pack/*.idx + do + idx=$(basename $p) + test "pack-$packsha1.idx" = "$idx" && continue + git verify-pack -v $p >packlist || return $? + if egrep "^$objsha1" packlist + then + found_duplicate_object=true + echo "DUPLICATE OBJECT FOUND" + break + fi + done && + test "$want_duplicate_object" = "$found_duplicate_object" +} + test_expect_success 'objects in packs marked .keep are not repacked' ' echo content1 >file1 && echo content2 >file2 && @@ -40,54 +59,19 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' ' # build on $objsha1, $packsha1, and .keep state from previous git repack -Adbl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' # build on $objsha1, $packsha1, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && - test_when_finished "found_duplicate_object=" && - for p in .git/objects/pack/*.idx - do - idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test "$found_duplicate_object" = 1 + test_has_duplicate_object true ' test_expect_success 'loose objects in alternate ODB are not repacked' ' @@ -100,16 +84,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' ' git commit -m commit_file3 && git repack -a -d -l && git prune-packed && - for p in .git/objects/pack/*.idx - do - if git verify-pack -v $p | egrep "^$objsha1" - then - found_duplicate_object=1 - echo "DUPLICATE OBJECT FOUND" - break - fi - done && - test -z "$found_duplicate_object" + test_has_duplicate_object false ' test_expect_success 'packed obs in alt ODB are repacked even when local repo is packless' ' From patchwork Wed Nov 27 19:53:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264859 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 8E91E138C for ; Wed, 27 Nov 2019 19:54:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DE2F2082D for ; Wed, 27 Nov 2019 19:54:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="deNUXGSW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727435AbfK0TyD (ORCPT ); Wed, 27 Nov 2019 14:54:03 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38612 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0TyC (ORCPT ); Wed, 27 Nov 2019 14:54:02 -0500 Received: by mail-pf1-f196.google.com with SMTP id c13so11628239pfp.5 for ; Wed, 27 Nov 2019 11:54:02 -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=1JomHC6LB2LqdeWqVL7bdOCmbQ9QjDWk8FVTfc3HdNU=; b=deNUXGSWLR+RHlYzTpNT9WdQrxCS2j1UX0LrTJUYUaZN2A3muXZXBH0rh/h7WM5lJt jl+z2nvco0gX95cdToy2llGk2p1/F5/popZX5kcR1A4WeG3uCzG+fiaHvnEmBV/bmqgJ /SUuCA776XO9+v70OWq7TOQOef2UmV/VLNjFsiNMeb4EPx7TeyOaLcedcg5UIDpyHId2 iLgdheiDbpFtsrnhuoNccGQ3VTDgi0FN70jyS/WB5ncRIyigprU/1rnixFT1iZ21pO7w vJQm+wjUT90Dc7gDzEBFPo7+ZeYTgmXeC8Ix1gICeWfyCdAlZyzMsxcas2TuB0/TbQw8 IiOQ== 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=1JomHC6LB2LqdeWqVL7bdOCmbQ9QjDWk8FVTfc3HdNU=; b=CVpRV1V8qTYIsYYx/5k5Uk0Ow8rdSxZW7aQ2P/jTyA6AWQ9jfrwg1TY1BwCHOayOsf 5R7Jso0ogNpV6bAba1jLXIDTzfNq1d+edXUHv/oIfYyWCuqFXBM/HeSeFlVgip8djavj HNIP/Tol6KhikPH4C4PLbuWgSLylihQtVIKcOT2LOJxuCXfjnM3EqC1qmS5QQUyzdZki Lc3mq99RauQ1gcPUVWL8A62lhsi1cpwLygsGf66j1rHxC0kRtGaTv7fXtLThhjgG3gsx MuEw1b5G9eEdmJj86snW9lAnjGGcdmtQi/WGdK332upDW8UmKgZCub30WEfM3Mk4FAgn tw3g== X-Gm-Message-State: APjAAAUFzsCQdgbzqkNcvlnnH2z6f4dN6oMuOn/C9Skl6cmkfvKslIrv ZuUWJKplNk9CL9mTK1AuKnjsGkQW X-Google-Smtp-Source: APXvYqyZVyNKTTmE1yw/aJP/6F1bdPi9lygdwiUEJZ3g8xeA5F3hD/NiZx/XwaKqUL+6vHm8cKQwow== X-Received: by 2002:a63:36c4:: with SMTP id d187mr7016685pga.108.1574884441629; Wed, 27 Nov 2019 11:54:01 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id b5sm7731538pjp.13.2019.11.27.11.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:54:01 -0800 (PST) Date: Wed, 27 Nov 2019 11:53:59 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 24/26] t7700: replace egrep with grep Message-ID: <632a62f6e9cdd58bebe7203ded8bbb9aea7c4c62.1574884302.git.liu.denton@gmail.com> 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 The egrep expressions in this test suite were of the form `^$variable`. Although egrep works just fine, it's overkill since we're not using any extended regex. Replace egrep invocations with grep so that we aren't swatting flies with a sledgehammer. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 5bbed02fe5..2493cc4e9b 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -30,7 +30,7 @@ test_has_duplicate_object () { idx=$(basename $p) test "pack-$packsha1.idx" = "$idx" && continue git verify-pack -v $p >packlist || return $? - if egrep "^$objsha1" packlist + if grep "^$objsha1" packlist then found_duplicate_object=true echo "DUPLICATE OBJECT FOUND" @@ -135,7 +135,7 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - egrep "^$csha1 " | sort | uniq | wc -l) && + grep "^$csha1 " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' @@ -152,7 +152,7 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - egrep "^$csha1 " | sort | uniq | wc -l) && + grep "^$csha1 " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && test_must_fail git show $csha1 ' From patchwork Wed Nov 27 19:54:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264861 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 B1D4315AB for ; Wed, 27 Nov 2019 19:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 910C82082D for ; Wed, 27 Nov 2019 19:54:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FzjhCx4a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727438AbfK0TyF (ORCPT ); Wed, 27 Nov 2019 14:54:05 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:46235 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0TyE (ORCPT ); Wed, 27 Nov 2019 14:54:04 -0500 Received: by mail-pf1-f196.google.com with SMTP id 193so11603538pfc.13 for ; Wed, 27 Nov 2019 11:54:04 -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=jNXcIvtvWOwcVTxfpktNTETrPxCxnPgY27D0nrw2y1A=; b=FzjhCx4aRGeewjJSNHK5s0n/bYEVudTGa6GXQ+UyrgX4mw39pk83YWLo8Dp+hJOfhA RhZBg/6qbZD6IS2l58ZvPohC17+FReyXOD3Hxt+J75Du/OqAS+sxsoo8roKnrvw6ErWh pF8AWmnRz+zv7oZbD+Of71Rb1jwbr66SUSS3R0sBOIgihXal+ge0VmAS+5Mr5EAS3a9s G3i2LbgGNt/e/JzamqY31Y6PsQq/P+cs+RerlAurW7pb6XY6VzmN3VqK8j5jn7yv6a+2 Y5kCw344K8rdAJm4n2S4z6x2UxDgJTtNjwsm86ZvuKMzF+97LKspYfnJwwARZCRidiuA 7MDg== 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=jNXcIvtvWOwcVTxfpktNTETrPxCxnPgY27D0nrw2y1A=; b=TZxYcJdypgiyzb4B/Emc9prIKyFkI9zbvHf2JXyWb/iCK6itDFFdLRpuClDoxMdwU2 x714NOg9S/46t7CheiLHHlBrnmu5NouwQvNtfIHNTu6EqklZxZIjKkewbENivxbgvQkk gQokMcFpqihKQyzn42Ye60Ylm9qDnOR/vlJG+KoY6pFIL0b5ahLwdqtIldL9B7f/keqa ihyiFb9wZ8tPJXqOIwXvQTrO18qJn/VKhh+PQyK0NR1lusd044aAuPEjE3+J50EM4y6O eVqiitGOeS30OTi0OYDaYop+GXHuUt6gzSdZIibe38BHZ7EKgMmXN+aGkIkankC2rjF8 33RQ== X-Gm-Message-State: APjAAAUBy+tZWiXSACux9zjwQL8/S/Z31TxkJc9hrJbp9CA/Xu8UNXAY Z4BlJ2qYDlKr4Z3v1iFHxZYGrH9h X-Google-Smtp-Source: APXvYqwa1QAWG+ghVIG2jHMZoUHK1+XLK9fd9UT0/JBY/HNCLuo6XMCN55BZ8VpgoiZ4oDqa8T7t+w== X-Received: by 2002:a63:1f1c:: with SMTP id f28mr7211096pgf.406.1574884443861; Wed, 27 Nov 2019 11:54:03 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id h5sm1305074pfk.30.2019.11.27.11.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:54:03 -0800 (PST) Date: Wed, 27 Nov 2019 11:54:01 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 25/26] t7700: make references to SHA-1 generic 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 Make the test more hash-agnostic by renaming variables from "sha1" to some variation of "oid" or "packid". Also, replace the regex, `[0-9a-f]\{40\}` with `$OID_REGEX`. A better name for "incrpackid" (incremental pack-id) might have been just "packid". However, later in the test suite, we have other uses of "packid". Although the scopes of these variables don't conflict, a future developer may think that commit_and_pack() and test_has_duplicate_object() are semantically related somehow since they share the same variable name. Give them distinct names so that it's clear these uses are unrelated. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 2493cc4e9b..1edb21bf93 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -6,31 +6,31 @@ test_description='git repack works correctly' commit_and_pack () { test_commit "$@" 1>&2 && - SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack orig.raw && - grep "^[0-9a-f]\{40\}" orig.raw | cut -d" " -f1 | sort >orig && + grep "^$OID_REGEX" orig.raw | cut -d" " -f1 | sort >orig && git verify-pack -v $myidx >dest.raw && cut -d" " -f1 dest.raw | sort >dest && comm -23 orig dest >missing && test_must_be_empty missing } -# we expect $packsha1 and $objsha1 to be defined +# we expect $packid and $oid to be defined test_has_duplicate_object () { want_duplicate_object="$1" found_duplicate_object=false for p in .git/objects/pack/*.idx do idx=$(basename $p) - test "pack-$packsha1.idx" = "$idx" && continue + test "pack-$packid.idx" = "$idx" && continue git verify-pack -v $p >packlist || return $? - if grep "^$objsha1" packlist + if grep "^$oid" packlist then found_duplicate_object=true echo "DUPLICATE OBJECT FOUND" @@ -51,11 +51,11 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' git rev-list --objects --all | grep -v file2 | git pack-objects pack && # The second pack will contain the excluded object - packsha1=$(git rev-list --objects --all | grep file2 | + packid=$(git rev-list --objects --all | grep file2 | git pack-objects pack) && - >pack-$packsha1.keep && - objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 | - sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") && + >pack-$packid.keep && + oid=$(git verify-pack -v pack-$packid.idx | head -n 1 | + sed -e "s/^\($OID_REGEX\).*/\1/") && mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && @@ -63,13 +63,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' ' test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git repack -Adbl && test_has_duplicate_object true ' test_expect_success 'writing bitmaps via config can duplicate .keep objects' ' - # build on $objsha1, $packsha1, and .keep state from previous + # build on $oid, $packid, and .keep state from previous git -c repack.writebitmaps=true repack -Adl && test_has_duplicate_object true ' @@ -78,7 +78,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' ' mkdir alt_objects && echo $(pwd)/alt_objects >.git/objects/info/alternates && echo content3 >file3 && - objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && + oid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) && git add file3 && test_tick && git commit -m commit_file3 && @@ -124,7 +124,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' ' test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f alt_objects/pack/*.keep && mv .git/objects/pack/* alt_objects/pack/ && - csha1=$(git rev-parse HEAD^{commit}) && + coid=$(git rev-parse HEAD^{commit}) && git reset --hard HEAD^ && test_tick && git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all && @@ -135,14 +135,14 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep "^$csha1 " | sort | uniq | wc -l) && + grep "^$coid " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && - test_must_fail git show $csha1 + test_must_fail git show $coid ' test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' ' echo $(pwd)/alt_objects >.git/objects/info/alternates && - echo "$csha1" | git pack-objects --non-empty --all --reflog pack && + echo "$coid" | git pack-objects --non-empty --all --reflog pack && rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && # The pack-objects call on the next line is equivalent to @@ -152,9 +152,9 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar rm -f .git/objects/pack/* && mv pack-* .git/objects/pack/ && test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx | - grep "^$csha1 " | sort | uniq | wc -l) && + grep "^$coid " | sort | uniq | wc -l) && echo >.git/objects/info/alternates && - test_must_fail git show $csha1 + test_must_fail git show $coid ' test_expect_success 'objects made unreachable by grafts only are kept' ' From patchwork Wed Nov 27 19:54:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11264863 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 CD38515AB for ; Wed, 27 Nov 2019 19:54:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADAAE20835 for ; Wed, 27 Nov 2019 19:54:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YaI0Rugh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727443AbfK0TyI (ORCPT ); Wed, 27 Nov 2019 14:54:08 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38511 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbfK0TyH (ORCPT ); Wed, 27 Nov 2019 14:54:07 -0500 Received: by mail-pg1-f194.google.com with SMTP id t3so11018323pgl.5 for ; Wed, 27 Nov 2019 11:54:07 -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=X7N4J8rstHNCXMeIkDde+BaZpUa1sAaV3I3B+UrlLPs=; b=YaI0RughtqgmxCRgw+2HLrC8X07bYwXsVpvmaN6Y7NiE7fR24Hb9bF4Ce2V4tWHhmI yS3Mmi6y7j7M4gtf2JvBJZMq9WEML6TOlRKntNxalGTfN+ktTRIh2My4cxgKGKfczDPn Oj8lylcVD0li4dU8tL/09gUDY0VGjmx56QN8vq2cPEZgYeqJwgiY8V/83lZKHUqjz+Sf HjhtQKrSgWdc/+/uTGI9Q6YkjXNItIgWJQHK8azWKkNXAHvsJ5RVXLBfsoWRsOTIT+iM FDGD45I/L9MWra3uBj6yys21JyeQZqM4Jvg3rPHsKjMnaHFlvB66jwrRnk1/qaqV7Yno OBCw== 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=X7N4J8rstHNCXMeIkDde+BaZpUa1sAaV3I3B+UrlLPs=; b=lGvULQqhVKYKMvrclzfdGJWosBGEqqCvPMnNP43+Xx87YI76L9dtEqc7xsyM/OdMEu s1htrpBkMm6l8bccAimuGu8YTGc5O/fU3xiDIO6w2KrFYapxpBNGy4MeMyr/79BfsG/+ Oxo4QqeN9MQP+m3hM9WeOQhZFHQZmu9bqBzd5p44vzPRXk1z+/A1xGkzfdKFpMgT/uIl MTddCkcHX/KEqeTTzI/RrlOONPTgPQDm2PTSO7eQQ4tkEJeDNunJI2DgEIpAhBY/EZhR FDFQKbfrtA4IhbiiDjjXAfUFL5AJyj3dTUUs6Kv4CMv4K6XlvkvjFHfEMdx0j5Z2sW52 uhfw== X-Gm-Message-State: APjAAAXSUzDw4zK/q7vLhBe28C4SvaGo8gFxFdfeP0oNHX4mWrycXLRy eBY7zapIIHnWCjqXTwsXWFl5Ef82 X-Google-Smtp-Source: APXvYqwBOhIU4BdKvrlP1NyzevjwDLrhxcMgv+2cFlgoRfzhlPxWkir+RhlBMXEyIIqMtCjbRZYwMQ== X-Received: by 2002:a65:4c4c:: with SMTP id l12mr6662315pgr.377.1574884446299; Wed, 27 Nov 2019 11:54:06 -0800 (PST) Received: from generichostname ([204.14.239.138]) by smtp.gmail.com with ESMTPSA id u20sm17158661pgf.29.2019.11.27.11.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 11:54:05 -0800 (PST) Date: Wed, 27 Nov 2019 11:54:04 -0800 From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano , Jeff King Subject: [PATCH v5 26/26] t7700: stop losing return codes of git commands Message-ID: <1f6d9a80ad45fd9f51c8cffe9ce3721fce9b80c0.1574884302.git.liu.denton@gmail.com> 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 In a pipe, only the return code of the last command is used. Thus, all other commands will have their return codes masked. Rewrite pipes so that there are no git commands upstream so that we will know if a command fails. Signed-off-by: Denton Liu --- t/t7700-repack.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh index 1edb21bf93..d5cce7c06f 100755 --- a/t/t7700-repack.sh +++ b/t/t7700-repack.sh @@ -48,14 +48,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' ' git commit -m initial_commit && # Create two packs # The first pack will contain all of the objects except one - git rev-list --objects --all | grep -v file2 | - git pack-objects pack && + git rev-list --objects --all >objs && + grep -v file2 objs | git pack-objects pack && # The second pack will contain the excluded object - packid=$(git rev-list --objects --all | grep file2 | - git pack-objects pack) && + packid=$(grep file2 objs | git pack-objects pack) && >pack-$packid.keep && - oid=$(git verify-pack -v pack-$packid.idx | head -n 1 | - sed -e "s/^\($OID_REGEX\).*/\1/") && + git verify-pack -v pack-$packid.idx >packlist && + oid=$(head -n 1 packlist | sed -e "s/^\($OID_REGEX\).*/\1/") && mv pack-* .git/objects/pack/ && git repack -A -d -l && git prune-packed && @@ -134,8 +133,8 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' ' --unpack-unreachable packlist && + ! grep "^$coid " packlist && echo >.git/objects/info/alternates && test_must_fail git show $coid ' @@ -151,8 +150,8 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar --unpack-unreachable packlist && + ! grep "^$coid " && echo >.git/objects/info/alternates && test_must_fail git show $coid '