From patchwork Mon Sep 13 15:19:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489771 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.7 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,URIBL_BLOCKED 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 7B36BC433EF for ; Mon, 13 Sep 2021 15:45:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5830D60F6F for ; Mon, 13 Sep 2021 15:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343497AbhIMPqq (ORCPT ); Mon, 13 Sep 2021 11:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245412AbhIMPql (ORCPT ); Mon, 13 Sep 2021 11:46:41 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 460F0C0A888E for ; Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id t18so15333196wrb.0 for ; Mon, 13 Sep 2021 08:19:26 -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=EDztBiw0+ZbyfUI/B7a79CljlOr/ZRUEAk2iSYSmG1A=; b=KILqnKFr0k3/kfbHWOUlDkAkmvfpXkodyJap6OXwD0B/6ywIJ0Q4DMKoCGV2gLGbly VfU8iXbEPXbkr2C/l4L/bwbmlN929+HxK+3NNljzdjVl3wfpBv61arzJpZxN8jsx80tq n+hqKgeasKLQDXx/VaJ8BWXTfV1uKdfYE2U7n72VVUwJtetqicStp6q3V8h55sYLxZqa fKTu411BkkLZy7SgAdWlsXpxTafZgcxuL9jg3dJd01eOzhC/3ECaBkQYFoLfqJmm4y4m Ei4+qLo0PShNkHJ0olsiFYpdSSRbZ8saYn5rZ7qbkHghUx4kuWzZ2RR5sc60UTMDceyI /UfA== 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=EDztBiw0+ZbyfUI/B7a79CljlOr/ZRUEAk2iSYSmG1A=; b=5s9LEQ5xGMlZw2TfyAX+JZWCoaCUwzL4zUjOtxRLHuzNAxXx3wbNacw/iF7IWI+2VI /IlgVxDqTI3f/39g6Jkz1KiosXUXdeipOUc5BSpwLl59Q++CsVqJp1hH57/MdSqhHTqh ocUNPLYeNnlqpB0In8DqpENtgpuh1PU859cJ8ClzMax1pJjzObmV6ycncCkfs90FRnQe KqSUbo3HN2XeNIQEihNAkZH9yGQTXO8UB4Kw1NRXeuvbZ3m3NVGaJPzYRWLoOfW2joKq 7aqb9zCu37eHdhsfVZ09g2/7AkgJ1CN04mC9at/KX+9848ojT5e94xLzZjveX4Y6bKnh rVGg== X-Gm-Message-State: AOAM532bem45UeQ81zSkknkTLwBpLBhrj9+KZfa/fcDr5AuKFrBGKZaK LiLYwF1RndQ7zJ+ARVkpx9sZBI3/xOM= X-Google-Smtp-Source: ABdhPJzuDsgo3p1jexZCEuiblC0xO+qfASIc5cEy1M6JIDSMduh4E8DqHlXxSQr7YIg0fz9R395Bhg== X-Received: by 2002:adf:d084:: with SMTP id y4mr7885529wrh.249.1631546364806; Mon, 13 Sep 2021 08:19:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n7sm3788570wms.18.2021.09.13.08.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:24 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:12 +0000 Subject: [PATCH v2 01/11] t3407: run tests in $TEST_DIRECTORY Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Commit 97b88dd58c ("git-rebase.sh: Fix --merge --abort failures when path contains whitespace", 2008-05-04) started running these tests in a subdirectory with a space in its name. At that time $TEST_DIRECTORY did not contain a space but shortly after in 4a7aaccd83 ("Rename the test trash directory to contain spaces.", 2008-05-04) $TEST_DIRECTORY was changed to contain a space so we no longer need to run these tests in a subdirectory. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 7c381fbc89a..c747bd31d76 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -7,13 +7,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh -### Test that we handle space characters properly -work_dir="$(pwd)/test dir" - test_expect_success setup ' - mkdir -p "$work_dir" && - cd "$work_dir" && - git init && echo a > a && git add a && git commit -m a && @@ -37,7 +31,6 @@ testrebase() { dotest=$2 test_expect_success "rebase$type --abort" ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && @@ -48,7 +41,6 @@ testrebase() { ' test_expect_success "rebase$type --abort after --skip" ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && @@ -61,7 +53,6 @@ testrebase() { ' test_expect_success "rebase$type --abort after --continue" ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && @@ -77,7 +68,6 @@ testrebase() { ' test_expect_success "rebase$type --abort does not update reflog" ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && git reflog show to-rebase > reflog_before && @@ -89,7 +79,6 @@ testrebase() { ' test_expect_success 'rebase --abort can not be used with other options' ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && @@ -103,7 +92,6 @@ testrebase " --apply" .git/rebase-apply testrebase " --merge" .git/rebase-merge test_expect_success 'rebase --apply --quit' ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase --apply main && @@ -115,7 +103,6 @@ test_expect_success 'rebase --apply --quit' ' ' test_expect_success 'rebase --merge --quit' ' - cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase --merge main && From patchwork Mon Sep 13 15:19:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489773 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.7 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,URIBL_BLOCKED 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 15547C433EF for ; Mon, 13 Sep 2021 15:45:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1BBD610A6 for ; Mon, 13 Sep 2021 15:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245039AbhIMPqx (ORCPT ); Mon, 13 Sep 2021 11:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245436AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7FCAC0A8890 for ; Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id i3so6948519wmq.3 for ; Mon, 13 Sep 2021 08:19:26 -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=EKgIYMV65+pF8SWCbofzmd9DTdcc/w9+US6Qm8arifo=; b=Of0rWDWAgVVaHdcD3HWcKPR+QPAU5Wl01lYhQg0lOC2822OoNzOVBH1//y/K9nexjR sCdnauHBFIOne8vuy35As9Hunex49ELkA+8cNqZb+NCVOS5JTYZ+u0SRml8gd0P4Jmb4 n+FuGok/BVoXsEdY+nNpGPi4N2HwhB/RPv0+cZL8eRekpgp+Y2fX4MklRrcvYR3ddftl B3249kCF45rdAeznrRe2DNjQRWagceWxAWDIsjv95P4J287rVBzKlLVDBSszW4VZqI3d Cp6LdVQvXb+M/mpMs8uZgcz+hJt23a2a2AdLrcRyNFtsnNDdkGw75YwLJafmZ5JOCmNh o3eg== 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=EKgIYMV65+pF8SWCbofzmd9DTdcc/w9+US6Qm8arifo=; b=zpOqPRu9qGBcG9LP1y8Y+FKSGg21wgV6ijFzyqJu6BPFTF7JFGLFA6aDYPaQ1IBUjJ d1/kFk3OqmIjRImabXZAmZTsNnM8VlqtIFIY36RyxSUnrFqnjuuGuJZg0INcYk9kZNVa 4fcpq5fY0SEBATzVWQ4k++fEhPry881SAPWqpXL66h1jxlX9bVJpWz8Oe2GZSDcbZKS7 ibBqY5B3g/UGYvDQW4Koy14RIe0blCbcS5gkPJmtO+e1APUZ+1updzIP5EJy36hvJM5U Rz7kdLYCl+N/xFK6kC5XwYkMiAg44kECht19HTvrckOdC7sGBMBtmGvLyA3o1x+43FAB 9Sww== X-Gm-Message-State: AOAM531io/c10Eo+KhP7V3T50N/FeFnTs77tx8BjhHm8cLXo104ZhCfC SC4NBSkrAiQBHyhgVudAbVbBow+hF6k= X-Google-Smtp-Source: ABdhPJxOkGSzqJbWGhjH1533EmabLK5eAENOQ4By1Z2rqOKfPSxuy6BpLPWOyAKZkrQEwauRt5MHgQ== X-Received: by 2002:a7b:cd0f:: with SMTP id f15mr11818263wmj.173.1631546365505; Mon, 13 Sep 2021 08:19:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f1sm7326291wri.43.2021.09.13.08.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:25 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:13 +0000 Subject: [PATCH v2 02/11] t3407: use test_commit Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Simplify the setup by using test_commit. Note that this replaces the branch "pre-rebase" with a tag of the same name. "pre-rebase" is only used as a fixed reference point so it makes sense to use a tag rather than a branch. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index c747bd31d76..0ad21966bc5 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -8,22 +8,15 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh test_expect_success setup ' - echo a > a && - git add a && - git commit -m a && + test_commit a a a && git branch to-rebase && - echo b > a && - git commit -a -m b && - echo c > a && - git commit -a -m c && + test_commit b a b && + test_commit c a c && git checkout to-rebase && - echo d > a && - git commit -a -m "merge should fail on this" && - echo e > a && - git commit -a -m "merge should fail on this, too" && - git branch pre-rebase + test_commit "merge should fail on this" a d d && + test_commit "merge should fail on this, too" a e pre-rebase ' testrebase() { From patchwork Mon Sep 13 15:19:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489775 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.7 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,URIBL_BLOCKED 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 5058BC433FE for ; Mon, 13 Sep 2021 15:45:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2DC3C610A6 for ; Mon, 13 Sep 2021 15:45:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343822AbhIMPq4 (ORCPT ); Mon, 13 Sep 2021 11:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245443AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62A53C0A8892 for ; Mon, 13 Sep 2021 08:19:27 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id g16so15320896wrb.3 for ; Mon, 13 Sep 2021 08:19:27 -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=9NpwjDFGHvgVsT0BcjST5Xoig7LqC/kMtL9l2s32FLU=; b=En48kPN+3urKpvRYggB0JAuqN9grqxwzWB7ztanFJ08sNH3DcBpg6gCD2zES0GdPXp ZilbEakFVjtVu2b+1hucwbtERjgpr5higS4klF+g0uDayNKms+hOXjRR09Q15RqRkAko lx+eaHgVAboHlIrlrYO+5UHmPW5fCpTXeigwtAsuXEfEjrH/y2Mw5A+r/b5OoLIUM3JX a/eMBKWpFxakTSIhF39MHWH2sEV/tpBISYCsdyTpFGQRTn6NlWYQ4Pin0llS4zPryDQQ gbfwFREhLbVZbYTTIXM5mLYCjCL3tPamnr0Jux1kogWU3AtWSgZKx908H1ygJ7uDsrd4 37xw== 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=9NpwjDFGHvgVsT0BcjST5Xoig7LqC/kMtL9l2s32FLU=; b=K0eTnDittWVsmIaHQw7AVeuELqq31Cv+MSIveL1z9U/wTGugb70G2WyJtYo7rcV2nu f9/r7sgHjLFjAXoD7mp5l3LXyekB0bJUciwHc3iQstOUjHxJtyrQpQN6k5oob0FHvraX WXuMWqnbpO+7WPyIdEqik+E2pbTujllP8cLd1gNSgbtebjWBt00LKkN7KpHqvBx1PRCo LIYs2yFwYkCqfzkypgn52Un/uGrlzVk60ZggomSidiy4GKXQnt/jCKfY/LSCtxPmJvjb dyZIqJU4TSDBSZiLlHxSON17JHCmu1x2m+GjhXx6rT96dk8hCicfQjyPfVcNQQEe+RUN i3BA== X-Gm-Message-State: AOAM531CaJx7zxWbboOBLjFpWgxW/Q2sRAhG5FeJ5tLmtdldMoc3VMjM 861rWNwPHYtFVA2HetaWy000el68pr8= X-Google-Smtp-Source: ABdhPJyFmdLidi1SXeioF4fR7oPYKbpFGG2WP7r/9F4pC1NZZtGdBuR6bon8eYqDYMCFIxKDK8+wnA== X-Received: by 2002:adf:ea90:: with SMTP id s16mr13360803wrm.235.1631546366059; Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o13sm5655475wri.53.2021.09.13.08.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:25 -0700 (PDT) Message-Id: <7755ce17fef90729275334a735d31a348a0ddbc0.1631546362.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:14 +0000 Subject: [PATCH v2 03/11] t3407: use test_cmp_rev Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood This provides better diagnostics if a test fails Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 0ad21966bc5..39076ac9462 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -29,7 +29,7 @@ testrebase() { test_must_fail git rebase$type main && test_path_is_dir "$dotest" && git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test_cmp_rev to-rebase pre-rebase && test ! -d "$dotest" ' @@ -39,9 +39,9 @@ testrebase() { test_must_fail git rebase$type main && test_path_is_dir "$dotest" && test_must_fail git rebase --skip && - test $(git rev-parse HEAD) = $(git rev-parse main) && + test_cmp_rev HEAD main && git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test_cmp_rev to-rebase pre-rebase && test ! -d "$dotest" ' @@ -54,9 +54,9 @@ testrebase() { echo d >> a && git add a && test_must_fail git rebase --continue && - test $(git rev-parse HEAD) != $(git rev-parse main) && + test_cmp_rev ! HEAD main && git rebase --abort && - test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test_cmp_rev to-rebase pre-rebase && test ! -d "$dotest" ' @@ -91,7 +91,7 @@ test_expect_success 'rebase --apply --quit' ' test_path_is_dir .git/rebase-apply && head_before=$(git rev-parse HEAD) && git rebase --quit && - test $(git rev-parse HEAD) = $head_before && + test_cmp_rev HEAD $head_before && test ! -d .git/rebase-apply ' @@ -102,7 +102,7 @@ test_expect_success 'rebase --merge --quit' ' test_path_is_dir .git/rebase-merge && head_before=$(git rev-parse HEAD) && git rebase --quit && - test $(git rev-parse HEAD) = $head_before && + test_cmp_rev HEAD $head_before && test ! -d .git/rebase-merge ' From patchwork Mon Sep 13 15:19:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489777 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.7 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,URIBL_BLOCKED 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 37B55C433F5 for ; Mon, 13 Sep 2021 15:45:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BB2C60F6F for ; Mon, 13 Sep 2021 15:45:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241112AbhIMPq5 (ORCPT ); Mon, 13 Sep 2021 11:46:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245476AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA18BC0A8893 for ; Mon, 13 Sep 2021 08:19:27 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id g16so15320934wrb.3 for ; Mon, 13 Sep 2021 08:19:27 -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=V98N4KFFTGnu5SYXwIpcKyAHtNwzXMX0/pNnBaCO1p8=; b=CgAQgtIhgQDtOPX2qa0PQrbRIS1xw4mDewbUdhqw1JvqRj8bmJ/b4O15bjf3LKNBwt aQ3KPIySZMmefA2u+ZqZ60wFYb9IGtvCR33CEWk7dk+Kgnqo5HSXx+NroS4vNgykUAaI F9IIDc8iSu2ZrNXmvRxF28gs2Dy0sdl/Ku9O7b4LDUqp7tuPgKS581DvMWCZz3I1KQdA 5J7HHalEasG6ZTZs5BZ9nylR0UqiRaSdPEAtLe4LY2/YZqcjxS0FsienTTmS/mypPhHV mAS+pKhDUGgdVpY2tPd7fRnf01GoJFu3CfCvfIuGYBzcZq7p+/N6p+NvWamOHXwTw5m4 Jh5g== 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=V98N4KFFTGnu5SYXwIpcKyAHtNwzXMX0/pNnBaCO1p8=; b=s42O6eZUmYALkxBYuDsC5hMqiZb2HlbBsB5ma5jDjx5ezSj4EIdrhCaXixPFIYVIh0 SQBYUGX12U9GJMCqJBxGBMkudPAR53S6i5RNSlQJ36M4j9SnQfN+uBT9GPcsVCa8IKX0 ezxT++bWY2QkU3XTErs9FHyliHbq+CK36ySjw0lxd3l9d0OvJi6jcNflKKHft6hAJ1Pl j46SZ6/dT5vnaarT0bMX+Blw7AX1aCecYS5OGx/AyzuV5wy3Tg8pPd6L6biRiwrbqRnY 6qHMQJb/Mt2bOXYJANjbifcbmb5RjLs3lNEG/7z3UmmVDdexAaxRJ7RM735MktQMFtYk 5fRQ== X-Gm-Message-State: AOAM533WLsfoFK8i0P7JNtDJ+kP7EePLcASEwwsvtV1Y8l+xgEWnCGBv K1tEPHWyrnCeuGbRJylVEPTzbMhGHs4= X-Google-Smtp-Source: ABdhPJwiMAijIwUx5tAUYloBYJw+cyjLrzwvfgnCPcgpDunKSurML8bMQd0ZS5FzltngUdGL6k4dTQ== X-Received: by 2002:a5d:59ae:: with SMTP id p14mr13022518wrr.278.1631546366583; Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v17sm7560808wrr.69.2021.09.13.08.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Message-Id: <38eee11baf580adbef406cd776551dda012c8b4b.1631546362.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:15 +0000 Subject: [PATCH v2 04/11] t3407: rename a variable Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood $dotest holds the name of the rebase state directory and was named after the state directory used at the time the test was added. As we no longer use that name rename the variable to reflect its purpose. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 39076ac9462..2c70230a4eb 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -21,35 +21,35 @@ test_expect_success setup ' testrebase() { type=$1 - dotest=$2 + state_dir=$2 test_expect_success "rebase$type --abort" ' # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && - test_path_is_dir "$dotest" && + test_path_is_dir "$state_dir" && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$dotest" + test ! -d "$state_dir" ' test_expect_success "rebase$type --abort after --skip" ' # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && - test_path_is_dir "$dotest" && + test_path_is_dir "$state_dir" && test_must_fail git rebase --skip && test_cmp_rev HEAD main && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$dotest" + test ! -d "$state_dir" ' test_expect_success "rebase$type --abort after --continue" ' # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type main && - test_path_is_dir "$dotest" && + test_path_is_dir "$state_dir" && echo c > a && echo d >> a && git add a && @@ -57,7 +57,7 @@ testrebase() { test_cmp_rev ! HEAD main && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$dotest" + test ! -d "$state_dir" ' test_expect_success "rebase$type --abort does not update reflog" ' From patchwork Mon Sep 13 15:19:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489779 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.7 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,URIBL_BLOCKED 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 2B491C433FE for ; Mon, 13 Sep 2021 15:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10E38610A6 for ; Mon, 13 Sep 2021 15:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236106AbhIMPq6 (ORCPT ); Mon, 13 Sep 2021 11:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244685AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -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 6ED03C0A8894 for ; Mon, 13 Sep 2021 08:19:28 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id m9so15317223wrb.1 for ; Mon, 13 Sep 2021 08:19:28 -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=5NiZ1dey39+kkiAnyp/BnURcm4AUhPyCNBo/a7YNbQM=; b=huHJTJcvMO5LQ1Qy/sNHcnP7gtJXeqTLqiL3fJQD55gZ8PtzbbqhwNz74PBOGj3J4g Inq9Y5yFXedyqAJnmXx8/oJi/RyYzWr+VHPhuxdjuoKUBfXCHi7HBX6QTu5nGavh/eji IGHxZD7vevIRmiEI+1zvLfbP1o/pTVdAW0OrrZ8o0lEP8gfPAKok+fD1LIYhP0ckXEod ehPTZZvtU8L9ViEZcRmKCYipiSJ9UZfnPICLk2j94fsA4WWT9Ioaz4NYul2KkZXl9ip7 6JPbArr/2oFur8MnoLKI/XwBRJNqpsV7lwhdB+d+to2ordJE4FiuXVvFVZj6r2g75ptB bldg== 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=5NiZ1dey39+kkiAnyp/BnURcm4AUhPyCNBo/a7YNbQM=; b=emTp68ZOlEdfJX+dXC3XRLSqlNXSO6Agazcy0kozxFqAEJ8r4KClzuv8xRexEDUYCp z8nSpEEHQ0UTgpMRQKZUV2NTmcMfLJYN432jlQIuIE5BAeJOWyt1DP68Q255sfbVhb1M E8GVZ5TCASqHeFaK2bytVxk7GGTWV/NpxuBcm7AfL6BpFgb5hgkOVD9LgCw1ketzO1su YDLaC1OrcyYEnNrPxCtuQXiSOIge/usRB6sK6x8EZJ138YYN7GXfTyVWCHdyB/xPG/I/ jWi+/T9ofPLUUUTzjV5BAYBtD2NYTL5iGTxe5Ns0UL+ATTka1o/OZmIOr6sVvo+cLnG9 Mhtg== X-Gm-Message-State: AOAM533gJ7iuj7Rbv/XT4NvqfeQtk8n5osrds/Kh17e9fSKzJbs9PSyh +cDaJqtEp1IuK+DLUHOS44R/iUbFEz8= X-Google-Smtp-Source: ABdhPJw3wbJBDWofi4Lrb2QKebsLY6NtTfbrEe19lnuKE4+GqEgix/5e1z93vKhjPyw3HK7hiXBQuw== X-Received: by 2002:adf:8070:: with SMTP id 103mr13050939wrk.74.1631546367113; Mon, 13 Sep 2021 08:19:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l187sm7067617wml.39.2021.09.13.08.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:26 -0700 (PDT) Message-Id: <61a37c89f1e97c00b28daf1ce7a0c4253ecec9fb.1631546362.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:16 +0000 Subject: [PATCH v2 05/11] t3407: use test_path_is_missing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood At the end of the test we expect the state directory to be missing, but the tests only check it is not a directory. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 2c70230a4eb..7eba9ec1619 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -30,7 +30,7 @@ testrebase() { test_path_is_dir "$state_dir" && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$state_dir" + test_path_is_missing "$state_dir" ' test_expect_success "rebase$type --abort after --skip" ' @@ -42,7 +42,7 @@ testrebase() { test_cmp_rev HEAD main && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$state_dir" + test_path_is_missing "$state_dir" ' test_expect_success "rebase$type --abort after --continue" ' @@ -57,7 +57,7 @@ testrebase() { test_cmp_rev ! HEAD main && git rebase --abort && test_cmp_rev to-rebase pre-rebase && - test ! -d "$state_dir" + test_path_is_missing "$state_dir" ' test_expect_success "rebase$type --abort does not update reflog" ' @@ -92,7 +92,7 @@ test_expect_success 'rebase --apply --quit' ' head_before=$(git rev-parse HEAD) && git rebase --quit && test_cmp_rev HEAD $head_before && - test ! -d .git/rebase-apply + test_path_is_missing .git/rebase-apply ' test_expect_success 'rebase --merge --quit' ' @@ -103,7 +103,7 @@ test_expect_success 'rebase --merge --quit' ' head_before=$(git rev-parse HEAD) && git rebase --quit && test_cmp_rev HEAD $head_before && - test ! -d .git/rebase-merge + test_path_is_missing .git/rebase-merge ' test_done From patchwork Mon Sep 13 15:19:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489781 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.7 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,URIBL_BLOCKED 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 C434EC433F5 for ; Mon, 13 Sep 2021 15:45:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A735F610A8 for ; Mon, 13 Sep 2021 15:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241059AbhIMPq7 (ORCPT ); Mon, 13 Sep 2021 11:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244694AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB6CC0A8895 for ; Mon, 13 Sep 2021 08:19:32 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id l18-20020a05600c4f1200b002f8cf606262so7295937wmq.1 for ; Mon, 13 Sep 2021 08:19:32 -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=YJq5Xh/G/r0K+xh06bV/qLGR4+89b3t/Z277xbA+z+o=; b=I32o60pHPRllGLqQE12fAMX4fUsg6xf8gECdL9T/uwSkpmne2zH/g0IH3srhng3K1N xPGMEgxCRvF8XklKNqW3F1W0U2mOuuMwQgX9V/e2txtL6IB+j92up5n3QJJpndhhPZtp OaFymRzjgsSYJV+MxXqyEL/4sC3+ETFSwwVx4gsw/QGdujpIYEMcobo+8K8AqirWHTeg EQ6aJlvHUdgkaGAoSoKgvaLNSwMkUnOOsT4wkTpDVbv03Y39fuMGyNcBiNEL/+Jckw3b JlAli7e7zZRd/7pnr4vOI9EuQB0pulrGorHJQmYZglLP6rMqbqGMWX4PfzZG2zom0dla NK2g== 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=YJq5Xh/G/r0K+xh06bV/qLGR4+89b3t/Z277xbA+z+o=; b=5eavjG1WhoeaH0n3TDv1YlI/NY/kaLQCRORmQk7vYPTaKwGSiSm5Lk1WTVQdP1fgH8 2htPQg+sBvkqt/I8roTiX7WCNrfq9LGjqMEtUkC7yWiLAx+CLfQ818J3dKL1VOE5f/oI 4ir0dc9LglItMlxTUWBIFlaq3+Aad7H8xHQqOA9QcwrLFhEfMNe8spBpsslkdJg2KgIP f5gtCm1LAWRis5yx5QfQsHBtkKATH/RHi1CBPRIjPbss+0JFmr0QGiXWpiApa3+9tV9d 6/nTDSXXe8wZ7bc3EP4F03/4nsx9tKk14CW9Ml00hnzE86hB3KyeP7MBQaN+eLn38PVY 4Myg== X-Gm-Message-State: AOAM5308S1x9nzgP+XsUGOkoAPNryUELbHrTd4Dp06W/7bNlqyva/1as pWL1fmPBwH2t/3OEFjqKWO0V78bpBus= X-Google-Smtp-Source: ABdhPJxOP2z6GRM0+m1Pxs7xsUtMeTqb/+TvpM1pefFvst3PAYVOQQ6bBs8oX5o58LOLO31G6Wr67Q== X-Received: by 2002:a1c:e91a:: with SMTP id q26mr11735918wmc.128.1631546371337; Mon, 13 Sep 2021 08:19:31 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g13sm5651364wmh.20.2021.09.13.08.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:27 -0700 (PDT) Message-Id: <6866630528b24d7629adebea132970241fa0d380.1631546362.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:17 +0000 Subject: [PATCH v2 06/11] t3407: strengthen rebase --abort tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood The existing tests only check that HEAD points to the correct commit after aborting, they do not check that the original branch is checked out. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 7eba9ec1619..f8264449b6c 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -19,6 +19,13 @@ test_expect_success setup ' test_commit "merge should fail on this, too" a e pre-rebase ' +# Check that HEAD is equal to "pre-rebase" and the current branch is +# "to-rebase" +check_head() { + test_cmp_rev HEAD pre-rebase && + test "$(git symbolic-ref HEAD)" = refs/heads/to-rebase +} + testrebase() { type=$1 state_dir=$2 @@ -29,7 +36,7 @@ testrebase() { test_must_fail git rebase$type main && test_path_is_dir "$state_dir" && git rebase --abort && - test_cmp_rev to-rebase pre-rebase && + check_head && test_path_is_missing "$state_dir" ' @@ -41,7 +48,7 @@ testrebase() { test_must_fail git rebase --skip && test_cmp_rev HEAD main && git rebase --abort && - test_cmp_rev to-rebase pre-rebase && + check_head && test_path_is_missing "$state_dir" ' @@ -56,7 +63,7 @@ testrebase() { test_must_fail git rebase --continue && test_cmp_rev ! HEAD main && git rebase --abort && - test_cmp_rev to-rebase pre-rebase && + check_head && test_path_is_missing "$state_dir" ' From patchwork Mon Sep 13 15:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489783 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.7 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,URIBL_BLOCKED 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 972E2C433FE for ; Mon, 13 Sep 2021 15:45:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B86E60F6F for ; Mon, 13 Sep 2021 15:45:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244685AbhIMPrB (ORCPT ); Mon, 13 Sep 2021 11:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245524AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47157C0A8896 for ; Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id d21so7591042wra.12 for ; Mon, 13 Sep 2021 08:19:33 -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=l/Jg8R6yAzj1NDGUukkEEPk+umccBmF3EC0FZvsVKYg=; b=S8tcvt9btxWDSGmXyRTKQp143Ti6vYXo04i9PxrBkzWTGqgQ/NNnrDsiOXzhi4/soR aMadZNVB6gBriZwnM/4hLZ3f0qUyY9y8dcSWd7koEbR55Z/wmR3B8Swl6trkJ28ybnvK nIAKWLtr+9k+MhER+yulCkwP2gX23LkWI5gqPxKpywt6yz2jRSNE+VAQUOF4JYoXz9F8 UwzRvijm3eiFZFKvhLqIG7cjG6D5xv2x5xIhQxY9l48d4mS/MZt0Eo1WIb+RlXg6EXMr /CwJYPF3EwoZ40UqT8MokMbNbXracbdmBCahg62ItBtPFveKCOUdc5QtL4lAP1KviuiW 92qA== 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=l/Jg8R6yAzj1NDGUukkEEPk+umccBmF3EC0FZvsVKYg=; b=nFct5lmz635qF3kJx0L2lg7kyqmxsbYOKwsD3CJkz9pyyWuuTxzRoRlkna0RMMW1S6 xyx7CxD0d7fHtwLZstc5jyG+MBfCpxFlnOkntUc0yCylpiA1Uzu4XKTc/aP+3ciWGk+b dnk1XsYeHEW1lavobSYfoC9soUpqgP1OW51ym2IUpR1HdN1MfIJQBWyzatLG/t2bEA/8 rO4Oz4PQ3TLBJPi8jhtoouMAqdz+WEdrca+GevYPa+XBVkl/3EhT69HCfk79vlrjpU1j kRgka/rwAqqVE11ZvixmDF9ODQZuiDuZu+Lnw+U8zh6Wu0vemsABI8O8v6sTORkZ0LES XrQg== X-Gm-Message-State: AOAM531QqmiEs4DhQbztPKUOdTkPhVkHPnxFDrlg7sQDyezbfE/JCEHD PxyYQWAqwQ+9CNp4S4yb48dxCR+PqqA= X-Google-Smtp-Source: ABdhPJwYqJwt33JAj1KkGr5WsrXZS5bNLK0nxTZFhCgJe+YSY1PuouVp6xgvJMps4tWAVzhy/nAm8w== X-Received: by 2002:adf:9bdb:: with SMTP id e27mr13005869wrc.162.1631546371912; Mon, 13 Sep 2021 08:19:31 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j7sm9656282wrr.27.2021.09.13.08.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:31 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:18 +0000 Subject: [PATCH v2 07/11] t3407: rework rebase --quit tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood 9512177b68 ("rebase: add --quit to cleanup rebase, leave everything else untouched", 2016-11-12) seems to have copied the --abort tests but added two separate tests for the two rebase backends rather than adding a single test into the existing testrebase() function. Signed-off-by: Phillip Wood --- t/t3407-rebase-abort.sh | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index f8264449b6c..162112ba5ea 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -86,31 +86,21 @@ testrebase() { test_must_fail git rebase --abort -v && git rebase --abort ' + + test_expect_success "rebase$type --quit" ' + test_when_finished "git symbolic-ref HEAD refs/heads/to-rebase" && + # Clean up the state from the previous one + git reset --hard pre-rebase && + test_must_fail git rebase$type main && + test_path_is_dir $state_dir && + head_before=$(git rev-parse HEAD) && + git rebase --quit && + test_cmp_rev HEAD $head_before && + test_path_is_missing .git/rebase-apply + ' } testrebase " --apply" .git/rebase-apply testrebase " --merge" .git/rebase-merge -test_expect_success 'rebase --apply --quit' ' - # Clean up the state from the previous one - git reset --hard pre-rebase && - test_must_fail git rebase --apply main && - test_path_is_dir .git/rebase-apply && - head_before=$(git rev-parse HEAD) && - git rebase --quit && - test_cmp_rev HEAD $head_before && - test_path_is_missing .git/rebase-apply -' - -test_expect_success 'rebase --merge --quit' ' - # Clean up the state from the previous one - git reset --hard pre-rebase && - test_must_fail git rebase --merge main && - test_path_is_dir .git/rebase-merge && - head_before=$(git rev-parse HEAD) && - git rebase --quit && - test_cmp_rev HEAD $head_before && - test_path_is_missing .git/rebase-merge -' - test_done From patchwork Mon Sep 13 15:19:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489785 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.7 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,URIBL_BLOCKED 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 B9F33C4332F for ; Mon, 13 Sep 2021 15:45:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BE79610A6 for ; Mon, 13 Sep 2021 15:45:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245317AbhIMPrE (ORCPT ); Mon, 13 Sep 2021 11:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244790AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEADAC0A8897 for ; Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t8so10256526wrq.4 for ; Mon, 13 Sep 2021 08:19:33 -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=e27GD8xkMudz3rHhWiu0IkNP5dF76ybzVTv7XI/D+pQ=; b=HMDB76bBMizIxvYgk4gvqm92C3eq/vFkix6SNhT/Ko/8nJDrv3bp3O/kY8GVVKWLKe cWyfO6+qEywc463jHqVx3Hn5YN8LzuibapqmoxjE5qve22poSrP813lgUKKs7FbjCJyj W7nHWCPPN8frrKVbwDsHBZTo+H5bbzKBESm3q6l+5e/w4nscKmqAFyLgyzZHqvYZVHTR kXxSpyHHuVigHMlEbM4E9caJnw3XosHb8tgFBH8JiVuMQKROTo3nb31cl6+pCo46qZ3/ mDqnyC1zwpOKoynxrna64OIkNNcTUMLpT+/GEVLvNB9EP9NXpP9qVaqTLqFAwJLeD0NX d2Vg== 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=e27GD8xkMudz3rHhWiu0IkNP5dF76ybzVTv7XI/D+pQ=; b=DvjQOZ0ETsy7UXh/Z1sPaWGvk3Lgfs2GRIifFY1qftC+WXftehhLYcDgUEGaLUBkqI nTtjW/FjhaHaZRovegtV0dIPOtsOmXM6vA92oTveahMpgm0BxienXRc9XuOqFnJcvXjD Cdhl10izwX8j3LTJHLyqr6siG4CG3CZaYANrSfIggpBVcsS49m0PWmgzWERqTJn32VQ7 1+MIeucP/msQmvA5KURdh3hyzgvT///QiJW29rPrp1hTL+a8VUNhdiqt27CVisOeQXTj 1p8F1B/JcBiyMk34c4FItizrp+zTpU9/XfWZ1LgdAaavy/+serMVwaAIdlB2GhPcyKnm GW6Q== X-Gm-Message-State: AOAM532l4wfC4TPUCg9Y2l8r/v/kgREaJAEWwa8mQzB8KPIbtu/Z6yIK ZpD97wWVOsbnxmW8J1HcXOWc6+K3xVc= X-Google-Smtp-Source: ABdhPJzTOzDF0LxbPdTJXCG6xzgXP6pNgSV1p24Gb2Wn62Nncr3MzxpTWJP0TlJ3chbHBoQWA7e29Q== X-Received: by 2002:adf:f80e:: with SMTP id s14mr13215819wrp.435.1631546372483; Mon, 13 Sep 2021 08:19:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i5sm6617330wmq.17.2021.09.13.08.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:32 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:19 +0000 Subject: [PATCH v2 08/11] rebase: remove redundant strbuf Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood There is already an strbuf that can be reused for creating messages. msg is not freed if there is an error and there is a logic error where we call strbuf_release(&msg) followed by strbuf_reset(&msg) and strbuf_addf(&msg). Signed-off-by: Phillip Wood --- builtin/rebase.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 6138009d6e4..69a67ab1252 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1299,7 +1299,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) int ret, flags, total_argc, in_progress = 0; int keep_base = 0; int ok_to_skip_pre_rebase = 0; - struct strbuf msg = STRBUF_INIT; struct strbuf revisions = STRBUF_INIT; struct strbuf buf = STRBUF_INIT; struct object_id merge_base; @@ -2063,30 +2062,29 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) printf(_("First, rewinding head to replay your work on top of " "it...\n")); - strbuf_addf(&msg, "%s: checkout %s", + strbuf_reset(&buf); + strbuf_addf(&buf, "%s: checkout %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name); if (reset_head(the_repository, &options.onto->object.oid, "checkout", NULL, RESET_HEAD_DETACH | RESET_ORIG_HEAD | RESET_HEAD_RUN_POST_CHECKOUT_HOOK, - NULL, msg.buf, DEFAULT_REFLOG_ACTION)) + NULL, buf.buf, DEFAULT_REFLOG_ACTION)) die(_("Could not detach HEAD")); - strbuf_release(&msg); /* * If the onto is a proper descendant of the tip of the branch, then * we just fast-forwarded. */ - strbuf_reset(&msg); + strbuf_reset(&buf); if (oideq(&merge_base, &options.orig_head)) { printf(_("Fast-forwarded %s to %s.\n"), branch_name, options.onto_name); - strbuf_addf(&msg, "rebase finished: %s onto %s", + strbuf_addf(&buf, "rebase finished: %s onto %s", options.head_name ? options.head_name : "detached HEAD", oid_to_hex(&options.onto->object.oid)); reset_head(the_repository, NULL, "Fast-forwarded", options.head_name, - RESET_HEAD_REFS_ONLY, "HEAD", msg.buf, + RESET_HEAD_REFS_ONLY, "HEAD", buf.buf, DEFAULT_REFLOG_ACTION); - strbuf_release(&msg); ret = !!finish_rebase(&options); goto cleanup; } From patchwork Mon Sep 13 15:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489787 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.7 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,URIBL_BLOCKED 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 9C470C433FE for ; Mon, 13 Sep 2021 15:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 879D660F6F for ; Mon, 13 Sep 2021 15:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344063AbhIMPrF (ORCPT ); Mon, 13 Sep 2021 11:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245581AbhIMPqm (ORCPT ); Mon, 13 Sep 2021 11:46:42 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60190C0A8899 for ; Mon, 13 Sep 2021 08:19:34 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id g19-20020a1c9d13000000b003075062d4daso273596wme.0 for ; Mon, 13 Sep 2021 08:19:34 -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:mime-version :content-transfer-encoding:fcc:to:cc; bh=zT1wBgFnMRZCsLcFWTrqBz0f8Tr5pzLEPGPlNRXpipY=; b=qeeMed0NALZe8J/TpJe9QSDtiiuXTlIrUfFhJkHfajJab1x9T3ak1HX+pR8F3JqATb 7W/47nmvgzwkidr2cZcoxPJRZ40lsJ3eIX1YCoISXeYh9N6Sekzn+5qVVg/goJaHWwLX 2a5aBciIogPs29aOPny8g+N8RqXeRvyrrtPo3Do93X4lqqdHcGLp325yKdYMm4iYTIal T9xSTPWuzxA1iEqYc7IcLmod2FdVBMXci+b3Y1LlMwO4/91hfGS6nGgRBBsSjnbzfEi4 AkAVa+sARqceWKzkt+b4zNWNDZdFNgCPzTKSB7G5gVOMPR62wtNDNw2wrsluVYpzxL51 8X7Q== 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:mime-version:content-transfer-encoding:fcc:to:cc; bh=zT1wBgFnMRZCsLcFWTrqBz0f8Tr5pzLEPGPlNRXpipY=; b=48ho+FQY/Xej8RjEepLdflduelOZ2lLo7j201MRGg3pUmbLJY2OiFY1LH1UgNHrY0O TaHm9ROPrU3MdHh+LkwXwC8nx6lPIzXShU3whc3OoWad+O9FfY7YC+xYBi9a3EvP3toT SJTDUB7SBnIlkTb+spQf1RohjFUgGvoTgbWPAWcQp/q9M7B13ruU/jUlRmPSwfR91aDS nJYxJg3zKb+rkXAgt56gMvFy1E2hyVGCYpBdlDUnDxvlPbVP/OAZJ+29HdGg18isDkW8 2DhcjYR6l7zDH1CCYck10KZ6k2/gawAWp6N4OOqwCDsw9EUrwMCOAuv79Nv6I/Ax3u8i LsxQ== X-Gm-Message-State: AOAM533Z4YXE2UaAAO9/b5mwC1xYiOa9CAbw0aHKUtZ5zwZrmCaMehH/ mmygHqDkxNSIAynOE74LvEK1HeJjWMo= X-Google-Smtp-Source: ABdhPJynGSFu8ER7mEznN4FddRqrxK2S+L0MA39g4lGJmh2RyfH5t6U5aGGf1BOQia2nn/FsAl3vHQ== X-Received: by 2002:a1c:234a:: with SMTP id j71mr11667759wmj.11.1631546373034; Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k4sm7146484wrv.24.2021.09.13.08.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:32 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:20 +0000 Subject: [PATCH v2 09/11] rebase: use our standard error return value MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Git uses −1 to signal an error. The builtin rebase converts these to +1 all over the place using !! (presumably because the in the scripted version an error was signalled by +1). This is confusing and clutters the code, we only need to convert the value when the function returns. Signed-off-by: Phillip Wood --- builtin/rebase.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 69a67ab1252..7905672d8de 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1573,7 +1573,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) die(_("could not move back to %s"), oid_to_hex(&options.orig_head)); remove_branch_state(the_repository, 0); - ret = !!finish_rebase(&options); + ret = finish_rebase(&options); goto cleanup; } case ACTION_QUIT: { @@ -1582,11 +1582,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct replay_opts replay = REPLAY_OPTS_INIT; replay.action = REPLAY_INTERACTIVE_REBASE; - ret = !!sequencer_remove_state(&replay); + ret = sequencer_remove_state(&replay); } else { strbuf_reset(&buf); strbuf_addstr(&buf, options.state_dir); - ret = !!remove_dir_recursively(&buf, 0); + ret = remove_dir_recursively(&buf, 0); if (ret) error(_("could not remove '%s'"), options.state_dir); @@ -1958,7 +1958,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (require_clean_work_tree(the_repository, "rebase", _("Please commit or stash them."), 1, 1)) { - ret = 1; + ret = -1; goto cleanup; } @@ -1993,7 +1993,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) RESET_HEAD_RUN_POST_CHECKOUT_HOOK, NULL, buf.buf, DEFAULT_REFLOG_ACTION) < 0) { - ret = !!error(_("could not switch to " + ret = error(_("could not switch to " "%s"), options.switch_to); goto cleanup; @@ -2008,7 +2008,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) else printf(_("Current branch %s is up to date.\n"), branch_name); - ret = !!finish_rebase(&options); + ret = finish_rebase(&options); goto cleanup; } else if (!(options.flags & REBASE_NO_QUIET)) ; /* be quiet */ @@ -2085,7 +2085,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) reset_head(the_repository, NULL, "Fast-forwarded", options.head_name, RESET_HEAD_REFS_ONLY, "HEAD", buf.buf, DEFAULT_REFLOG_ACTION); - ret = !!finish_rebase(&options); + ret = finish_rebase(&options); goto cleanup; } @@ -2099,7 +2099,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) options.revisions = revisions.buf; run_rebase: - ret = !!run_specific_rebase(&options, action); + ret = run_specific_rebase(&options, action); cleanup: strbuf_release(&buf); @@ -2110,5 +2110,5 @@ cleanup: free(options.strategy); strbuf_release(&options.git_format_patch_opt); free(squash_onto_name); - return ret; + return !!ret; } From patchwork Mon Sep 13 15:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489791 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.7 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,URIBL_BLOCKED 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 D86A0C433EF for ; Mon, 13 Sep 2021 15:45:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEFAE610A8 for ; Mon, 13 Sep 2021 15:45:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245635AbhIMPrH (ORCPT ); Mon, 13 Sep 2021 11:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244807AbhIMPqn (ORCPT ); Mon, 13 Sep 2021 11:46:43 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED750C0A889B for ; Mon, 13 Sep 2021 08:19:34 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id y132so6944102wmc.1 for ; Mon, 13 Sep 2021 08:19:34 -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=NzPFbNI5mqavLRsRCxjdW4h17gl29AKfsozAHlpo1Wc=; b=VPErcNxtJkWNbaUWEOgODTnt/OnXyfThi+RL7lh8SqsDhGgt/dTkyr9Yd4c08Qx4nu 0XuQi2UTmabg296+UYOXe7adwpqWRqTl5wCM4wusmGJ482by26pPIPEYD7oZCi/Vnh// +5BDrYbc0RY7QozJ5BMWUaZl7KFmZdVZKpQgV9qPEW4CUpeiSOL4RTX3Var8YfWLkDh4 9tU9fAtTUPBQQmkc1LmN5x/u/cWDAVHPYm6AwvrWsLCwBHJMD5CtM0Y+gmDWbBpWpeJP aqPXRhLi2wBNoDdn4dJOvPnYPCT7hpSKYy9eg75ySu6kwLV7kUwZybX8IsMitqHXmZEO Ip9w== 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=NzPFbNI5mqavLRsRCxjdW4h17gl29AKfsozAHlpo1Wc=; b=cMS1XOjYhczDnFrH3fOURLM9picjT/pFkx2Du3ifOEvkS9/ORGQDw1xV+TZgzAR81u ZPWsoJAw/O2He3qx0Tr+r7U/Oo/OJwtVTrb6lXACf2SVRJy/oNeTuPZGMBXaTQRIR82m zkJQ60xBwAQQPGUyB4iEw6UEvQG04g9GhexO59Lp+ELTWudURzmGKDTb0Bm+lWr8+r4b +Y5eOhRNFPlXYa2R2ElwE7bb/oqf+bJ+n1KuM/+YrUes+7A7jUZ1k2LFPE8gvHUUb+DA PELiZ30RxCvzAEAMqxfbC1O8+cJN4MvG6+RiZWPzaX7zudmhqQoohESUSSC9Lh8VWeBg rp3A== X-Gm-Message-State: AOAM5337If1ysgewmWhVFnyln6QFDLa20vC9B9MNPpZnTFP6cURdakWq pM0zaOFaOPuF72ZiOtnHIC676pTqWDM= X-Google-Smtp-Source: ABdhPJxHrVy8uSjWgllGiOsR3nxvtBvrpRuxOuEtcstUIdEi+ryOqXGDC1eST2y8/Ub3bsPC86S61Q== X-Received: by 2002:a05:600c:2298:: with SMTP id 24mr6216056wmf.177.1631546373668; Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j23sm7129556wmo.14.2021.09.13.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:21 +0000 Subject: [PATCH v2 10/11] rebase: use lookup_commit_reference_by_name() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood peel_committish() appears to have been copied from the scripted rebase but it duplicates the functionality of lookup_commit_reference_by_name() so lets use that instead. Signed-off-by: Phillip Wood --- builtin/rebase.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 7905672d8de..74663208468 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -762,17 +762,6 @@ static int finish_rebase(struct rebase_options *opts) return ret; } -static struct commit *peel_committish(const char *name) -{ - struct object *obj; - struct object_id oid; - - if (get_oid(name, &oid)) - return NULL; - obj = parse_object(the_repository, &oid); - return (struct commit *)peel_to_type(name, 0, obj, OBJ_COMMIT); -} - static void add_var(struct strbuf *buf, const char *name, const char *value) { if (!value) @@ -1844,7 +1833,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (!strcmp(options.upstream_name, "-")) options.upstream_name = "@{-1}"; } - options.upstream = peel_committish(options.upstream_name); + options.upstream = + lookup_commit_reference_by_name(options.upstream_name); if (!options.upstream) die(_("invalid upstream '%s'"), options.upstream_name); options.upstream_arg = options.upstream_name; @@ -1887,7 +1877,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) options.onto = lookup_commit_or_die(&merge_base, options.onto_name); } else { - options.onto = peel_committish(options.onto_name); + options.onto = + lookup_commit_reference_by_name(options.onto_name); if (!options.onto) die(_("Does not point to a valid commit '%s'"), options.onto_name); From patchwork Mon Sep 13 15:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12489789 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.7 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,URIBL_BLOCKED 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 CF14CC433F5 for ; Mon, 13 Sep 2021 15:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BBAE8610A6 for ; Mon, 13 Sep 2021 15:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245415AbhIMPrG (ORCPT ); Mon, 13 Sep 2021 11:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245594AbhIMPqn (ORCPT ); Mon, 13 Sep 2021 11:46:43 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17099C0A889C for ; Mon, 13 Sep 2021 08:19:36 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id r128-20020a1c4486000000b003065f0bc631so2622248wma.0 for ; Mon, 13 Sep 2021 08:19:36 -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=ifyGM1bGx9+z5iO0Tty9Ca+lQnQVolwT7KptW3JJAZo=; b=VWh86H9m7SmLvNwEOUnmS0onIrwUseWxLcXLTrjmJ8bXP/J9OXHm3Mnukrr2+3RyMG xfNP4vraWIvXJiqIT0PxjjDIgcsvl2jJNzd8LC57qmujcB1ZQbisWGt2UiEsr8ZPIHEJ DRM07CQX3Y4VBYF7OfJfrKYjEqaxopkmDsmGIS8b/MMk99Vzpf6sUp2yZGj7Dzqt7FAF HwhmIXDwYVyhIk2mhzDDGiZVipsW8oNJptWL7U9WzTVz6UsRrpE5BxHgPKwFGzFyvE6k JLQ7L5GCTx6qupbDRnlVFvXu5Sx06GhotNwWMIET7gPTOp4cF0DLHGeZ0RC9IN9mE3ws +wVQ== 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=ifyGM1bGx9+z5iO0Tty9Ca+lQnQVolwT7KptW3JJAZo=; b=Q2Mvw8Es1alkKQDEdq2YB3BxjY9XGN/uQeLgdfr3f5NYzQw4Wk5W48dqkYkSfvVzOP FlO9qNWlFqvYEbWje76LMe04q6rhWBT1qqnNON5I2sP/tueRCuXzlQm1TowCRVxVXGJP sm2Gx3pVjyp1TU9EGSzzruxeCbWhkbeIez+1DIhPNy9acdqZDXj29nvdCztmFP41yPJO q/4BFbjBb7fUJF2jpZ3HE/d5qJhUoJxaKYK/pVof0py8315EacJVpilYK7WSZHNIWf1f Uiz7RloK48ooLfg0MZ7aNwEkLLHuOHfrSPIE+O0SCm/HNVJBlEcYRm9ZMBsC3QISuFQC SnTQ== X-Gm-Message-State: AOAM5335A6MVyGpimc1lfI7eemAKVB70sTALzE61c/YLlBTJ7nGVYjOD 60rPfPCVcrRAYWFN+DysMaFSS80NaIw= X-Google-Smtp-Source: ABdhPJwl/UlTQLRudHGXSTgoYedTQ/4N4CdlGHbZMxfVkHIIWSYfWQ053fz1YPR9SdkPgS7IsJWEoQ== X-Received: by 2002:a05:600c:21d9:: with SMTP id x25mr5498060wmj.7.1631546374739; Mon, 13 Sep 2021 08:19:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a10sm7844824wrd.51.2021.09.13.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 08:19:33 -0700 (PDT) Message-Id: <951de6bb1992773cda60791c4b7a09867b5e0f19.1631546362.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 13 Sep 2021 15:19:22 +0000 Subject: [PATCH v2 11/11] rebase: dereference tags Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Phillip Wood , Johannes Schindelin , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Aborting a rebase stated with 'git rebase ' should checkout the commit pointed to by . Instead it gives error: update_ref failed for ref 'HEAD': cannot update ref 'HEAD': trying to write non-commit object 710d743b2b9892457fdcc3970f397e6ec07447e0 to branch 'HEAD' This is because when we parse the command line arguments although we check that the tag points to a commit we remember the oid of the tag and try and checkout that object rather than the commit it points to. Fix this by using lookup_commit_reference_by_name() when parsing the command line. Signed-off-by: Phillip Wood --- --- builtin/rebase.c | 14 ++++++++------ t/t3407-rebase-abort.sh | 18 ++++++++++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 74663208468..2b70a196f9a 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1903,13 +1903,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) die_if_checked_out(buf.buf, 1); options.head_name = xstrdup(buf.buf); /* If not is it a valid ref (branch or commit)? */ - } else if (!get_oid(branch_name, &options.orig_head) && - lookup_commit_reference(the_repository, - &options.orig_head)) + } else { + struct commit *commit = + lookup_commit_reference_by_name(branch_name); + if (!commit) + die(_("no such branch/commit '%s'"), + branch_name); + oidcpy(&options.orig_head, &commit->object.oid); options.head_name = NULL; - else - die(_("no such branch/commit '%s'"), - branch_name); + } } else if (argc == 0) { /* Do not need to switch branches, we are already on it. */ options.head_name = diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh index 162112ba5ea..ebbaed147a6 100755 --- a/t/t3407-rebase-abort.sh +++ b/t/t3407-rebase-abort.sh @@ -11,18 +11,18 @@ test_expect_success setup ' test_commit a a a && git branch to-rebase && - test_commit b a b && - test_commit c a c && + test_commit --annotate b a b && + test_commit --annotate c a c && git checkout to-rebase && test_commit "merge should fail on this" a d d && - test_commit "merge should fail on this, too" a e pre-rebase + test_commit --annotate "merge should fail on this, too" a e pre-rebase ' # Check that HEAD is equal to "pre-rebase" and the current branch is # "to-rebase" check_head() { - test_cmp_rev HEAD pre-rebase && + test_cmp_rev HEAD pre-rebase^{commit} && test "$(git symbolic-ref HEAD)" = refs/heads/to-rebase } @@ -67,6 +67,16 @@ testrebase() { test_path_is_missing "$state_dir" ' + test_expect_success "rebase$type --abort when checking out a tag" ' + test_when_finished "git symbolic-ref HEAD refs/heads/to-rebase" && + git reset --hard a -- && + test_must_fail git rebase$type --onto b c pre-rebase && + test_cmp_rev HEAD b^{commit} && + git rebase --abort && + test_cmp_rev HEAD pre-rebase^{commit} && + ! git symbolic-ref HEAD + ' + test_expect_success "rebase$type --abort does not update reflog" ' # Clean up the state from the previous one git reset --hard pre-rebase &&