From patchwork Wed Sep 8 02:17:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12479779 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51E8FC433EF for ; Wed, 8 Sep 2021 02:17:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 362226103D for ; Wed, 8 Sep 2021 02:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346037AbhIHCSX (ORCPT ); Tue, 7 Sep 2021 22:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234260AbhIHCST (ORCPT ); Tue, 7 Sep 2021 22:18:19 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 285ACC061757 for ; Tue, 7 Sep 2021 19:17:12 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id b6so795979wrh.10 for ; Tue, 07 Sep 2021 19:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=uIPp3CfnsAAnjK9crt2NMpVuUsqUMwT1HywtehAKhzE=; b=IrxbTGgiUCtS/SkALwOLJIi23sUxNTxwTannREMpQBS5m6jVdumHxJPBDcqtP82jLb yFh9LE9KKmOQ+ZownFNBFb38vaQ1jR3/iQuTjQXu/LzAu29BHlTCOELs5iimfcYnT3dR a8K+rBVAmoCaHgADiznXKAhAnS7BCuP+VU90mmhj2C6AyGGh21NDmkH0cqr5ViGHv9HR Ax9cmHQ8Z3/9Qr54d5b8JPcbxt7wD5AYaKxLCc1bcMPtEEPLK2JA7Em1aSeJ3y0RmFVC m8mw0k+etfO3IOPrZKbAbKVnXsIl8GwTiIdlw0GRCwSxInjr333TdwJcnMTLWSe0H49k 9iuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=uIPp3CfnsAAnjK9crt2NMpVuUsqUMwT1HywtehAKhzE=; b=EnbawcA4VEoussxiGrWlDlSWtgcHnBTG4Nu7UZKBHhCB/9ZwShk6qNLc3O0W/j8KhC TSSAEm1EXK7R/Q8c4jh94LVa1TJkpBop2FMcbOIIxJw6fGXPczr46t8vemSwX6qlSdp5 S/VeAR1MgjRq4cx2KCDISjUa24XUcGMh/+coyW8Vf4lu9azRoYhuMfM22+zV5wCyYund PTuzqBWFIWPQv6+3iJ4ME7pjWq8uijNmMkh8FHihncIwGWEmiQnKf3Kx35RQuQm6UtG5 U6lVLYCER/hp/nrkA3GzkTvl0ONM0w+j/l5hBLBSQL+WYNyvWDwZ1/NwYYZau035PcEC 35cw== X-Gm-Message-State: AOAM533nxCv6DvUm3C4As3QpZ0XZxN/SjMGfcvvhVc2AO9/hz4opsEVJ jANqq3bJp0A04fVXp3b9aEfeJA+IDXA= X-Google-Smtp-Source: ABdhPJyzT0K+i7T74qHG5anT0oq2LRdm+ud370m3Pg/SHDh4zV40YW1UpT/5ek9RwetkLdkN1P/07g== X-Received: by 2002:adf:c506:: with SMTP id q6mr1241301wrf.78.1631067430761; Tue, 07 Sep 2021 19:17:10 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d29sm652597wrc.6.2021.09.07.19.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 19:17:10 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 02:17:08 +0000 Subject: [PATCH 1/2] t4151: document a pair of am --abort bugs Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- t/t4151-am-abort.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 9d8d3c72e7e..501a7a9d211 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -23,7 +23,11 @@ test_expect_success setup ' test_tick && git commit -a -m $i || return 1 done && + git branch changes && git format-patch --no-numbered initial && + git checkout -b conflicting initial && + echo different >>file-1 && + git commit -a -m different && git checkout -b side initial && echo local change >file-2-expect ' @@ -191,4 +195,31 @@ test_expect_success 'am --abort leaves index stat info alone' ' git diff-files --exit-code --quiet ' +test_expect_failure 'git am --abort return failed exit status when it fails' ' + test_when_finished "rm -rf file-2/ && git reset --hard" && + git checkout changes && + git format-patch -1 --stdout conflicting >changes.mbox && + test_must_fail git am --3way changes.mbox && + + git rm file-2 && + mkdir file-2 && + echo precious >file-2/somefile && + test_must_fail git am --abort && + test_path_is_dir file-2/ +' + +test_expect_failure 'git am --abort returns us to a clean state' ' + git checkout changes && + git format-patch -1 --stdout conflicting >changes.mbox && + test_must_fail git am --3way changes.mbox && + + # Make a change related to the rest of the am work + echo related change >>file-2 && + + # Abort, and expect the related change to go away too + git am --abort && + git status --porcelain -uno >actual && + test_must_be_empty actual +' + test_done From patchwork Wed Sep 8 02:17:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12479781 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B052C433EF for ; Wed, 8 Sep 2021 02:17:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D13C6108B for ; Wed, 8 Sep 2021 02:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346139AbhIHCSY (ORCPT ); Tue, 7 Sep 2021 22:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235450AbhIHCSU (ORCPT ); Tue, 7 Sep 2021 22:18:20 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D515C061575 for ; Tue, 7 Sep 2021 19:17:12 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id m9so853523wrb.1 for ; Tue, 07 Sep 2021 19:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mO6XkLHQL3a/TemDdoDtE/8OXCaWboURjrkTebQ11wg=; b=mIscAzCTMau1ox7/GhcWXc5la0B9ateW+DF8B0lFklEsMJB+xqkrK3CWznEM1f4vxA vLFinNVkfJIQVyeOcYNxQTgRaO8hREuagzsPg3xIi1OD+MIvmna4iO6tkUW5FuJy5wQ2 W1eer28AmTJs5odYNDhqtyqtL22tFPMicSK2sRqii3ymBU3e8IWMKPH9Tn78AUbMjnZE /X1rnPfRKrat7r738un8JOej32G4qBu/qZ+0mFIc4aelWasRN9GlOSAx6o3ehIQEgl6d G/TUsWc8SKaLJPeKDRBvxFUTPK5EX/3ou63xwo3nOpTG7bMHZKpqETBY8lk0smZUqiXJ SYvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mO6XkLHQL3a/TemDdoDtE/8OXCaWboURjrkTebQ11wg=; b=L6GgR0xExS2/lluS0+E0iSPBTBAjLcTTzaYdWB6kqrwrgjM5VA5qU4I4bCByxjFHg0 LCjecPybD7/y2oWKGar9KJSfNgwvCqBQKUruKaVb3MrE+B6joIPaaSOHBI2qr3SBhTy+ eU4+74ZZliA08gEze++KdE2ijoTvFMP7a2ZgNscwL82IS/NzKXzzETNOx8iIOEpySVYA 5Czh19XLOE3ac6q9Swlg7IZzsCXGUg7DMFk8bU8eXmLTOe2EfZ7o1mlvKWgZsSlEbpkg PQLSAaupljRYezEUqdfS3kGfApt6kP1qrlAz8F6k/aaxmTsXUEx++oRDsZqcl65htwD2 jqrg== X-Gm-Message-State: AOAM531zz4ZsM3PviSlchiAYfOyii+I8c1OFTrBuAjvtFxtLYi1fZmUe ElfFpeu6wwqp7wCGXNTFjifGBiaQ3Y4= X-Google-Smtp-Source: ABdhPJxlQL3v8muP3O7IdRtkfy2nhS8gBuc4scu6eBuILWeaoyZJ91+lZX1FOwHzAhIY+CTtmYhpUg== X-Received: by 2002:adf:8b03:: with SMTP id n3mr1166718wra.439.1631067431308; Tue, 07 Sep 2021 19:17:11 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n4sm649744wra.37.2021.09.07.19.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 19:17:11 -0700 (PDT) Message-Id: <5fa7daf264b75fc5419e829683be2e6d83191908.1631067429.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 02:17:09 +0000 Subject: [PATCH 2/2] am: fix incorrect exit status on am fail to abort Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren Signed-off-by: Elijah Newren --- builtin/am.c | 3 ++- t/t4151-am-abort.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index 0c2ad96b70e..c79e0167e98 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -2106,7 +2106,8 @@ static void am_abort(struct am_state *state) if (!has_orig_head) oidcpy(&orig_head, the_hash_algo->empty_tree); - clean_index(&curr_head, &orig_head); + if (clean_index(&curr_head, &orig_head)) + die(_("failed to clean index")); if (has_orig_head) update_ref("am --abort", "HEAD", &orig_head, diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 501a7a9d211..f889f25a98f 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -195,7 +195,7 @@ test_expect_success 'am --abort leaves index stat info alone' ' git diff-files --exit-code --quiet ' -test_expect_failure 'git am --abort return failed exit status when it fails' ' +test_expect_success 'git am --abort return failed exit status when it fails' ' test_when_finished "rm -rf file-2/ && git reset --hard" && git checkout changes && git format-patch -1 --stdout conflicting >changes.mbox &&