From patchwork Tue Jan 7 04:52:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320363 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 99F7E1871 for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EE642075A for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MxuOkYkO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727549AbgAGEx3 (ORCPT ); Mon, 6 Jan 2020 23:53:29 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:34810 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727524AbgAGEx2 (ORCPT ); Mon, 6 Jan 2020 23:53:28 -0500 Received: by mail-qk1-f194.google.com with SMTP id j9so42012390qkk.1 for ; Mon, 06 Jan 2020 20:53:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aKyjgKssg7R/2ksPBvTIV7gBrzFlvGG0s959AGd855Y=; b=MxuOkYkOJ0UOxiCHcfq/C9RtY6lG9QOeZ+76nqjcamyMUo+YQ14Te2xFygfUEUfWeO 16ECPPPqeDDi0hV2oJ7iFbmH3+k1IftCkiX0b2NhbLmTo9nHW8DN8Opk75+vRdWOs8aX MJAsygTuszmuVUAVa5cFY7rpy1t5tacPJeZPXxr6Ay3XjZ6rew7i1D04ANEz7CY/VRFA zRGNDGJr1Tvmvmde0XO47NLqgbxoTRoDPLzbwCmp3+Q6lLC0gBZPgEPa0AVd/xSscAOY tsd/paVQxTlQeFTYh1WfGhl9ecbmMwhIOuJk5Wy5QincARmzEj61FMfnCoEvT4enXi5a JESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aKyjgKssg7R/2ksPBvTIV7gBrzFlvGG0s959AGd855Y=; b=FMpnZLIaA0EMRC3NXxWg4w748zlHNNIHULvN0oMip/tWMPrdOrU4XVUe1LTtejTo+u 3zCwZ53tf+pYS654HArGFzHMRDa9T/fVrFcbI/Y49WYRgYwFxlQzrhG2cipUc+6l36Hz tI00sSRqTQdH1uR052JqKygzuBAFoDYl53b4YfdvnJiOMoBu7CcAHMvVHBPEEy2P5WNr W5AselqswbXFNvc1ak8Koc2hCul/TsuNXWwnWIch8+vG8wg1ibT0BmAx9g+VDGXABh+8 qXGZ1IX+hzP2JnUS9C4gQOfOf8BHJ12mq8LJ9losOxu8tSX5gMd9EwqvIDL/hfijrDgm M72A== X-Gm-Message-State: APjAAAU4+A2re7VmTXiIu2gmD3FsMbsOJ+GidAJ4nfRgNjMFl9eglwDW nRx2rRsK2sLRicPFhUTk5TbGcIEd X-Google-Smtp-Source: APXvYqwRMV5dh58GryNvs58mKa5O9dV4UhhpxSYcSI9fbQ7d40z5/gJxzoTjsMubCX8oUfoDyIERiQ== X-Received: by 2002:a37:684b:: with SMTP id d72mr87724849qkc.293.1578372807539; Mon, 06 Jan 2020 20:53:27 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:26 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 01/16] t2018: remove trailing space from test description Date: Mon, 6 Jan 2020 23:52:58 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 822381dd9d..e18abce3d2 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='checkout ' +test_description='checkout' . ./test-lib.sh From patchwork Tue Jan 7 04:52:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320365 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 C4CCF14B4 for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A369F2075A for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ten0aWBm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727564AbgAGExa (ORCPT ); Mon, 6 Jan 2020 23:53:30 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:39698 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727524AbgAGEx3 (ORCPT ); Mon, 6 Jan 2020 23:53:29 -0500 Received: by mail-qk1-f193.google.com with SMTP id c16so41601410qko.6 for ; Mon, 06 Jan 2020 20:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2TqR0WDW8Y+NBJDh6OoLq+hfofgn+oUtQjnL9CRszHo=; b=ten0aWBmcTXUlA2V/M51lrQGuizgczPLByCXiDDL0DZ8F3FgnagOJ20FktTkjf/t/G SQMA/OEI8sWI1vhWSg3YMXOh8v25NrGTNpHoG/3+xJ3wA0lIZdJ2oznWLDwbF/dy1zGG KhOeIwJzwzWvV2czCZm3IgmaS5QGYmnjmHFjq0hzDMkkxVEpGk94pxHYPG1fsal37o1P /tjZF77TJ68Xz9DVXU7fUfd8PvHYaGj23FvapBEG3YALREqeGs/z6qT8S888/rE2lHiZ Ghan//57RVApF2BBbgsnyy263d4LGn/FEROmC+jWDlVxzi1/v5fYhsJ2EXdLqglu+iIu CYLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2TqR0WDW8Y+NBJDh6OoLq+hfofgn+oUtQjnL9CRszHo=; b=HmhkHigPfqFnJUf92nmTfq9t5xclFL8GlMeA0gdo0jtuAn2QMHYK01GOMhS+qmfYPH m1RiYsEh58tDGHGC2GyWTJeVGNMSNskq70Tr9iFEg2xaEQprpYXFlqMykNaCINYnfJSo DOj+7UqAQ071Vy5yNd1agja3Uxpnhs1alnAH5en0/+O1Z9jVZclSSjUQPvZj7F/8R6tF fg0rkUk7zFDS/3G2b18tHd26kBnVD3ws//q6KJDf86uc+wJ6yEJGMkyLtp9u7f025nir KPWbzaHbaEng15NUVCI0NwK+1aeIOTtbKqeykAtrMSzm+VNsB6PtriCk0M0cNUezcCLO JvAQ== X-Gm-Message-State: APjAAAXgXiqa6Pos2s3yhRpj+76UBXhwCtKijcPPsu6pEgCqssB8RqGS bC1JC2e7lCg6YaDxyeFB5V36rgDe X-Google-Smtp-Source: APXvYqwA5hyCDEHvTWWwAK2qpSLmE7wAR7ER26hS78khhC+0Mh1bexM4nFP9+T9cCmrct7HVrdNa0g== X-Received: by 2002:a05:620a:910:: with SMTP id v16mr86670545qkv.194.1578372808616; Mon, 06 Jan 2020 20:53:28 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:28 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 02/16] t2018: add space between function name and () Date: Mon, 6 Jan 2020 23:52:59 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a space between the function name and () which brings the style in line with Git's coding guidelines. Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index e18abce3d2..79b16e4677 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -12,7 +12,7 @@ test_description='checkout' # 2) HEAD is ; if is not specified, the old HEAD is used. # # If is not specified, "git checkout" is run with -b. -do_checkout() { +do_checkout () { exp_branch=$1 && exp_ref="refs/heads/$exp_branch" && @@ -32,19 +32,19 @@ do_checkout() { test $exp_sha = $(git rev-parse --verify HEAD) } -test_dirty_unmergeable() { +test_dirty_unmergeable () { ! git diff --exit-code >/dev/null } -setup_dirty_unmergeable() { +setup_dirty_unmergeable () { echo >>file1 change2 } -test_dirty_mergeable() { +test_dirty_mergeable () { ! git diff --cached --exit-code >/dev/null } -setup_dirty_mergeable() { +setup_dirty_mergeable () { echo >file2 file2 && git add file2 } From patchwork Tue Jan 7 04:53:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320367 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 EFD8A6C1 for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE2A12075A for ; Tue, 7 Jan 2020 04:53:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qqIP5+3+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727581AbgAGExc (ORCPT ); Mon, 6 Jan 2020 23:53:32 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:33755 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbgAGExa (ORCPT ); Mon, 6 Jan 2020 23:53:30 -0500 Received: by mail-qk1-f193.google.com with SMTP id d71so33768446qkc.0 for ; Mon, 06 Jan 2020 20:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1aXnx/J08W6X6FOk0xhH/K3eXu/5ICJHXtqwWyZqQ9o=; b=qqIP5+3+clzKe3UcQp1QhZEEZ7NmtK8xMf3VyPRnbOxacVRsIllCN+i1hbPPtfEv7H A/28IjrNxwBNmTngoDtJM1Zy9/D46Y7poSFrSi1gDRslTEB80cLAOE+92XGReZnYaUXK 3ZwcM5AjNCLuQ6I8FZPcptK3DikyxOov0qwiPj4IRhCYmqHF7BlZveAcFkrXUngVpird n0cW/0fpG+OxTI/eTvB073uq5HMnvTfcOBsXzLQNZDx+gFk/QeMUXndpSTZ8o0YId+9S 1J/sC7hUukd5RT8CrtQ6XcyBJrwQDG1akQanGkOocATwpvyWlIKIYMsgDyCTIA46OlZv mCVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1aXnx/J08W6X6FOk0xhH/K3eXu/5ICJHXtqwWyZqQ9o=; b=Mzly3JQ6AaHJUY4EgkKo/cbWv07S2ffgFVFljMNgo5SOxKOIcuqU9f5Db43wqkfKQd p0LjNwZUxhAjRh7LsGfsxvGyFVfjY/gie11aRjUI1rRCreBdst/WQjmnVs8R9myN8a6/ b/a2ytFocmr171wgUNErRxLlBVjDbzmWqIk+bbmXAKchcKfDpooCVon3xhYEnQ8zf1JM u/oG36l5/8T7MyAw1h5i76DzhrbzlPXZUch2PgxzrnwYrGTGC0ZZWG1dnH6Acf/jWgf0 NQj/lyUsYvonUs9+1030bA10knVHEqfJwEf4eThdYsvWHqmNYjnVAUhTqahH/2JSUXuh qYqQ== X-Gm-Message-State: APjAAAUZKlRiiOtcbW24gaoBKsPPJIp+GxDxs/VhqU9nh6LrfAYQMVBx K95g6Bkeh26bUVuiW2G0xSBLe++3 X-Google-Smtp-Source: APXvYqyos6KrVRq9NBeAiR4N7CKAjUsrgHJ7HEqvnWkTm2m9WTmPWextoi/ZwGyj0DtuTS18gMoV/A== X-Received: by 2002:a37:a642:: with SMTP id p63mr79270444qke.85.1578372809426; Mon, 06 Jan 2020 20:53:29 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:29 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 03/16] t2018: improve style of if-statement Date: Mon, 6 Jan 2020 23:53:00 -0500 Message-Id: <501eb147c3442b781b6b50be0691f326dc82f91a.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert `[]` to `test` and break if-then into separate lines, both of which bring the style in line with Git's coding guidelines. Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 79b16e4677..61206a90fb 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -20,7 +20,8 @@ do_checkout () { exp_sha=${2:-$(git rev-parse --verify HEAD)} && # default options for git checkout: -b - if [ -z "$3" ]; then + if test -z "$3" + then opts="-b" else opts="$3" From patchwork Tue Jan 7 04:53:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320371 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 656751953 for ; Tue, 7 Jan 2020 04:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A19D2075A for ; Tue, 7 Jan 2020 04:53:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fdCvLPfM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727578AbgAGExc (ORCPT ); Mon, 6 Jan 2020 23:53:32 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37243 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727524AbgAGExb (ORCPT ); Mon, 6 Jan 2020 23:53:31 -0500 Received: by mail-qk1-f194.google.com with SMTP id 21so41654790qky.4 for ; Mon, 06 Jan 2020 20:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2zJrhx+fGQLR0+YAKZccgX4U7vobwc6JXBDzo8umP/E=; b=fdCvLPfM98QszPkvSYWI52AhBE60cBlgDFiBa85lGDUFRtzJwpAOvDxF/cZ8i9Q2ox fnItllHDxNCxWruO3vmVlyVDLL12jY/UZNmq8rfk7myBgdhaw2Y+rHpU/O7bOaPJlFjU PTu0lZTOuxwwwB5rtovGe2Pm29Pig48ELe8dlx1rwYR1fbJspVF944G39lgpzoot/qk6 BN/2FQZKn3erXmKEl1mr+HBnPUHNiUynarJSoaRzg9OM+45pTnvUejoXAoKu6geWJavQ w8tj644yChfKhmznYdLV7rZCcvKE4adZ5Uz3It0JQEr7I1VbcjuQ0YySdHAkAie5rlko AlJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2zJrhx+fGQLR0+YAKZccgX4U7vobwc6JXBDzo8umP/E=; b=sKuOnF5Jxw0EBJP5Em03W7JtJmpHeEIcXPx0mAnzFlHj3E/n10PQ//AdNdODJve878 79Y8ZjPVt37X9nUERBXCFGdBBKOVW7+J45d1CIQkfeg3tVc+gBK6MMV+Pi8S46zl+ohx dmFR4//W2lFwG7zTrTzu9z4S+JXLDUntgpn1wOYK8GO3NsVwd+JwOtevZPra1E3DhtVg seXpddbjmb2BbAiVxSmZRND4LCOIu41X3FDnDLMQN94LzU7eQa5vF2jO93FIiuuuI5e5 SLf6AlAFWj33qK/CDEpmU5ZgCGfX3w+hGGkwnCE9fXHz4b2j+oT5EqNbgBf52qeuPcar +24w== X-Gm-Message-State: APjAAAWBFsWjbNe7+rbIGw2rmTM/WupxGopFf8kogge4mNffLb2RGsCi +L48RZndKyROxNG4nZ+o1axDoYmI X-Google-Smtp-Source: APXvYqycZvbNGYmRbMdaUFyQxJ54QPsdHk9cotu+A966av7EXIDgn1cTj2XJXYQpsKYTRoV4Q1OtVQ== X-Received: by 2002:a05:620a:136e:: with SMTP id d14mr78849335qkl.263.1578372810296; Mon, 06 Jan 2020 20:53:30 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:29 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 04/16] t2018: use test_expect_code for failing git commands Date: Mon, 6 Jan 2020 23:53:01 -0500 Message-Id: <587e53053f02ad0867dc903688c8887602950bd3.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When we are expecting `git diff` to fail, we negate its status with `!`. However, if git ever exits unexpectedly, say due to a segfault, we would not be able to tell the difference between that and a controlled failure. Use `test_expect_code 1 git diff` instead so that if an unexpected failure occurs, we can catch it. We have some instances of `test_must_fail test_dirty_{un,}mergable`. However, `test_must_fail` should only be used on git commands. Convert these instances to use the `test_dirty_{un,}mergeable_discards_changes` helper functions so that we remove the double-negation. While we're at it, remove redirections to /dev/null since output is silenced when running without `-v` anyway. Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 61206a90fb..7ca55efc6b 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -34,7 +34,11 @@ do_checkout () { } test_dirty_unmergeable () { - ! git diff --exit-code >/dev/null + test_expect_code 1 git diff --exit-code +} + +test_dirty_unmergeable_discards_changes () { + git diff --exit-code } setup_dirty_unmergeable () { @@ -42,7 +46,11 @@ setup_dirty_unmergeable () { } test_dirty_mergeable () { - ! git diff --cached --exit-code >/dev/null + test_expect_code 1 git diff --cached --exit-code +} + +test_dirty_mergeable_discards_changes () { + git diff --cached --exit-code } setup_dirty_mergeable () { @@ -94,7 +102,7 @@ test_expect_success 'checkout -f -b to a new branch with unmergeable changes dis # still dirty and on branch1 do_checkout branch2 $HEAD1 "-f -b" && - test_must_fail test_dirty_unmergeable + test_dirty_unmergeable_discards_changes ' test_expect_success 'checkout -b to a new branch preserves mergeable changes' ' @@ -112,7 +120,7 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca test_when_finished git reset --hard HEAD && setup_dirty_mergeable && do_checkout branch2 $HEAD1 "-f -b" && - test_must_fail test_dirty_mergeable + test_dirty_mergeable_discards_changes ' test_expect_success 'checkout -b to an existing branch fails' ' @@ -163,7 +171,7 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes test_expect_success 'checkout -f -B to an existing branch with unmergeable changes discards changes' ' # still dirty and on branch1 do_checkout branch2 $HEAD1 "-f -B" && - test_must_fail test_dirty_unmergeable + test_dirty_unmergeable_discards_changes ' test_expect_success 'checkout -B to an existing branch preserves mergeable changes' ' @@ -180,7 +188,7 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes setup_dirty_mergeable && do_checkout branch2 $HEAD1 "-f -B" && - test_must_fail test_dirty_mergeable + test_dirty_mergeable_discards_changes ' test_expect_success 'checkout -b ' ' From patchwork Tue Jan 7 04:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320369 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 303D718B8 for ; Tue, 7 Jan 2020 04:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 054502075A for ; Tue, 7 Jan 2020 04:53:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FfO+g62x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbgAGExd (ORCPT ); Mon, 6 Jan 2020 23:53:33 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:36659 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbgAGExc (ORCPT ); Mon, 6 Jan 2020 23:53:32 -0500 Received: by mail-qk1-f196.google.com with SMTP id a203so41965521qkc.3 for ; Mon, 06 Jan 2020 20:53:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5BH/BhIcjwj3b4Zj09JzrLz89x8UD3qVZ5zGxOg67Xw=; b=FfO+g62xJqcLxCMbjA9zJvLCNDaNCFUT0Cb/FDxyY3AekI4RSTqlMEy8v14IOj1f/m J4jIyHrAUiTxbHexJchaP8jNd50fym4jb+N5BZRZ4ADtts68vzNOewMrtFL3/baZPPo8 +0P54xpd2tJ1PFW5KcOw5hosHzqaLh5D85bBjpnBCGUd+VjqHs8dgCEJrDn9a/PyDyFD LsMU4H9DoNZZeUnP7Mj9RHt5SylqdnjhD9wDx038wtXFj3py778rZ84zUPXfxmMySARL 33E2fkwOlK4wzCPIciSCI/qLlhz7rS6mof08tW+gNIzxmpIheQCBDyZn+JETQoPvcAI9 JsKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5BH/BhIcjwj3b4Zj09JzrLz89x8UD3qVZ5zGxOg67Xw=; b=R4Bv5zDsrFMnR8A1KxrApfX9DUZSzBFuZgjfoqoNLAqpmW7ZkXRtpn/YcxbxIrwDXv S6elb7cmA4EYfI3wJiffDLE9tvNJSZ4SDxd+sKI4OxNtt9CTeNM4nNIlFo9nuZytRfXE KaN2Pbxng54fQ0eH0IbPfBDxaHNAhw9qF2UovzsLveOxf0W1j9icbeT69FgV0HY1+bLJ wKvFaW8umt0KUxMkyoNL+m+8tJjeXG/MQd9Nbzbbft3wCO0HsgdieQ84trVn6v1TkmGy XjAIIMRXRwDLV3qqo2VGAxRvCo/LL8qlZVXAr9zvMhaSSVHRpzfn4aQe7r6Gwo78EJeO W++A== X-Gm-Message-State: APjAAAUtG681C6iVDreOlnsh+bdbQadRtGKSBqSD0OD/C8A9fkP+id+X Gy2+KFjDOiBPIWXk2u+B2RSs1997 X-Google-Smtp-Source: APXvYqxj2nwbL1GLEyf7j5vNKVJureKsh50aOptvZON1obCVO15qHSEYHRSDBxx88WSonQZkL/oZxw== X-Received: by 2002:a05:620a:142c:: with SMTP id k12mr86953799qkj.207.1578372811249; Mon, 06 Jan 2020 20:53:31 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:30 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 05/16] t2018: teach do_checkout() to accept `!` arg Date: Mon, 6 Jan 2020 23:53:02 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We are running `test_must_fail do_checkout`. However, `test_must_fail` should only be used on git commands. Teach do_checkout() to accept `!` as a potential first argument which will cause the function to expect the "git checkout" to fail. This increases the granularity of the test as, instead of blindly checking that do_checkout() failed, we check that only the specific expected invocation of git fails. Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 7ca55efc6b..687ab6713c 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -4,7 +4,7 @@ test_description='checkout' . ./test-lib.sh -# Arguments: [] +# Arguments: [!] [] # # Runs "git checkout" to switch to , testing that # @@ -12,7 +12,16 @@ test_description='checkout' # 2) HEAD is ; if is not specified, the old HEAD is used. # # If is not specified, "git checkout" is run with -b. +# +# If the first argument is `!`, "git checkout" is expected to fail when +# it is run. do_checkout () { + should_fail= && + if test "x$1" = "x!" + then + should_fail=yes && + shift + fi && exp_branch=$1 && exp_ref="refs/heads/$exp_branch" && @@ -27,10 +36,14 @@ do_checkout () { opts="$3" fi - git checkout $opts $exp_branch $exp_sha && - - test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && - test $exp_sha = $(git rev-parse --verify HEAD) + if test -n "$should_fail" + then + test_must_fail git checkout $opts $exp_branch $exp_sha + else + git checkout $opts $exp_branch $exp_sha && + test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && + test $exp_sha = $(git rev-parse --verify HEAD) + fi } test_dirty_unmergeable () { @@ -91,7 +104,7 @@ test_expect_success 'checkout -b to a new branch, set to an explicit ref' ' test_expect_success 'checkout -b to a new branch with unmergeable changes fails' ' setup_dirty_unmergeable && - test_must_fail do_checkout branch2 $HEAD1 && + do_checkout ! branch2 $HEAD1 && test_dirty_unmergeable ' @@ -125,7 +138,7 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca test_expect_success 'checkout -b to an existing branch fails' ' test_when_finished git reset --hard HEAD && - test_must_fail do_checkout branch2 $HEAD2 + do_checkout ! branch2 $HEAD2 ' test_expect_success 'checkout -b to @{-1} fails with the right branch name' ' @@ -164,7 +177,7 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes git checkout branch1 && setup_dirty_unmergeable && - test_must_fail do_checkout branch2 $HEAD1 -B && + do_checkout ! branch2 $HEAD1 -B && test_dirty_unmergeable ' From patchwork Tue Jan 7 04:53:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320377 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 004C66C1 for ; Tue, 7 Jan 2020 04:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D33F12075A for ; Tue, 7 Jan 2020 04:53:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HnDOwVVq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727604AbgAGExh (ORCPT ); Mon, 6 Jan 2020 23:53:37 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:39703 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727582AbgAGExd (ORCPT ); Mon, 6 Jan 2020 23:53:33 -0500 Received: by mail-qk1-f196.google.com with SMTP id c16so41601475qko.6 for ; Mon, 06 Jan 2020 20:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G1PpaJmx0aLNyY962YW2ZoEbKD5ybsIavN1/eoSLdJU=; b=HnDOwVVqYjpi4RdZSou5bI+uvFWtnbo2CplmkXKlaKNLvpSrMyjfFZM9JNmw8bbxMj e0uRWtZwH58yS9WP5L746pT02X9jkaVEz89a7Q5eigaddKgRbYvEDJm/rVFWiWYwRgjQ Tfo56lqAgpDvY9iGFFkXYaEm8PguXMwwif78j9M9eYsjZJXJ3dP1pgu0h/q8Zkrr0hsI pn83uLNg3bddqGs+OnRBKAVkOxqCOJ+nG7/SCQd0jKRl+IMXy3pD7a5k+MDk/8Zv7IcO Ksf7sCAEt3MEAPtUr5mITODMB/0bTjvAAUBnIEIYcDZz3842CJzi1w3rmkbmOAHQzITf /W+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G1PpaJmx0aLNyY962YW2ZoEbKD5ybsIavN1/eoSLdJU=; b=PgDKIX7gP2aQ4jvAd1mIJhULmHxIBbXrhC+g7W/0rIXL6gVAiYitTjG54ReOSPFFxx YVIsYLLw5Bs9U6pR15tiYITZHlL1t/jPzoSqVOrAGVaJ5Rp2zEltc5rR0YuNRKsE/BT6 I/S0UAZfckQYA+E9QW4ifRCSXoLYxTu2i8PiZW2cCvKSFUO8jlmTtNmwDZ60qPoPtLMC Y1zBS/6b+MoB+Bi7EBXwfCa9lZKy/UMZivuDaaet7/kA/1m/nPBNGJu0KQbt7bT1RqLJ ue5aKLN7hYSUf3g8xE7AC/v0vISo91a8t5XmcLX8iwLyKPmYPp2Vk6GYiJCJNiRRRFgs U2Yg== X-Gm-Message-State: APjAAAX3wagixrtVjfhndcuXRvMgAKyJGpvwAYD2Fl/k+RGBBUJ5xbUL r3TE23vn/HpNVssr8Awx4G/3o7v2 X-Google-Smtp-Source: APXvYqzTGAiFPyBprVGne3G7XOk6oTEO9flvZUQ9QFqKJj7SGL62ldMu7lwHLBBuwRrT0wTsGsoefw== X-Received: by 2002:a05:620a:9c9:: with SMTP id y9mr52220064qky.397.1578372812392; Mon, 06 Jan 2020 20:53:32 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:31 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 06/16] t2018: don't lose return code of git commands Date: Mon, 6 Jan 2020 23:53:03 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix invocations of git commands so their exit codes are not lost within non-assignment command substitutions. Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index 687ab6713c..caf43571b1 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -41,8 +41,12 @@ do_checkout () { test_must_fail git checkout $opts $exp_branch $exp_sha else git checkout $opts $exp_branch $exp_sha && - test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) && - test $exp_sha = $(git rev-parse --verify HEAD) + echo "$exp_ref" >ref.expect && + git rev-parse --symbolic-full-name HEAD >ref.actual && + test_cmp ref.expect ref.actual && + echo "$exp_sha" >sha.expect && + git rev-parse --verify HEAD >sha.actual && + test_cmp sha.expect sha.actual fi } @@ -162,7 +166,8 @@ test_expect_success 'checkout -B to a merge base' ' ' test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' ' - git checkout $(git rev-parse --verify HEAD) && + head=$(git rev-parse --verify HEAD) && + git checkout "$head" && do_checkout branch2 "" -B ' From patchwork Tue Jan 7 04:53:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320375 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 C98B714B4 for ; Tue, 7 Jan 2020 04:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A848C207E0 for ; Tue, 7 Jan 2020 04:53:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QNA8aPtc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727598AbgAGExf (ORCPT ); Mon, 6 Jan 2020 23:53:35 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:43483 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbgAGExe (ORCPT ); Mon, 6 Jan 2020 23:53:34 -0500 Received: by mail-qk1-f193.google.com with SMTP id t129so41604816qke.10 for ; Mon, 06 Jan 2020 20:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Td/HO+1GEy+nHul/PamMoe9ZN3pML0c3MFJoApdqXgA=; b=QNA8aPtcNOqPR2Ej1Iewv8vvvFNVS2dRui6o6eBBaB3Le28I8BgmTr9ln2NTyXtbza a/3ASaOnKehgCaKG6iY7gbs4M67uKGI1hnu0oxwUgENLS00QfGhdO83XnheY1LnDCMuC +DZ3GGHQ77n6wUcKNBEvDwPup7TvNfpJB6S3GbSUNg+p9HwyuQeLu/Zf+n+RdIzpAJyo dPt0aLvReIN4FqdsneXmbsgR/yW6mJzcZHDNH+eJ46Dbjjleld80J0Aq7PeWeUA/Apd4 Y1LgpESqIPg65qVlyvngLVOyP/fMYQ5O7mggvaoLxO0YxtciRknCrOMJxcIi1OwuJqTI xYOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Td/HO+1GEy+nHul/PamMoe9ZN3pML0c3MFJoApdqXgA=; b=ioGfpUMOL3YDa0FEKNDkyl48Wrmx/nu+cfSlAN6y6urOTk/5S65FVVbVq0fWTemzxZ h/QuXKQG7nlKKACiVFZgTzLheKCYWfRcvVbRK6FJQTUDoK05r9zmXl7RSKZN+5h0Eo9I npIZ4p08bLzdC+ylXXg8QuAOMNG9BRVv3X+3ezU8IfI1FOTgRktIaAg5xDVfDheW46iD ArkGM/2GaaLmf1cLAWgVaR+C1EGei6/2oa4EADnV9+JXTxQqK9Gdk+KOXdVUG++7PFHP 66QmYrfkzms0HvIG7qRsDoiD6893PQzvQ1fUHu/k1/eRXuc0KYcEjWftnJHcpyWSgL8/ MMiQ== X-Gm-Message-State: APjAAAVO5hLbwh4kRRF1pZeZB1zlV4KkBeFiZ1UKACv1RqJfgz8Gcw69 S3aXr1LGAZ91mHFxeIW5hFDYgWf6 X-Google-Smtp-Source: APXvYqxzw5qJQ6siVhQ/hwjo5EGywaVsoJ2/1BzzwNr5UdC9GwlK3cKmMnPL2hkf4462DXcsZxzNxw== X-Received: by 2002:a37:c449:: with SMTP id h9mr83322897qkm.124.1578372813248; Mon, 06 Jan 2020 20:53:33 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:32 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 07/16] t2018: replace "sha" with "oid" Date: Mon, 6 Jan 2020 23:53:04 -0500 Message-Id: <71f84811c73174f3e8f85ca173dc65b37b698ad2.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org As part of the effort to become more hash-agnostic, replace all instances of "sha" with "oid". Signed-off-by: Denton Liu --- t/t2018-checkout-branch.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh index caf43571b1..bbca7ef8da 100755 --- a/t/t2018-checkout-branch.sh +++ b/t/t2018-checkout-branch.sh @@ -4,12 +4,12 @@ test_description='checkout' . ./test-lib.sh -# Arguments: [!] [] +# Arguments: [!] [] # # Runs "git checkout" to switch to , testing that # # 1) we are on the specified branch, ; -# 2) HEAD is ; if is not specified, the old HEAD is used. +# 2) HEAD is ; if is not specified, the old HEAD is used. # # If is not specified, "git checkout" is run with -b. # @@ -25,8 +25,8 @@ do_checkout () { exp_branch=$1 && exp_ref="refs/heads/$exp_branch" && - # if is not specified, use HEAD. - exp_sha=${2:-$(git rev-parse --verify HEAD)} && + # if is not specified, use HEAD. + exp_oid=${2:-$(git rev-parse --verify HEAD)} && # default options for git checkout: -b if test -z "$3" @@ -38,15 +38,15 @@ do_checkout () { if test -n "$should_fail" then - test_must_fail git checkout $opts $exp_branch $exp_sha + test_must_fail git checkout $opts $exp_branch $exp_oid else - git checkout $opts $exp_branch $exp_sha && + git checkout $opts $exp_branch $exp_oid && echo "$exp_ref" >ref.expect && git rev-parse --symbolic-full-name HEAD >ref.actual && test_cmp ref.expect ref.actual && - echo "$exp_sha" >sha.expect && - git rev-parse --verify HEAD >sha.actual && - test_cmp sha.expect sha.actual + echo "$exp_oid" >oid.expect && + git rev-parse --verify HEAD >oid.actual && + test_cmp oid.expect oid.actual fi } From patchwork Tue Jan 7 04:53:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320393 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 01F3D14BD for ; Tue, 7 Jan 2020 04:53:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5196207FD for ; Tue, 7 Jan 2020 04:53:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d8/2yFxa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727607AbgAGExi (ORCPT ); Mon, 6 Jan 2020 23:53:38 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:45942 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727593AbgAGExf (ORCPT ); Mon, 6 Jan 2020 23:53:35 -0500 Received: by mail-qk1-f194.google.com with SMTP id x1so41566916qkl.12 for ; Mon, 06 Jan 2020 20:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y5XsKrkMwUUFBH1wMuXh1KUK9uMITCm65kS4SjYFPEM=; b=d8/2yFxa6GlY+vpHgvHQz/whfKslA5VE1Zs235omyGTQH8Swij9oCumsjuIX8S3NZP 2r762a5K6uBmtY89XP4geFQq0b6qcnklBQZoccPaTCj6hJGhXMq5BmuAKsXHgYEi+8zs n0IlNxiG82SYsh3KVG63qYwoPWng2UrOIkVB8gT01gDmTu6Oi7gz513HTt3bK49l2pax QLOuSd/WA2PSKRpso7FFjqakqS16Sp3ULXFcjMKWCip/Rw5pfF6lA6AKnEzXdf1X29xn tX32Jwz5H7pl2JQ/q9+3JJgxXFsAV+8p7G/EFQyb0z4+6G71NO5+++AHHkL2Fe1/8gVs 1Yeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y5XsKrkMwUUFBH1wMuXh1KUK9uMITCm65kS4SjYFPEM=; b=B2xp25M1CfV0hbCZDnsRCl5vBuasNzngMFQF3cd84zf6AmaVQSiAuuO4Kn4MLahkcd YYKJ6YfQazKLC3R7i3iU1qit8CFQasCmQo6mZRwk2BiWX+Kag+VKYLA/mKH3VZY5mx1N xqIP4oym2fCx1GD9ZQapYLiAJy5j+5B8QjAswOJszP851Kw+nUITMozQcJKyouKqlJQ8 mgQ3OWAEMZrT6PXCeJtscSnhKTLRihUNpyrSWGmf6KuT+dfKfjLlzYxSqrSs1dwxZRe2 6DWLiQapMRF8AK5MABKGQKzMGaP1A6Yf0sgh3kv2lo+u7HTfmxDggbeFQq0BoEfZthC7 CC0w== X-Gm-Message-State: APjAAAWwXsiENAVap05jGNTfCI9orOg3MXOJ04Si3Q/+WqbqIX8at+5S gnub7F/3i2vdJv57iq8ELk5nHlrn X-Google-Smtp-Source: APXvYqzGr4fR986WmxfH3W5EiXxHf70ONq3zV+Fnn1rKIx4//uO5mFdCOd4Tsct6uEouoh7AifG1XA== X-Received: by 2002:a37:ba03:: with SMTP id k3mr83941897qkf.127.1578372814246; Mon, 06 Jan 2020 20:53:34 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:33 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 08/16] t3030: use test_path_is_missing() Date: Mon, 6 Jan 2020 23:53:05 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We use `test_must_fail test -d` to ensure that the directory is removed. However, test_must_fail() should only be used for git commands. Use test_path_is_missing() instead to check that the directory has been removed. Signed-off-by: Denton Liu --- t/t3030-merge-recursive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh index 2170758e38..d48d211a95 100755 --- a/t/t3030-merge-recursive.sh +++ b/t/t3030-merge-recursive.sh @@ -604,7 +604,7 @@ test_expect_success 'merge removes empty directories' ' git commit -mremoved-d/e && git checkout master && git merge -s recursive rm && - test_must_fail test -d d + test_path_is_missing d ' test_expect_success 'merge-recursive simple w/submodule' ' From patchwork Tue Jan 7 04:53:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320379 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 34A291871 for ; Tue, 7 Jan 2020 04:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 09DBE2075A for ; Tue, 7 Jan 2020 04:53:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FjCxVfH8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727611AbgAGExi (ORCPT ); Mon, 6 Jan 2020 23:53:38 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44266 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727550AbgAGExg (ORCPT ); Mon, 6 Jan 2020 23:53:36 -0500 Received: by mail-qk1-f195.google.com with SMTP id w127so41589691qkb.11 for ; Mon, 06 Jan 2020 20:53:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PZRvR2Y+JQoX3lzFkTjwKScWJiTweTmkNbDFZYlPaFI=; b=FjCxVfH8DrcoZJa521d3nhrdkJj41HODQaXKKsfIULV6JarzxJv+1Ch5xA4xIZP9x0 mH9mMjwF/0+zSOV0YCIeNkN2wFA4Fb0VJtD5hWO14x/EuYVeVPZHaGF7t69RnKbjnnhq CzYzVfLWKU2VRHKoUocBJT8hp/jd3Fm63KgvHUDXkAL2p6xXkdHspSHqNciJ4P9vNJhZ yJA++IYLLAaaDVZk4YPnUO1wD7UIMHSWDXC/XWjYp2pkdGyxmkqLz4JHbzxMiuahQpYV T4UZmU/9eAdZOzJxBBJHDC4B6gvpv9KJzT1hlU9+SkkaPtQ+OrPt9pdxDY6lVtKhoj2p eGAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PZRvR2Y+JQoX3lzFkTjwKScWJiTweTmkNbDFZYlPaFI=; b=WphnOqO5BiVPQK5F12sxGGmuHLeS/3Suanff0NTAw37RZQyhWHMhTiZWie6kVO/+nF ob3yABuSKjHa6+mWa5HHLgF18391vuSPlYxt3MapxVn2JM9J7+4aV0BFrMnVc71CiUOV Tt0YsQeqTZSx+cRMfxclpCGCqjVk10dw03wiqzeku4sXCunQ76AbnwoDAgulUb1lbHDE F4dBrclCnP2Qkb8k2OMTR23P+EsKCLwPwSorJYRh4ijudDZb5Av8xtM0BURz4cm3U50W KwIJdquAKi1QPNAnQD4+M66j+uD5qQCsVgpRGRss9w4PA+6b6qbqixf1rjYBvQoUyGkS A1ow== X-Gm-Message-State: APjAAAUarkEPpeie8jTPzgQlevNi7COFf/VL8EJfmYI1U2YRJMtTrsjR IcbDgbRIv1VZOBoR3TqEQDeL5KkX X-Google-Smtp-Source: APXvYqynTGoT3xs16gaMYTjeaHDom7bej6woiBV5WdWq+LBaqrzgweg7ACnW0I+7dsnXyQREFdUN5g== X-Received: by 2002:a05:620a:20c7:: with SMTP id f7mr86513904qka.440.1578372815095; Mon, 06 Jan 2020 20:53:35 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:34 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 09/16] t3310: extract common notes_merge_files_gone() Date: Mon, 6 Jan 2020 23:53:06 -0500 Message-Id: <46fe82b856d217265b01bf2bcf1ff78fa9474fc3.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have many statements which are duplicated. Extract and replace these duplicate statements with notes_merge_files_gone(). While we're at it, replace the test_might_fail(), which should only be used on git commands. Also, remove the redirection from stderr to /dev/null. This is because the test scripts automatically suppress output already. Otherwise, if a developer asks for verbose output via the `-v` flag, the stderr output may be useful for debugging. Signed-off-by: Denton Liu --- t/t3310-notes-merge-manual-resolve.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh index 2dea846e25..d746f4ba55 100755 --- a/t/t3310-notes-merge-manual-resolve.sh +++ b/t/t3310-notes-merge-manual-resolve.sh @@ -32,6 +32,12 @@ verify_notes () { test_cmp "expect_log_$notes_ref" "output_log_$notes_ref" } +notes_merge_files_gone () { + # No .git/NOTES_MERGE_* files left + { ls .git/NOTES_MERGE_* >output || :; } && + test_must_be_empty output +} + cat <expect_notes_x 6e8e3febca3c2bb896704335cc4d0c34cb2f8715 $commit_sha4 e5388c10860456ee60673025345fe2e153eb8cf8 $commit_sha3 @@ -335,9 +341,7 @@ EOF y and z notes on 4th commit EOF git notes merge --commit && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -397,9 +401,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol test_expect_success 'abort notes merge' ' git notes merge --abort && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # m has not moved (still == y) test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" && # Verify that other notes refs has not changed (w, x, y and z) @@ -464,9 +466,7 @@ EOF echo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 && # Finalize merge git notes merge --commit && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # Merge commit has pre-merge y and pre-merge z as parents test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" && test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" && @@ -553,9 +553,7 @@ EOF test_expect_success 'resolve situation by aborting the notes merge' ' git notes merge --abort && - # No .git/NOTES_MERGE_* files left - test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null && - test_must_be_empty output && + notes_merge_files_gone && # m has not moved (still == w) test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" && # Verify that other notes refs has not changed (w, x, y and z) From patchwork Tue Jan 7 04:53:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320381 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 5F6E914BD for ; Tue, 7 Jan 2020 04:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E1832075A for ; Tue, 7 Jan 2020 04:53:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YzIdWLXV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbgAGExj (ORCPT ); Mon, 6 Jan 2020 23:53:39 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38569 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727601AbgAGExh (ORCPT ); Mon, 6 Jan 2020 23:53:37 -0500 Received: by mail-qk1-f194.google.com with SMTP id k6so41621223qki.5 for ; Mon, 06 Jan 2020 20:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=58u2/7L7YkNqYjYqFJfE5sJpBL3Xh/U2MtboribzNkg=; b=YzIdWLXV8bRW/vLfC9JKWKMclVA21oX1OPFw//A4VyAoIlI22GsyndKfi3c5Ac07MG Ng02O7kYl2PC69hlZG7Wr1zEOsO06VvCRgrrUlT+Hh/NP7G7vo5bIhQ0Ns0XMHgX54SJ WjmdxoNU8HbIaVK/X02VO/FC2y3YxQWKgll9vaLE9MAgacZ9zJsBarYGfs2Z6hsipf4e 4aQ+ZD/nHlDKxk1SAQE8E6EGts7dL7Beb8ppPE1qYLr2oZlkFAX8VT62xjbMT9NduRM8 Cqyt9iYKudufFfpz8nwv8su7RETQ4Cw5wWavLPjgPR+T4Q80jC/17nfNhRqKghZkFDVl BwCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=58u2/7L7YkNqYjYqFJfE5sJpBL3Xh/U2MtboribzNkg=; b=bhqYC6RnfHUsfihW+7Q6VTihTCs1nqhzk4ScwJ5gY7MBDkCJW0yIc0dwDtsVVOvaK9 JGE2B2EXYXAg/UJvPPTrJEJrRFKAHOMFlPEk1ebMdD7ZERnkFYiOl1/648F7hccSZREm xzd/yLZOE71skJoNSkP859pAX54ZDLhg4akJE0LKj0DyO0GWP1AM15LSXFVjdBDa1Og3 6tc/hu64Uce1s8BltqbTOSFqJzHCo6foeRCURlsrZbR/o006feQb7nDEYv0ga9Hg6NEP W5BLuPABzNrKPBEkIg/wxlK58KKp3PMxvhAscLYrdV8SkjW046ThbvWMbcOfsHKmzrfl Zzow== X-Gm-Message-State: APjAAAURzb/n9esSFmq7+Hi7MbUUJLNCTZZQujpCMS6FKRPrUzQZNtUh TyipUA4CJ0jQomJgi9RtZKWY/6v4 X-Google-Smtp-Source: APXvYqzRNxiDmgaWPpiqkS3A25rlktXPTIQTq4wCtvN+whr99YfBWuu8euVv4WaLjzuLN31NImvu1w== X-Received: by 2002:a05:620a:150e:: with SMTP id i14mr84299666qkk.273.1578372816020; Mon, 06 Jan 2020 20:53:36 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:35 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 10/16] t3415: stop losing return codes of git commands Date: Mon, 6 Jan 2020 23:53:07 -0500 Message-Id: <32d2051b319449205b18048c800b906b675460f4.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix invocations of git commands so their exit codes are not lost within non-assignment command substitutions. Signed-off-by: Denton Liu --- t/t3415-rebase-autosquash.sh | 113 +++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 31 deletions(-) diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index 22d218698e..b0add36f82 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -37,8 +37,12 @@ test_auto_fixup () { git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code $1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 1 actual } test_expect_success 'auto fixup (option)' ' @@ -66,8 +70,12 @@ test_auto_squash () { git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code $1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 2 = $(git cat-file commit HEAD^ | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 2 actual } test_expect_success 'auto squash (option)' ' @@ -94,7 +102,8 @@ test_expect_success 'misspelled auto squash' ' git log --oneline >actual && test_line_count = 4 actual && git diff --exit-code final-missquash && - test 0 = $(git rev-list final-missquash...HEAD | wc -l) + git rev-list final-missquash...HEAD >list && + test_must_be_empty list ' test_expect_success 'auto squash that matches 2 commits' ' @@ -113,9 +122,15 @@ test_expect_success 'auto squash that matches 2 commits' ' git log --oneline >actual && test_line_count = 4 actual && git diff --exit-code final-multisquash && - test 1 = "$(git cat-file blob HEAD^^:file1)" && - test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) && - test 1 = $(git cat-file commit HEAD | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^^ >commit && + grep first commit >actual && + test_line_count = 2 actual && + git cat-file commit HEAD >commit && + grep first commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches a commit after the squash' ' @@ -134,25 +149,38 @@ test_expect_success 'auto squash that matches a commit after the squash' ' git log --oneline >actual && test_line_count = 5 actual && git diff --exit-code final-presquash && - test 0 = "$(git cat-file blob HEAD^^:file1)" && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD | grep third | wc -l) && - test 1 = $(git cat-file commit HEAD^ | grep third | wc -l) + echo 0 >expect && + git cat-file blob HEAD^^:file1 >actual && + test_cmp expect actual && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD >commit && + grep third commit >actual && + test_line_count = 1 actual && + git cat-file commit HEAD^ >commit && + grep third commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches a sha1' ' git reset --hard base && echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short HEAD^)" && + oid=$(git rev-parse --short HEAD^) && + git commit -m "squash! $oid" && git tag final-shasquash && test_tick && git rebase --autosquash -i HEAD^^^ && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-shasquash && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 1 actual ' test_expect_success 'auto squash that matches longer sha1' ' @@ -160,15 +188,20 @@ test_expect_success 'auto squash that matches longer sha1' ' echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short=11 HEAD^)" && + oid=$(git rev-parse --short=11 HEAD^) && + git commit -m "squash! $oid" && git tag final-longshasquash && test_tick && git rebase --autosquash -i HEAD^^^ && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-longshasquash && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 1 actual ' test_auto_commit_flags () { @@ -183,8 +216,12 @@ test_auto_commit_flags () { git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-commit-$1 && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test $2 = $(git cat-file commit HEAD^ | grep first | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = $2 actual } test_expect_success 'use commit --fixup' ' @@ -210,11 +247,15 @@ test_auto_fixup_fixup () { ( set_cat_todo_editor && test_must_fail git rebase --autosquash -i HEAD^^^^ >actual && + head=$(git rev-parse --short HEAD) && + parent1=$(git rev-parse --short HEAD^) && + parent2=$(git rev-parse --short HEAD^^) && + parent3=$(git rev-parse --short HEAD^^^) && cat >expected <<-EOF && - pick $(git rev-parse --short HEAD^^^) first commit - $1 $(git rev-parse --short HEAD^) $1! first - $1 $(git rev-parse --short HEAD) $1! $2! first - pick $(git rev-parse --short HEAD^^) second commit + pick $parent3 first commit + $1 $parent1 $1! first + $1 $head $1! $2! first + pick $parent2 second commit EOF test_cmp expected actual ) && @@ -222,13 +263,17 @@ test_auto_fixup_fixup () { git log --oneline >actual && test_line_count = 3 actual git diff --exit-code "final-$1-$2" && - test 2 = "$(git cat-file blob HEAD^:file1)" && + echo 2 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && if test "$1" = "fixup" then - test 1 = $(git cat-file commit HEAD^ | grep first | wc -l) + test_line_count = 1 actual elif test "$1" = "squash" then - test 3 = $(git cat-file commit HEAD^ | grep first | wc -l) + test_line_count = 3 actual else false fi @@ -256,19 +301,25 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' ' echo 2 >file1 && git add -u && test_tick && - git commit -m "squash! $(git rev-parse --short HEAD^)" && + oid=$(git rev-parse --short HEAD^) && + git commit -m "squash! $oid" && echo 1 >file1 && git add -u && test_tick && - git commit -m "squash! $(git log -n 1 --format=%s HEAD~2)" && + subject=$(git log -n 1 --format=%s HEAD~2) && + git commit -m "squash! $subject" && git tag final-squash-instFmt && test_tick && git rebase --autosquash -i HEAD~4 && git log --oneline >actual && test_line_count = 3 actual && git diff --exit-code final-squash-instFmt && - test 1 = "$(git cat-file blob HEAD^:file1)" && - test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l) + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep squash commit >actual && + test_line_count = 2 actual ' test_expect_success 'autosquash with empty custom instructionFormat' ' From patchwork Tue Jan 7 04:53:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320395 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 8DCCF6C1 for ; Tue, 7 Jan 2020 04:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CC15207FD for ; Tue, 7 Jan 2020 04:53:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PCWgeXIN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbgAGExt (ORCPT ); Mon, 6 Jan 2020 23:53:49 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:46088 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727605AbgAGExi (ORCPT ); Mon, 6 Jan 2020 23:53:38 -0500 Received: by mail-qk1-f193.google.com with SMTP id r14so41581629qke.13 for ; Mon, 06 Jan 2020 20:53:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T1VJMwScl7Uk2kNG44Oe0XCc3aJ6N+HOl+OvzYjuncU=; b=PCWgeXINZ6FNVSWOELEokb+E1h2jJvW6RpvNPwNzjMX5b0Ya4lIxbwH3JodjMF2ANI eYwlz2mGt4czvD4r+Ikm3ioxlgr6ea+swnlHlLGwgJFqHmFkAL5G64RqSiN/EIA1TwB4 IqyrCxOYfbMBqYwq44y1/f+QlGv8Gyrkbl+DxBhZWRBD5iqnM84OdylKNoXnpKrhhs98 bbDlQiybNZoS2w13bhPQ+0TjT6dER0V6gmJmNSctnYebOF7KjiyEkN9eHCp9pSPYOd1b Nie5yLzWf3olufsMOibkAn07mpsaJcs0IKknrE4vZptgXdQLqYd8Li0VPTcGoU0MZ9m7 igVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T1VJMwScl7Uk2kNG44Oe0XCc3aJ6N+HOl+OvzYjuncU=; b=I2IS02WUW1y170JD+hYJzJdpVsqTrr6d4/stJpzbLLcV1mHKqv0IyiulPVM9//jomH wtZb6Fs16Zc1GjzbIRIcUNaTxAgGbomZPvJ0p829uaIQSRuZzyBzCmj/xs9QgLwQAKm4 +T6ygQVWgN3p/ebVE3IRm+eXA+1muKz7Nbyo9lY6Cwk1fWfHkOlzp5p+WYdTUxK3qj9T 9PAsw8MEHt6O0bFxgtfxaxVDqLSbC+eg6x8smwtnzBhGbBbsjYGU28DLJI2p5tmUS8NJ tRby9BUGeCVRWGCvpdkYJ238ChXa+LuFMRF16SkgxFekIK/2ObjhI4N0bZg7c/qxuKIb aleQ== X-Gm-Message-State: APjAAAVKv+TNgpZxwAGCl+piH0FXY3HBtM4iioY/jf3nZH5UxXpgylbL KkCrhiLOZ+B64Z/XMk18Hat+MDlx X-Google-Smtp-Source: APXvYqw/7v+6RRhDzgpdXE9lAwzUt5dGE8upjIOuRhH3jWNXd/034rQneZkoukWBRqYTX/PFWBdMvg== X-Received: by 2002:a05:620a:1005:: with SMTP id z5mr85550853qkj.26.1578372817024; Mon, 06 Jan 2020 20:53:37 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:36 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 11/16] t3415: increase granularity of test_auto_{fixup,squash}() Date: Mon, 6 Jan 2020 23:53:08 -0500 Message-Id: <8b716c6a8198edb6a7f060cff797cb1085fdceab.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We are using `test_must_fail test_auto_{fixup,squash}` which would ensure that the function failed. However, this is a little ham-fisted as there is no way of ensuring that the expected part of the function actually fails. Increase the granularity by accepting an optional `!` first argument which will check that the rebase does not squash in any commits by ensuring that there are still 4 commits. If `!` is not provided, the old logic is run. This patch may be better reviewed with `--ignore-all-space`. Signed-off-by: Denton Liu --- t/t3415-rebase-autosquash.sh | 64 +++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh index b0add36f82..093de9005b 100755 --- a/t/t3415-rebase-autosquash.sh +++ b/t/t3415-rebase-autosquash.sh @@ -25,6 +25,13 @@ test_expect_success setup ' ' test_auto_fixup () { + no_squash= && + if test "x$1" = 'x!' + then + no_squash=true + shift + fi && + git reset --hard base && echo 1 >file1 && git add -u && @@ -35,14 +42,19 @@ test_auto_fixup () { test_tick && git rebase $2 -i HEAD^^^ && git log --oneline >actual && - test_line_count = 3 actual && - git diff --exit-code $1 && - echo 1 >expect && - git cat-file blob HEAD^:file1 >actual && - test_cmp expect actual && - git cat-file commit HEAD^ >commit && - grep first commit >actual && - test_line_count = 1 actual + if test -n "$no_squash" + then + test_line_count = 4 actual + else + test_line_count = 3 actual && + git diff --exit-code $1 && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 1 actual + fi } test_expect_success 'auto fixup (option)' ' @@ -52,12 +64,19 @@ test_expect_success 'auto fixup (option)' ' test_expect_success 'auto fixup (config)' ' git config rebase.autosquash true && test_auto_fixup final-fixup-config-true && - test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash && + test_auto_fixup ! fixup-config-true-no --no-autosquash && git config rebase.autosquash false && - test_must_fail test_auto_fixup final-fixup-config-false + test_auto_fixup ! final-fixup-config-false ' test_auto_squash () { + no_squash= && + if test "x$1" = 'x!' + then + no_squash=true + shift + fi && + git reset --hard base && echo 1 >file1 && git add -u && @@ -68,14 +87,19 @@ test_auto_squash () { test_tick && git rebase $2 -i HEAD^^^ && git log --oneline >actual && - test_line_count = 3 actual && - git diff --exit-code $1 && - echo 1 >expect && - git cat-file blob HEAD^:file1 >actual && - test_cmp expect actual && - git cat-file commit HEAD^ >commit && - grep first commit >actual && - test_line_count = 2 actual + if test -n "$no_squash" + then + test_line_count = 4 actual + else + test_line_count = 3 actual && + git diff --exit-code $1 && + echo 1 >expect && + git cat-file blob HEAD^:file1 >actual && + test_cmp expect actual && + git cat-file commit HEAD^ >commit && + grep first commit >actual && + test_line_count = 2 actual + fi } test_expect_success 'auto squash (option)' ' @@ -85,9 +109,9 @@ test_expect_success 'auto squash (option)' ' test_expect_success 'auto squash (config)' ' git config rebase.autosquash true && test_auto_squash final-squash-config-true && - test_must_fail test_auto_squash squash-config-true-no --no-autosquash && + test_auto_squash ! squash-config-true-no --no-autosquash && git config rebase.autosquash false && - test_must_fail test_auto_squash final-squash-config-false + test_auto_squash ! final-squash-config-false ' test_expect_success 'misspelled auto squash' ' From patchwork Tue Jan 7 04:53:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320389 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 948356C1 for ; Tue, 7 Jan 2020 04:53:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 726E9207E0 for ; Tue, 7 Jan 2020 04:53:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jb4Ajixx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727636AbgAGExq (ORCPT ); Mon, 6 Jan 2020 23:53:46 -0500 Received: from mail-qv1-f44.google.com ([209.85.219.44]:35029 "EHLO mail-qv1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727610AbgAGExj (ORCPT ); Mon, 6 Jan 2020 23:53:39 -0500 Received: by mail-qv1-f44.google.com with SMTP id u10so19958309qvi.2 for ; Mon, 06 Jan 2020 20:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IUqS2ToxxIaU+JGMqM0slg+lmdW/PYLUq2Mp3ANUqOY=; b=Jb4AjixxpucSr5IV9UcZ/aCVXZpHgvJCkRQnVZSRQWSaGjSTe8r0aoOUeTIyWZ8zzJ 0SHYa/tjXroYwOxBmNqNustqROzKlyhVDcnx9mWEYIdDXw1kDdrVOnac+seSSkcK/tjT 8Zaf8Qcf2CUmPd9ZdMjUshO1IvvUYqoMr4iO1xwfRIiBHMUI/E5oE7uvDM38Cf3RE8zx HX0CyMeDCR9I3I9MYry5w8NqvOe0oKaCgVeL6LykbEgJAjzu2adZnJdYFGIxYap03P9k MzzyREg9zpHN450aRB1SI2IOzpTU0kmLRwTP8hrRSVRTHpwcumFt8ABj8/Vw99qTsw1c nBRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IUqS2ToxxIaU+JGMqM0slg+lmdW/PYLUq2Mp3ANUqOY=; b=VPlb1pf4634Fbd2RzakSfPXahvYMsZ4/esJ458fcmDthaLqzmOh3hrzNGmh/DCPlNT B1OFusGNKxVvVYsnaJ7zKksdeWLFp01Z364984nYVXafc+qBQrS9NQRzV0Tg62mr3vsz KVUCb0d6wc3RtDYRsdJXWFRsHIG429yyq9c1DnM7JV8O4dBcY1xTvToNT4Lkugh/geMR pFIuJTdkR5Cm6EcR2r0YdBd9spIAjmP86Zn+sJg6aAcAO5wciDlDiHb73eq/T4B1jb7y 1YRn2VH9nBPYl36ZQmuu53YcOSrOKyLt3C87y9haKrJPtW2343jPtC6XCnUdTfInXrsp wThw== X-Gm-Message-State: APjAAAWQ70N2QzoxTjjmtIrSGlEQpf8j+FsckPZFouxMArTVwa6zA/FL vpEmY4/psmpxUDDQQs7nK3Raxnqe X-Google-Smtp-Source: APXvYqzuDBjJDK2qyz7Wt1vnNOY3AHc/ImW+UT4QLDD8YrIWLVViJI2XPc2rJukzHLvcAczBoLBRDA== X-Received: by 2002:a0c:ed32:: with SMTP id u18mr83085016qvq.2.1578372817976; Mon, 06 Jan 2020 20:53:37 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:37 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 12/16] t3419: stop losing return code of git command Date: Mon, 6 Jan 2020 23:53:09 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix invocation of git command so its exit codes is not lost within a non-assignment command substitution. Signed-off-by: Denton Liu --- t/t3419-rebase-patch-id.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh index 49f548cdb9..94552669ae 100755 --- a/t/t3419-rebase-patch-id.sh +++ b/t/t3419-rebase-patch-id.sh @@ -80,7 +80,8 @@ do_tests () { git commit -q -m "change big file again" && git checkout -q other^{} && git rebase master && - test_must_fail test -n "$(git rev-list master...HEAD~)" + git rev-list master...HEAD~ >revs && + test_must_be_empty revs ' test_expect_success $pr 'do not drop patch' ' From patchwork Tue Jan 7 04:53:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320387 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 C9EF214BD for ; Tue, 7 Jan 2020 04:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A593C207E0 for ; Tue, 7 Jan 2020 04:53:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JcNprWz9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727624AbgAGExl (ORCPT ); Mon, 6 Jan 2020 23:53:41 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:32924 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbgAGExj (ORCPT ); Mon, 6 Jan 2020 23:53:39 -0500 Received: by mail-qt1-f196.google.com with SMTP id d5so44405294qto.0 for ; Mon, 06 Jan 2020 20:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=28oBMed1uIAPxpGMIjzfQY1Nzi7Ju1o58BuNUHYtsOE=; b=JcNprWz9UOKkyCWAoGt+ogmak+OtkvhkydIo3HI8axrqtXl4Y61e7MpV3QaXjsUPrT Q1BzpbWIlJxrjs3oxBNwaQP4A6YT8EzFTu4QRPAwTE9tQm7mvof6Eak0RiVFcUQg4BRN EJye9Is2U9PDDd5HdDo5/Pl9K15kfg2dl4ZuRLrSLOo/J/q/PAAwf1fBhbiztUAg5KUa iZPFB2uj4Bgklp1c5wzayFVudXO5G0qpVJKO5+gh+xXWKMpGRn8AH2ou2lH0lpeYfzqM fHB+dbQN88kCIx/uq9hCUMpmdiP4AECz8rCpPPf6APK/GfzTDarDWRl9g9ImQ1A96e/+ ZAwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=28oBMed1uIAPxpGMIjzfQY1Nzi7Ju1o58BuNUHYtsOE=; b=ums0Yv7XSdGSMPuUknYlLiHcqQXqRQPrLAh+r1pACnbi2xXjo7TU2ykjyCf+9++oqq rD0wGPW23SMV8O5jXBZvJJmAb+pJyyBJZtCptLrPJdKYqOLO8yZ9zPwPb+ADI0dsom9Q NCX3zdbhpve//Z271SuqjkFbSQlZeBYqIMysugj3NY5wH8V6HIe8qO6vm1ciDSgZVfX1 4uMWm8YloA5/CUsczEgJJHkLmp8IesF1Rr+BIVThEWEa0JIHSZT1jq+Ef/bfpd2FfhVg kubcd87kZyV3fYQa/qyJC9xjXatasR9RVxnpmMXaq9jRu1oCt8wucGOqIyR2iRN01vv9 FLHg== X-Gm-Message-State: APjAAAW4MBME4qBOUAm3UTDNPk6LK8EWyokGxsK4YVGEIW4V0Me3u4XF 6E2CxDytusVUrlXvNGLn5SNVC/vd X-Google-Smtp-Source: APXvYqxy+MMKzTqZ2onn39zgkAszmVEqypddSJv5MSZmQYJePwWFtY7jpFKUzfETFgJYSWlQK8FAaw== X-Received: by 2002:ac8:534b:: with SMTP id d11mr78017217qto.170.1578372818876; Mon, 06 Jan 2020 20:53:38 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:38 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 13/16] t3504: do check for conflict marker after failed cherry-pick Date: Mon, 6 Jan 2020 23:53:10 -0500 Message-Id: <88134bb6d1cb32fca621f5b8acdb3e8b0c4e1c69.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Sixt The test with disabled rerere should make sure that the cherry-picked result does not have the conflict replaced with a recorded resolution. It attempts to do so by ensuring that the file content is _not_ equal to some other file. That by itself is a very dubious check because just about every random result of an incomplete cherry-pick would satisfy the condition. In this case, the intent was to check that the conflicting file does _not_ contain the resolved content. But the check actually uses the wrong reference file, but not the resolved content. Needless to say that the non-equality is satisfied. And, on top of it, it uses a commit that does not even touch the file that is checked. Do check for the expected result, which is content from both sides of the merge and merge conflicts. (The latter we check for just the middle separator for brevity.) As a side-effect, this also removes an incorrect use of test_must_fail. Signed-off-by: Johannes Sixt Signed-off-by: Denton Liu --- t/t3504-cherry-pick-rerere.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/t3504-cherry-pick-rerere.sh b/t/t3504-cherry-pick-rerere.sh index a267b2d144..80a0d08706 100755 --- a/t/t3504-cherry-pick-rerere.sh +++ b/t/t3504-cherry-pick-rerere.sh @@ -94,8 +94,10 @@ test_expect_success 'cherry-pick --rerere-autoupdate more than once' ' test_expect_success 'cherry-pick conflict without rerere' ' test_config rerere.enabled false && - test_must_fail git cherry-pick master && - test_must_fail test_cmp expect foo + test_must_fail git cherry-pick foo-master && + grep ===== foo && + grep foo-dev foo && + grep foo-master foo ' test_done From patchwork Tue Jan 7 04:53:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320383 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 5996514B4 for ; Tue, 7 Jan 2020 04:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38230207FD for ; Tue, 7 Jan 2020 04:53:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U72J9ANn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727629AbgAGExn (ORCPT ); Mon, 6 Jan 2020 23:53:43 -0500 Received: from mail-qv1-f49.google.com ([209.85.219.49]:36347 "EHLO mail-qv1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727617AbgAGExk (ORCPT ); Mon, 6 Jan 2020 23:53:40 -0500 Received: by mail-qv1-f49.google.com with SMTP id m14so4110660qvl.3 for ; Mon, 06 Jan 2020 20:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jbA3LBz+SdJg67fYbKODcNtdYg8o9uAs+VSX7Ubldpg=; b=U72J9ANn17meyr2e/JvWJk7GYlgitKhCYJGwTdB4HKKSScTqkiOoNVbjPsTNPr4dfu Mbiw/uM6lJvjrkg5+vW4uHjD21pYOgs8S/mWIb+4gSUpJr6b77XWfuVuPuqgZaEuSDyZ We+yHxnxe4z7Lphyu/sXgEiK2v/AKaTA78n3k1YBc6xzOGfeop6WEmIhEhyb6avlc7Dg +5yPMd5NDLuO7h1wBroJpPDvN2yGwytPc4tb2vaQwE49clNKLSp0NIiaBEbNHtK/OFB8 6AHtBaoQuWbiNDhupQJncS0mi4Jwc3svwk8NSTYwvtAcpXQ1vMdbCK1zkXO+1iqZEYJG SvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jbA3LBz+SdJg67fYbKODcNtdYg8o9uAs+VSX7Ubldpg=; b=cwLtftFGLAio8Kqhe2AtxgaWKON7MQrwcj155mp8c0gD0oAseV9FJGcyFhsyjJmYGC X/CNnkUKG1+eHI2SwtEIYxzAmTaspLkbUUFFCNoDqDuA0/ViX5JH/NsLDpUS+J2eSb0K YP7NsPQDg0ykK6ONwkMjRZTpbkbochOQRdwQToAxhxSTAsT2JlZ8w9KC6LkJIYSMKFvZ J1lcj2Y3MIIh6YCWKjoh1VMPyPIqc3CIrXwuWUDGJpXvDs104Ogai8MemdOp5dlyj+1o pEjSWtK+gZJKsexGw/bytnjK7MaI0Ara8A7LTX9HywtvGa1KMk9TTZsJU3T+KDq7Z2IK PS8A== X-Gm-Message-State: APjAAAVF6KuIfzDQnsCq8fWwCshXQBAA6kmLfGR5MNV/Xh+e/vXfw3Mp ctvUHVhvSGZlXy8f9PK2vbgiMczZ X-Google-Smtp-Source: APXvYqyzzQ0Q2QTHJDnr1Vh91L4w+NrQlgPkEi5pBYRJJOc+lY2E1N/VsKY66BwiK1waBunClG1ViA== X-Received: by 2002:a05:6214:38c:: with SMTP id l12mr82518743qvy.224.1578372819698; Mon, 06 Jan 2020 20:53:39 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:39 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 14/16] t3507: fix indentation Date: Mon, 6 Jan 2020 23:53:11 -0500 Message-Id: <96310b7d289a912fa173dd15d55f3326005402cc.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We have some test cases which are indented 7-spaces instead of a tab. Reindent with a tab instead. This patch should appear empty with `--ignore-all-space`. Signed-off-by: Denton Liu --- t/t3507-cherry-pick-conflict.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 9b9b4ca8d4..2a0d119c8a 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -381,23 +381,23 @@ test_expect_success 'failed commit does not clear REVERT_HEAD' ' ' test_expect_success 'successful final commit clears revert state' ' - pristine_detach picked-signed && + pristine_detach picked-signed && - test_must_fail git revert picked-signed base && - echo resolved >foo && - test_path_is_file .git/sequencer/todo && - git commit -a && - test_must_fail test_path_exists .git/sequencer + test_must_fail git revert picked-signed base && + echo resolved >foo && + test_path_is_file .git/sequencer/todo && + git commit -a && + test_must_fail test_path_exists .git/sequencer ' test_expect_success 'reset after final pick clears revert state' ' - pristine_detach picked-signed && + pristine_detach picked-signed && - test_must_fail git revert picked-signed base && - echo resolved >foo && - test_path_is_file .git/sequencer/todo && - git reset && - test_must_fail test_path_exists .git/sequencer + test_must_fail git revert picked-signed base && + echo resolved >foo && + test_path_is_file .git/sequencer/todo && + git reset && + test_must_fail test_path_exists .git/sequencer ' test_expect_success 'revert conflict, diff3 -m style' ' From patchwork Tue Jan 7 04:53:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320391 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 8DF586C1 for ; Tue, 7 Jan 2020 04:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C80B207E0 for ; Tue, 7 Jan 2020 04:53:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uqEHXhD5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727632AbgAGExp (ORCPT ); Mon, 6 Jan 2020 23:53:45 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:36630 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727620AbgAGExl (ORCPT ); Mon, 6 Jan 2020 23:53:41 -0500 Received: by mail-qv1-f67.google.com with SMTP id m14so4110669qvl.3 for ; Mon, 06 Jan 2020 20:53:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=znwb9Sje/8O77iNvWb/cukk/sZqJTNSKosYDU3GOKZk=; b=uqEHXhD5kZtz+7/TxUMNqwULSedRVT3/WHzB5yGMd3IhhC3Gi7ptpX3UOfj8ezJ46l tMay6y2nJMwp/OzWWx8ti1wLtWSu7BeVojbwZ63FH3k5pOApk0ua+ymrq5HqW38nNq6r J+644hdvy4ZAeplkZbbnnRUvKKJqvP8HFKWn5Chua4woAcifV4hGTRcF6AazHSAetACg XkaXqVyfjvNORNCncjoTlOwtRTo/o4O43CVPlCyIcC+W9WzbLKmBFWVIqq1YOf4J72GN MaMg2aY934PzMhigliWa/hVRLAOwwCcrVjOPTIVjgrXHG6tDyBM1JLtl1Hbzvl0do7r8 7n/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=znwb9Sje/8O77iNvWb/cukk/sZqJTNSKosYDU3GOKZk=; b=ODVzquTZV84cZz5DSZ7on9aMrDkqXjWGb/q4dowAZ/p64BPUxVkAP4+mTdw8iagsBP 1FCMLTxY1zj6yM+1UbAcurI4WGFn1iqFBSUjL/hoPnjbIc4dBrcmWRfEf8ZcfDXoh/rc UOI5NG/mOGfndEltRdyKv9EDVso6BN8ow+o9nPHveynmlGqjFAY+j57kcEQom4jV8Ho7 6vaoWDkIutfmZo8+JjXHtZkUtDe5xB+pB6S7xv0BPUzvosWu/l1wyhPi5dlwueItMaTb 7fF0k+Maz15uGdhm2MqJytLdHMZxv2o4NESQBP7zJHlbXnUvpjvhFoSLrts7X1yf6D2y PuJw== X-Gm-Message-State: APjAAAV6Nw9pR1btQJqpyvbhaJGm3wag2vX4pVip3q08AoApcRWziT46 BaGdxMBnZ4omZtKfhl3Cs+DZerck X-Google-Smtp-Source: APXvYqw5sjLsytFfPFZNUj6JDBi0kjwizVnQaiOkQ1IdUAYddLpAcTrssifuduE5pksP1rO9V5fvJA== X-Received: by 2002:a0c:f24a:: with SMTP id z10mr83577163qvl.33.1578372820606; Mon, 06 Jan 2020 20:53:40 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:40 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 15/16] t3507: use test_path_is_missing() Date: Mon, 6 Jan 2020 23:53:12 -0500 Message-Id: <69125b8e2f33e9e538263829b0bcfc08c4812684.1578372682.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The test_must_fail() function should only be used for git commands since we should assume that external commands work sanely. Replace `test_must_fail test_path_exists` with `test_path_is_missing` since we expect these paths to not exist. Signed-off-by: Denton Liu --- t/t3507-cherry-pick-conflict.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 2a0d119c8a..9bd482ce3b 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -168,7 +168,7 @@ test_expect_success 'successful final commit clears cherry-pick state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git commit -a && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'reset after final pick clears cherry-pick state' ' @@ -178,7 +178,7 @@ test_expect_success 'reset after final pick clears cherry-pick state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git reset && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'failed cherry-pick produces dirty index' ' @@ -387,7 +387,7 @@ test_expect_success 'successful final commit clears revert state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git commit -a && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'reset after final pick clears revert state' ' @@ -397,7 +397,7 @@ test_expect_success 'reset after final pick clears revert state' ' echo resolved >foo && test_path_is_file .git/sequencer/todo && git reset && - test_must_fail test_path_exists .git/sequencer + test_path_is_missing .git/sequencer ' test_expect_success 'revert conflict, diff3 -m style' ' From patchwork Tue Jan 7 04:53:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11320385 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 525D16C1 for ; Tue, 7 Jan 2020 04:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EC272075A for ; Tue, 7 Jan 2020 04:53:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="exZfRakb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727630AbgAGExo (ORCPT ); Mon, 6 Jan 2020 23:53:44 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:46296 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727517AbgAGExm (ORCPT ); Mon, 6 Jan 2020 23:53:42 -0500 Received: by mail-qt1-f195.google.com with SMTP id g1so4022249qtr.13 for ; Mon, 06 Jan 2020 20:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DgaLyiQkjXbO+vBVUmE3syCbCvisT6JTQ0XXXX2DoVk=; b=exZfRakb8I54+yZJVdP0s/n2dvc0jcxeNyPxNa7FEUvt9r7lR5fLXobqbPV5XUVF7W zkwEwz6FhNS8J4geTLon+GPShsVFbLN+ECAG53oDQd9VAkoAKTQ8HkDOA0NGtvcNNwTw hjPjid2GYlqMrnXxTJZSKakB0IVpbCLZgjBMxM8v7FNtg7peI+AXjbjAGA1XNTVv+LMk 63mI3CBAWT+Eb/kxU3NGgg23Vn5bHb/vrzYc6vvAKVkdrjNDvcNKdVmCrLr71C3TsA2a ZFwso2vk2S8ZRSdhqjUSUCTB4KtiGSYLJ9d6xmF2KHE9HBVIO2rljJPzZVm4rPs8jGN8 tVvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DgaLyiQkjXbO+vBVUmE3syCbCvisT6JTQ0XXXX2DoVk=; b=LtWF4VvkBcRjGih5GZIYD3QYjtdeNFuYwetPh8U9M8FuJPWNZDOUGRD3B7tWMk/Ktl ZtKJMnJ3/Ulpp7o2JWva5qnVQhdhbTBoSBTOEzBmIO50S6BPuyzYG9jPefuWRO0umOzl f+eJNU3bB1s4l//xxBxUoEMRRdl4BEC59yhfQPxnPhRQzfWtN1B3BeqWGSHfLwbUBg5e +twbOTBhjEEXINHjmydOYT+mnMD694xW7vk9F6AawSg69h9/WVG4OQdQ8OJa3WQMvQCy LafjNCY+wN31ahtezNR4wFZ5WVqdJyHMDOnIUgZ7wkF4XOBfL4+1Bwkx9EBhC5yImuc2 ZjRA== X-Gm-Message-State: APjAAAXqAqc9H9aFg0DT3I0efdCHY/1II+dVrHpWQuALuBKYuh3Di1RE Jd/r58HVxtGIYx+ZBWrEhWs/LG0W X-Google-Smtp-Source: APXvYqxHl5cobnL7nvb0BwjXDSHQfAfZ0WTT4yDqkguU2VgDPfw4STyETAhqaeSRGqEtpgefI846Ew== X-Received: by 2002:ac8:5548:: with SMTP id o8mr79933912qtr.338.1578372821502; Mon, 06 Jan 2020 20:53:41 -0800 (PST) Received: from archbookpro.lan ([199.249.110.29]) by smtp.gmail.com with ESMTPSA id t2sm21663893qkc.31.2020.01.06.20.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 20:53:41 -0800 (PST) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Jakub Narebski , Johannes Sixt , Junio C Hamano Subject: [PATCH v2 16/16] t4124: only mark git command with test_must_fail Date: Mon, 6 Jan 2020 23:53:13 -0500 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.180.g49a268d3eb In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The test_must_fail function should only be used for git commands since we should assume that external commands work sanely. Since apply_patch wraps a sed and git invocation, rewrite it to accept an `!` argument which would cause only the git command to be prefixed with `test_must_fail`. Signed-off-by: Denton Liu --- t/t4124-apply-ws-rule.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index ff51e9e789..971a5a7512 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -35,9 +35,15 @@ prepare_test_file () { } apply_patch () { + cmd_prefix= && + if test "x$1" = 'x!' + then + cmd_prefix=test_must_fail && + shift + fi && >target && sed -e "s|\([ab]\)/file|\1/target|"