From patchwork Wed Sep 8 09:49: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: 12480717 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 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 70D09C433FE for ; Wed, 8 Sep 2021 09:49:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FC6161154 for ; Wed, 8 Sep 2021 09:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348552AbhIHJue (ORCPT ); Wed, 8 Sep 2021 05:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347816AbhIHJud (ORCPT ); Wed, 8 Sep 2021 05:50:33 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 258D8C061757 for ; Wed, 8 Sep 2021 02:49:26 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id i3so1232652wmq.3 for ; Wed, 08 Sep 2021 02:49: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=f3REcNjTOgL/exJwrTHqXYD+9bQc4QxwWFu8GeGOGnTtHABsadNmquDWxWwbdyRuW7 fVJ+dwnLBeBM/F/R5D8noOUE0uNjRpqeFK5UnMvNNuCUJ79LkjaaaGzJb7gLs9OWwUST xIhtMSHkMw9WoLfGBAbBi3Xh3TjWvL1GG2UNTzvjj/vK3LqoSU7Wh7eVi0Cj8PkwciaY KCYWM8UVvrUs3K6jEgXn8z4QdF4hSHnxLvsUQyXM68cK8HSMEAfs/eSKBUPTXT/oJyvx bSXBJ71pEqgRuPBq6WnYJ1Xt918kYGdgSeXmttxz4s1Rh/EdoPpzJHvuVzxgLC0B0bas FhYg== 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=EDztBiw0+ZbyfUI/B7a79CljlOr/ZRUEAk2iSYSmG1A=; b=igu3i8U2p4ul1q48b+Cp+Tt4iJzGuAAAccbClzmDCoIJDXZhFYJaJgLDWx+CysX17Q 6cAA1rqtu2Rn/77NApm9ULSiNtXwf2qPx5frCn/wWd5cJ4deXe72V7QOIFlCbQzs1Mi9 lSDOg7WLq6+/008TZz14leso5d+wfROPG/axWXm5c/DnOH9QLBsfnJxA+Yl+yT2WLlrw K0Y5DCGC9x5K6xQkhJAHoiK1dW5nASZ7bWF0hHJYqNTap1HnFZnKJP5KG+WHFtGypp3j 5Qm2oeFbO58XJvAsblE378c3vW+fJN8wDlXcOGMW/YPX9Gs7uvwLJwB5mVzTxibfid4E nlnw== X-Gm-Message-State: AOAM532X6iLLerMVxpMJY8H8Q37uzpin5o+ZuTF7g7JnZclQ1p++/eMe qVk/SeMB1xdvLUuYUb44ODZ9Ley0kqY= X-Google-Smtp-Source: ABdhPJzCS4iz2uk4vDc8lmqLanR++zrCXztPX0HGrA+ZIrJxA3eTbq+sWfhlbTF48EjTSsCqVEso5g== X-Received: by 2002:a05:600c:5c1:: with SMTP id p1mr2538669wmd.151.1631094564748; Wed, 08 Sep 2021 02:49:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i9sm1631176wmi.44.2021.09.08.02.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:24 -0700 (PDT) Message-Id: <0f5992e8caba424e484524252a303a00e108df34.1631094563.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:12 +0000 Subject: [PATCH 01/11] t3407: run tests in $TEST_DIRECTORY Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 Wed Sep 8 09:49: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: 12480719 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 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 8FF56C433EF for ; Wed, 8 Sep 2021 09:49:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C1B461154 for ; Wed, 8 Sep 2021 09:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348638AbhIHJuf (ORCPT ); Wed, 8 Sep 2021 05:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348506AbhIHJue (ORCPT ); Wed, 8 Sep 2021 05:50:34 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD20FC061575 for ; Wed, 8 Sep 2021 02:49:26 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id t18so2415614wrb.0 for ; Wed, 08 Sep 2021 02:49: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=p0m5JRRvBWNSsjgw4lLoIvzOSwIR28AZL2oQVRTGF1YmFurmfCF/YbPHXdBldwVl8N 1WiiZpuwsn7pwBhbuM4WW9JztqykzJB0MmWOmyFSAiv9JuAP9LSL0+zpe9RjL7WuMquB A/HDGU+tPP0nQra97pDBoTMscZk30owhKnZNUQ6qCgWxeNjtpB+PiuFA7GxXuNUCRTju +OgsOuUi8ObOg6+8V8d0qW1OAsAD7wgOG/7bAcowUbpMSiQX7KS/BWjucXYUD2Yyh78J eFmHJVBKWh7qwK5B3YL8NEFq4a3N3dNYE+fB4LvRfDuuMIBwJWlkzrL1lN7aCfnTWhYl hr3w== 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=t3W4T91PcXf6mAaq9OKxsRUF55Y4Pe2co8dAs1cu3f5b4tBCzpnXGytiCWqHjHVy9H qhKWebnNpgiEq7MYDeG1Jghrjmkg2OcoW4CgOSaTbhJlKRzkD73qVV5dRxwRG7vxiWdJ aaiBrQzsqc+BkusUV2RQaHQCVh4jB8hqkQ1ceGWMNwBfuM2Ll3RbXB/fmpjw5oJW10qi r9AqTj2bkynl2b2v5PbSlkaGs9m+wyqCaZsiT2g3BjkRUfzgfplKdfI08h9SCunssWsV G7nvDjMOWA9T5de3Kbv84C38glj+76sqRC2Qy8nWOmTijgBQsSxwujl/pjDB/sdXW6YP hLwg== X-Gm-Message-State: AOAM531OSGmvX424bY51mJRZOX1StOSfMTZ2OkKK/0uJhIbQ11k0KkyD /Fd5pvTLMXOIv9qj5MqOSOXHq0x6V8Y= X-Google-Smtp-Source: ABdhPJzUdu9WBrsRB/M2CNZz3jF1kCLaV4OfpT2LjPXB7nCiwY0Z6+yhtYmrzbUusTLmtAgHN0ue5w== X-Received: by 2002:a5d:4245:: with SMTP id s5mr3082984wrr.237.1631094565280; Wed, 08 Sep 2021 02:49:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c13sm1605322wru.73.2021.09.08.02.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:25 -0700 (PDT) Message-Id: <79b6dec910ecc9ceb61d03e3bbd9919ce457d78e.1631094563.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:13 +0000 Subject: [PATCH 02/11] t3407: use test_commit Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 Wed Sep 8 09:49: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: 12480721 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 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 C6A8AC433FE for ; Wed, 8 Sep 2021 09:49:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8F5461153 for ; Wed, 8 Sep 2021 09:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348733AbhIHJui (ORCPT ); Wed, 8 Sep 2021 05:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348602AbhIHJue (ORCPT ); Wed, 8 Sep 2021 05:50:34 -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 2DD39C061575 for ; Wed, 8 Sep 2021 02:49:27 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id d6so2295790wrc.11 for ; Wed, 08 Sep 2021 02:49: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=ZhjzUEqeBPp7tt1U6Ces1LG4VHNm1+/YJdcF6v8aI9E=; b=YM80FIwZHvwmgR6QEZPpOVfBj/Cbb6/gENhxWcD92chAXUcqFQOa9SAtvHAqXPVHcY 8mjy0wnHr96eJUPBQdLbQhDTw8s6WHSFk3GNGcEZOduCwhrQWThzrYFG7opuawLGmTTP lbVgsodtxyQilJDAfvVHT9MSLW44VfOzVJTpZijBbiVWYBo0zRIXhAW6JZyHSBLunXiu 8ThGTrY2mQGEJSwl68QzptI2s3s09MBEavHaqVoYXkjJvPoUPiYPPINUHZVoIv+2Mc4X k0UbfvdvOenOEmSLYtK64RGveQFvixo+Ly1mGuKWPT8S0nOnny4atIFYRPFSfUXyEeGQ qXRg== 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=ZhjzUEqeBPp7tt1U6Ces1LG4VHNm1+/YJdcF6v8aI9E=; b=f4RI0WuiokDnDNOi4ljC/Fu7IjMVnDD8l182aq77QAbwWhJWvopDpqquQD+AmEtloA skMAD7leq8225AyIx4QhAM5qCUtsvA61ld40jPzwyWUxixunfLXGSW61+ZsebpTV4u/r EUeBwnj/QubVLIa/mJ2DNaAhqbJbrA107qFBNBtV3/DWuoblDuFJJK43vD7LSc0F/BNA 7eOH39r2Me970g1JLgQ394XmnVeU1GWeQstvleqtDtX+aq1HGXEMxJKO12a400xccOJP 6STYuFVMTAkuoka1JbB5ZRyn/Qp2+lk8BhMZE0GqNWqNQ2HdvoxKjvv+MHQ7mBULBNZo GkKQ== X-Gm-Message-State: AOAM533y5Mmos8CXmprdEE6B1NrTaGubCh+Y115bE5Hur198q6hRg1oF G4HLPnCSR7w2osE/UcAUTErz7+tAET4= X-Google-Smtp-Source: ABdhPJyAzrRhhjCTBfNxWOSnmVqnTLN+57ze6zjoyiuB2SrxukhBbfJDV2fUEJCUcuQZoHqOxFY01Q== X-Received: by 2002:adf:e6c9:: with SMTP id y9mr3018289wrm.430.1631094565847; Wed, 08 Sep 2021 02:49:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z17sm1564305wrh.66.2021.09.08.02.49.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:25 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:14 +0000 Subject: [PATCH 03/11] t3407: use test_cmp_rev Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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..8d913d73bad 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 Wed Sep 8 09:49: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: 12480723 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 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 982F5C433F5 for ; Wed, 8 Sep 2021 09:49:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BAB361139 for ; Wed, 8 Sep 2021 09:49:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349637AbhIHJuk (ORCPT ); Wed, 8 Sep 2021 05:50:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347816AbhIHJuf (ORCPT ); Wed, 8 Sep 2021 05:50:35 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B09CEC061757 for ; Wed, 8 Sep 2021 02:49:27 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id d6so2295820wrc.11 for ; Wed, 08 Sep 2021 02:49: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=EPek7zPE71UPQnRcrHy4dEprcD4wlseTed/S+Am4RYg=; b=Bs4amrTQ4CUeN0UAJBCQwiZKpd8QBKV8+Gn2WPQKwHSMyEVu1mhKGKZo6Pxgmiucci +3nGK9H85McuG0HHFVuDHxYjPtnx3rveOdGjCWUepw1uDnZqaXDyodSQsz4eDk/5SWB3 3++4tBnLvLidilOKjeXJTnFu9goF6W8YPcChlL0uVDy/4NAYR5CzeU25zMTO0+qqc8y7 KXrYbZa65UGfS63YxeqIPDTXpLoVaN1yTWE5DOK33yJzZefcB+7s3ARviuEkWzugRdEf c6osQc38kAa/+ydm2fPzOSmwWZwHe1JF+M/4X3dTw+xcrRfwyGnQx5xUku4ztHO2SV+Q vrIg== 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=EPek7zPE71UPQnRcrHy4dEprcD4wlseTed/S+Am4RYg=; b=Bzap7wPmuVwnKzl9bd0F/wPi9ZZvmAheNBHuSoI8S9/8Z/+1kwbKEuSMmDjIqcOm3S 2DHjHVJYBOvk5gYIRWH/kwbBnOHT7wn3CU8mNqRN0lUUW2K/mU5Vbgu/xcJRjreiBwuT XnBN7GOqTDmDpzyjh2gdl0fVSLD8Q5mCuse6Xqo8F5O0EBWO8V1ijUOQVwwxOVudsofq h9zFMusJYv5aTeJi2FpD2sx5n7dzBa2Eg2YbxmyYeQ7MOsnL74MRwdJ1NPxBOoq3X/mb SAGsvufEiZvyEvKBKDIdevVS+uzSoqonWoK/KZv9vIwvRWtq/fyx2pxVbhhmFR6N1vAL 9ncw== X-Gm-Message-State: AOAM532YKAzEpr/2hzYDexp+udY5pFp0p9B5V8bpEIvnFvjWVJywJIRM og+8/PTeyjPglShDFhp4G+gMVYNpQm4= X-Google-Smtp-Source: ABdhPJy7jq0VAru7kphRy6megvJ02iyirfSzxcEIfNfIrIDWwY0Xyh2tDX1WMIlaALZROndw0UCx3g== X-Received: by 2002:a05:6000:374:: with SMTP id f20mr2982348wrf.129.1631094566342; Wed, 08 Sep 2021 02:49:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i4sm1768983wmd.5.2021.09.08.02.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:26 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:15 +0000 Subject: [PATCH 04/11] t3407: rename a variable Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 8d913d73bad..d36a3f2758b 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 Wed Sep 8 09:49: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: 12480727 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 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 C890CC433F5 for ; Wed, 8 Sep 2021 09:49:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA24F61139 for ; Wed, 8 Sep 2021 09:49:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351278AbhIHJuq (ORCPT ); Wed, 8 Sep 2021 05:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348657AbhIHJug (ORCPT ); Wed, 8 Sep 2021 05:50:36 -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 58951C061575 for ; Wed, 8 Sep 2021 02:49:28 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id u15-20020a05600c19cf00b002f6445b8f55so1066547wmq.0 for ; Wed, 08 Sep 2021 02:49: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=Ee4k5bVEDCDcLzkDmF80K5D0JVWDg2Ihfroij4uub/Q=; b=e+4NmAB3Md1DHHoI4c/nOCPX5FRJJAzHr/kjdfsIdQm3XbBB8D8VUNbpQ9tYomIvzH OSZ91uvF4SXj9y8j00IA+N5x3mQS50Ew85tI3CxX6Pdv1z6f38yYTj4UC8WHJEzAALYm SZR6rVzhpE/8RckhZesM1HKssbdJO7TBnqop/PmA5g7twTWFvKbWSvR8R55fxFsBUirL c4uhfQaGGYROvCwno4mSkRKOPTP/6MAcnNAU2cXYsxX+UJ5ywKzMHkMfEjVVb5/Lap1r lsqFewl1ChyX2ciZqOkHfHMOtoZ+qDVRpCUtQaPz5he/Pl/BLATSGwiNwG47DK8N+5RM vZ9w== 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=Ee4k5bVEDCDcLzkDmF80K5D0JVWDg2Ihfroij4uub/Q=; b=WUwjPgpbyQ1W8qTdp7JDDCYZwV2zaE8iwlNoi0dVLgKLvhHICto4N7DKrDaV1jFyzE BATeRD6FNDa1fIvxcmfx9xXo8RP5zigvsU4o+sPUGAkoKXI8LuIFoWx8fuHWu03VMFAi D8YVuAiDT9G9P7sggHLJXhbKvpKVwvZoRLQjthcJKEtF063pKJWi72mnoAFcKewDDnkW J/cOz2YARZgTwxrnwb63DRB4OC+nKBNVo24+wgYQanrnBDExavCC60+7IISSED/ABgxi CTv0V4zsAr98B63Pdwn/fn8tvV0ytatAF6Y2HJvlQIs14YCvEHv8sAc0qDTzDZtkcedP HuAg== X-Gm-Message-State: AOAM533gjoQ26CGStX81yivxYJdQntCEL78RPdQxGOF4fuIx3HD4KiH6 DssPomNnTYITC5LF3jEB0LcDIxO2UxA= X-Google-Smtp-Source: ABdhPJweWqswm4IfJwPUMdy0RQXH719IMqIZOP6H/KcwAgzK33+y+IdmnnvZGXfDlMvhIAEr+/rdwg== X-Received: by 2002:a1c:a713:: with SMTP id q19mr528468wme.42.1631094566942; Wed, 08 Sep 2021 02:49:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c2sm1631391wrs.60.2021.09.08.02.49.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:26 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:16 +0000 Subject: [PATCH 05/11] t3407: use test_path_is_missing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 d36a3f2758b..624d2ee3fa4 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 Wed Sep 8 09:49: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: 12480725 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 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 D2991C433F5 for ; Wed, 8 Sep 2021 09:49:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD3CA61153 for ; Wed, 8 Sep 2021 09:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350250AbhIHJum (ORCPT ); Wed, 8 Sep 2021 05:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348506AbhIHJug (ORCPT ); Wed, 8 Sep 2021 05:50:36 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2803C06175F for ; Wed, 8 Sep 2021 02:49:28 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so1037214wml.3 for ; Wed, 08 Sep 2021 02:49: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=yt8R3/UWqtUM7CQB1VKV8KNf4gJG872khhd+8FEB2U8=; b=W+6HefLHdnaBbRc3gKkmuOUWdzpRPB5sYyaZMtEHJUxyOUL0UP5PNEDcO3BLPU+D2X uucuAedvPVbpKQRvyvs2f07KL2/WmOAd7qcX263G+xKjmVpBec5KStjuXjxsITicrzKw 76DywAy+n5kOwhOwBmwbtU2pG3UY2gbgQJuIbcXKvwcXC/dG87xACQoO12bRIV8zxF8c 68VaEpBGILyJfiE8zQKNDuYXg/ggEY1MkQjvUnlIT4fHE8kS7Gy55m2Pv22/0qxYwWf8 BtCxr89+GI2FDd53FzEAVCriP4TZOYM1CstG1xx4NDLAq3ZPO9sYEUZ2Kq1rCs7nUAew RIRw== 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=yt8R3/UWqtUM7CQB1VKV8KNf4gJG872khhd+8FEB2U8=; b=O3R7Ibg6jRaGBqCw9SnfzNyjtlJp947Pt9v9vuELD6onCIqaBxciWdBATXcDNz19gt rk/Q1cKoxBxaE7+4BMveax8vIAeuEdyPKFyZeo2vDq6nL0i6fXfoIYcw6c08Xcx3VcRx eRn3hbpivxoDkD6l/wUmR1391jVB/0DIacaUcuWMdQPFCxg8JoYKnotFGJWs1PBpnxp6 fztoLJcmrWiFwVZFofnJimSy+yoBnighP3V++EXWdIjseK/EIPDERT93K1IJclY9NV8Q ToXvQzu530XsZ3r5+CMEVVlO5JWuH8IQYNTbTV8iDVJnd9kpWq8Xkanett7oUQtUGtiI VPVg== X-Gm-Message-State: AOAM533R3tgkXNzWBtwByPhBDrpHbKTdeVTB6PlKKOtqX4xsoZQfkdrn Zs9kXbBxjv1NLpk+8S6uvn5oxc/XORM= X-Google-Smtp-Source: ABdhPJzYTLVU98/Dy4QLeJc5A+R4Y1/QRFeCQGFAFX4ywklJot3pAd23/l5k9Vm9BNzfIUnFBOX0Zg== X-Received: by 2002:a1c:e915:: with SMTP id q21mr45653wmc.180.1631094567434; Wed, 08 Sep 2021 02:49:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z1sm1512368wmi.34.2021.09.08.02.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:27 -0700 (PDT) Message-Id: <87d7e9bf2d4537ddbdec8c8fa67190e81a426312.1631094563.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:17 +0000 Subject: [PATCH 06/11] t3407: strengthen rebase --abort tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 624d2ee3fa4..72cf391156d 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 Wed Sep 8 09:49: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: 12480729 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 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 8BD9BC433EF for ; Wed, 8 Sep 2021 09:49:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71B1761139 for ; Wed, 8 Sep 2021 09:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348617AbhIHJut (ORCPT ); Wed, 8 Sep 2021 05:50:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348690AbhIHJuh (ORCPT ); Wed, 8 Sep 2021 05:50:37 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 635F2C0613C1 for ; Wed, 8 Sep 2021 02:49:29 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id i28so2363595wrb.2 for ; Wed, 08 Sep 2021 02:49:29 -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=yIIElqaT75bZtC0UsPDOwcoFCgp4lVNvJa3bkYmTH/w=; b=nUSLntqp6LFKjy6AJd9AvhZQfQ1k7mTBQpjRPpeedpKZRI/q82gYn/FZohL195xUFR MrWYjM/y9/u/RI68IL3TBgxElXckeq5dI1Gwb8c/Lzk7sYNYRlsB6cG2myDVoQp8FcR/ YqcjoaY0NVzyBnXqsMwXiuGiSe2w/UMsGamglKeaMvVEYxYSmBoIoZcF7tuVBx7nxNwV 6naU9+3bIdqeRYeh4xEoKRSPZm8DxPM2VlQZ0kUGqoG+i4jHNCwDpC+ih1IrpD+Gc50n WkEtJtKocLwP76z0V5bpQA9dOiC5oXEShdowZTrBHDu+Gu+BDrSQJ5hihK08AMGZXD20 KAOQ== 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=yIIElqaT75bZtC0UsPDOwcoFCgp4lVNvJa3bkYmTH/w=; b=StFgZhWmbysWHp4A9aO5B7K4BnfSm8ym/7W1vx6qTncnXkbY5hje91j3JlAhMbhxk1 F5EKH45po/Bkcq82m/vw1vAaudy756G43JOArTGRnzKszDZwf5so5tOaCJvZcnxVoPPo s9aPFqabG/8Og8GR5XDB3Y19xZQMGL9YsdxsgL0NbREYjuKRCUEeF8aTbx0ssAVGFkd/ StnXWESWHjWbADYh1/lxdw7gUMeEIDmB2x+g9Ft/tmSfjp2Sbi9r6BQhGeh8SVMhYWYE xZMmUew9LpP0czSqPhbrrQ8t74cCaO+02YrgqbZDgMIjNGe9YBIjPOrCsuCaB6KcYEL1 Htvw== X-Gm-Message-State: AOAM532a60QeLJZSoeZMwE5LkbFA3+IgnG8l6KDk5UiObtou9Ndfj8Zt FFc7gAWnLfEHBennzPufr9tdLdFz62o= X-Google-Smtp-Source: ABdhPJwSkYyv67AuxpAhr9NyIIrkIhGXc0Uqg7jrFnglSZ5phpFRPwJMp4ll4RBQ7Fk2o4MsAgK9lQ== X-Received: by 2002:adf:c785:: with SMTP id l5mr3007103wrg.360.1631094567989; Wed, 08 Sep 2021 02:49:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n3sm1586505wmi.0.2021.09.08.02.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:27 -0700 (PDT) Message-Id: <9a4f6ea73c5e9052c7105b0fc63c6d76c0d3e92e.1631094563.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:18 +0000 Subject: [PATCH 07/11] t3407: rework rebase --quit tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 72cf391156d..2f41b06e028 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 Wed Sep 8 09:49: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: 12480731 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 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 9F0A0C433EF for ; Wed, 8 Sep 2021 09:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8645B61153 for ; Wed, 8 Sep 2021 09:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350239AbhIHJuv (ORCPT ); Wed, 8 Sep 2021 05:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348741AbhIHJui (ORCPT ); Wed, 8 Sep 2021 05:50:38 -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 D208BC0613CF for ; Wed, 8 Sep 2021 02:49:29 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 192-20020a1c04c9000000b002f7a4ab0a49so880044wme.0 for ; Wed, 08 Sep 2021 02:49:29 -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=4JiF5aUr7lHwrDLZ/aDrCns+OORVJQykve1EOZCFWhs=; b=bzadVsZ8/A2S4ED5amTxRc3wZdlLr0V4IFNfCK+WZx/oU6vrBV8D5ypCws9Zio+5Zq M3qqo8PVwwUppQXJH2R0o79Zu6YjsyA+othDRQXjAm+qYYSLI46G5xAT1yaaxHBYKBZX 22xovetrRSfGHxyl132vs3WG+8yuMoB0urOvkAddvIwCexuXMM5UV3iERvVockWagJtF B17XwQiLuAJOnAt7OziwEKwyJcKcZt+CqFK/QCI1V5TdQeIOz+KbTR1QDO7NYMrrjPwZ vFhO1H9VbaYV1admP2CPeW0+1Pg3LE8uD9BZVpbpL9h/eoaiciR18Vhyfjg3qBlUhWXz FI4g== 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=4JiF5aUr7lHwrDLZ/aDrCns+OORVJQykve1EOZCFWhs=; b=UOu/VWEY5X3opu0rI3S0blU7iS8mxh+jeSbLehAyFcjCdAIE93wIgW0MbF1zdv8kj9 iLkf4xejyeAuX+/Q9mk6u/I+PBgOD2WokJaeFo2YvyhQTzUp1xWQMdXeyFHzmr/m2jaw CJGzuTVwY+baGpM68d24ytIR56Lcue7+nLGH76EFO1Dw76aJYX3+rnv7Uz5WG4+xevJp 4UoA5EEj9FoU/May4f/8bzH8Et6qYhzYijuP+iquRpOw/jMTDdw7XgRtEJpXyxZxfGGX umSx0cChnsjx+0lIzNPE1ayMeUATus0MleyBt4xEY31NoDs+B/6c+FkmVIM0iPZM1nSY kefw== X-Gm-Message-State: AOAM533fhgg2A0/PP1ybJsvxspVMD0s9wCATltzqy4FFoGjeF0lKCYlR 3JCAe1Cvj5zgtwD8xtkxIAH/rNZvmvQ= X-Google-Smtp-Source: ABdhPJzRfUj39r9GkSuOrygkrC8Ae3fI1PK/BcyycxgyPVpJ9G9Qch02Yh1DzxnlAp4dp8K4Pct/eA== X-Received: by 2002:a1c:4e14:: with SMTP id g20mr1292789wmh.64.1631094568531; Wed, 08 Sep 2021 02:49:28 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s205sm1583986wme.4.2021.09.08.02.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:28 -0700 (PDT) Message-Id: <35b6c26c8f934e3bac984014a59c095c15416c79.1631094563.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:19 +0000 Subject: [PATCH 08/11] rebase: remove redundant strbuf Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 33e09619005..48ab7d9ae3b 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 Wed Sep 8 09:49: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: 12480733 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 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 DD117C433F5 for ; Wed, 8 Sep 2021 09:49:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B78F161139 for ; Wed, 8 Sep 2021 09:49:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351111AbhIHJu5 (ORCPT ); Wed, 8 Sep 2021 05:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348951AbhIHJuj (ORCPT ); Wed, 8 Sep 2021 05:50:39 -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 76A0DC0617A8 for ; Wed, 8 Sep 2021 02:49:30 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id c8-20020a7bc008000000b002e6e462e95fso1086364wmb.2 for ; Wed, 08 Sep 2021 02:49:30 -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=bWPhQXgHi9Ug5njzCVgWdfnwNqZP6vAfKFv1PzIYfSc=; b=oCZgEaBHmlq3VAiRVbfn7lgleaF5LipHaVnfomueqHT7VOC9OWqSppntOFYYhzwRxe 9FOX8a3U/p0DP1ogzGevdVYsWgvx0fygM5z2ov53C2OsITZ4oyiR066tVtfuEF1KjhuK EkZ25PScA6yJSU4XtA2fgqfDeaxKuDlKlEC74lLMDr+bXiw2BwVB1Qv8iwUfnbdrXpJ8 FkuEpGiFjZRnc96gqEd+caVX9rBfZSkM+xrybq6mzvulKegpVfmJPbjwLQHgbMxhZ023 HOsffFakFHn1dFYLN4kcVKKlwzoKsomAuzBXCY/WYfYV1XA1GQAY7XWIIh7XxZi75vzI OEmA== 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:mime-version:content-transfer-encoding:fcc:to:cc; bh=bWPhQXgHi9Ug5njzCVgWdfnwNqZP6vAfKFv1PzIYfSc=; b=QNscd6Fu80gwtzfBBdhFaz2dxj61KHc17QbbCfxEOezGKduFj/WCKpXqDaEpMuuRxQ ZBenvSmYctVj8Py9ent0rr2Mrx12NdvlA6R1Zv3A8k7wTEQw4d2Kg0Yjk5FvfrQr/QqI dCwL8YzQ2+Izpu31VEgGF1T02LDteEjxu1yGqqCHLjX7tTINTv0bbk16pASXde61qcyU X2XYXfAjAMZL/pf82MV5E6Zcw+2jFOMiRVSexHqdcuKoym7qKR1EBUoO2DKT4bD/x+bb 8mUpBdTNeCXwKiKuun6ICTGDLn6EJls3LNAkszYQc3V65xQcLKnGBh71bpciIrer9CsF P3Tg== X-Gm-Message-State: AOAM530P9Bpgq0ZTfOaMeaW5K1G1eO4cGSrXIzy9mR+iLy2PgAZGnnOj HH2PDHrIcxtEVuCm0IABC4ft3+1IOb0= X-Google-Smtp-Source: ABdhPJw793ovxXFl6wFVKfYNcqJcb35eNiyGAtxd2hv3PiH02x1m89G6IPkNizXvpf/bBESIsne9rg== X-Received: by 2002:a1c:7403:: with SMTP id p3mr2725565wmc.72.1631094569059; Wed, 08 Sep 2021 02:49:29 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k16sm1626555wrd.47.2021.09.08.02.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:28 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:20 +0000 Subject: [PATCH 09/11] rebase: use our standard error return value MIME-Version: 1.0 Fcc: Sent To: git@vger.kernel.org Cc: 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 48ab7d9ae3b..e8c3c77bab0 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 Wed Sep 8 09:49: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: 12480737 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 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 3543AC433F5 for ; Wed, 8 Sep 2021 09:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E8DF61102 for ; Wed, 8 Sep 2021 09:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351208AbhIHJvC (ORCPT ); Wed, 8 Sep 2021 05:51:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349291AbhIHJuj (ORCPT ); Wed, 8 Sep 2021 05:50:39 -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 EC6F1C0617AE for ; Wed, 8 Sep 2021 02:49:30 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id n7-20020a05600c3b8700b002f8ca941d89so1042435wms.2 for ; Wed, 08 Sep 2021 02:49:30 -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=5yx1dMb0hK9A0DBcrgI3wIjtDeekFCHuqBloKxfazTQ=; b=puqeDv7OPw4NHFlWabUbK7qZ74OwS8qX/3grRTKDOevWG8O2OQFPhlLoBaaSgSSpFW w5WkmDWNRD5G52fcDfPYod1Axd38PDHAQwQ62L0K5/LC7AbzWm2c8SK12xJDvEMHkiwm DDyLZqTwGMojVIoZiAGyeBahlpvVt8ng93RoF2FRfEb0RWYqyVizqAsN2QaRnK7ZhVKa 8i88vDbIrPQuaoYb7GP2AXMlfd+1F/fXYq8oL7mjOfatKAyOpA9mQsS0uMNHgGRbJecA YWQsk8KSZQ8lS+Nwro7DS20daUFmHoRqQvBjYpC0e7yGp3zNktCcKPZ5Tj6eUkJSUNDz d4AQ== 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=5yx1dMb0hK9A0DBcrgI3wIjtDeekFCHuqBloKxfazTQ=; b=COA6mRpz6hnaUO6G+ZWyY7QetNbG6QOVoCP8aojPfLTzaVdhMOlMX0D/DdR4VOJcH9 y+ZcFo2dGuG0aGiqUa3kK5DKox0DvhTGeParFyWe//BvZNnRjFnsRHXEjleekKcUoJGo E/q9K57pHzPHpxp8eaWwcH/ltNYNz/ZZ8V8JiVlLYZmBm5Rp2EH5Bnv0SvgnUxfKG8YR BUtsivET4sbsWU2dhu1LFLHuBKNIuxTX7/Hdt9UpMpONRaezSdQ8j+MrEQn0m5/nqFk2 ITplq4xc68TSz0IxJElpOBJ4GmCRw0abxWj7YSbuS0imZgCI8Yl/GrSTqNrhts7qWcWU 0gxA== X-Gm-Message-State: AOAM5334UN07nRBeGxT3aE3eBUeKwpVOdAi+chcVSQvGcy3o/0LRvNDv WtKA9+p/2H1eD/tLXGm7WrR8xFuDErg= X-Google-Smtp-Source: ABdhPJwpKXcwN+lAjFNtaXyeNjR3DRbJSdHQAlh57ClUMgKMwbXfHxRyLjPxU8XHyernS8/2vypNBQ== X-Received: by 2002:a7b:c387:: with SMTP id s7mr2717162wmj.26.1631094569624; Wed, 08 Sep 2021 02:49:29 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n18sm1516797wmc.22.2021.09.08.02.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:29 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:21 +0000 Subject: [PATCH 10/11] rebase: use lookup_commit_reference_by_name() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 e8c3c77bab0..93fcc0df2ad 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 Wed Sep 8 09:49: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: 12480735 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 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 37C52C433EF for ; Wed, 8 Sep 2021 09:49:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D1AC61102 for ; Wed, 8 Sep 2021 09:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348820AbhIHJvB (ORCPT ); Wed, 8 Sep 2021 05:51:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349618AbhIHJuk (ORCPT ); Wed, 8 Sep 2021 05:50:40 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 905E1C0613A3 for ; Wed, 8 Sep 2021 02:49:31 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id g16so2353407wrb.3 for ; Wed, 08 Sep 2021 02:49:31 -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=IAn3gxCR2OOhHnqKRU34JUQfN7cZYMLTrJ/pUFwl634=; b=i5mbjkqdaS4UXoQQD9vajntki2//kscBguydepQU8RnswcfKI+TAzY7HDobtQ8+MdB 6GZUmJOFxAfH9ZMYUN7gLM5DIHemUw9sxC9TxsZEtpGYO1uPkLjQLwv7TwPZMQIyT9nF tL6WJHfclh1vWiWdW1IPqL/1qSlYI6dh2zo0CUMJ2TWFzZCRQig05HDeYjEnAmksHiKQ fkDcROxeDTMaeswP2RGxJ1U5FieOJa0tPOo3kL3b04zrZbfKBiQ8dJ1Wajfwx8PxCHdi 7OofduaNdro3qmC/RJ+n4OwDHYsRNTOAA2wLlK8ZzgIMSWmzcvhtz0i22+IhNK/GFaRR Du1w== 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=IAn3gxCR2OOhHnqKRU34JUQfN7cZYMLTrJ/pUFwl634=; b=S51jke+GJDYBu1yPhhL5mzUzNk0TG4zJ32Iupsn41ksgtpDYF4eTAkHtUcHUoXMFOZ gKcEXoCoc18lMmGZqaExXrFoe0kK8ibiumP6r8mD9zvbWId4SoJm/i4ROj6QWreaHzjq C/Ixm4bHeJWMobO+V7kGMyHF/7YP5xpVx13te8q44qOMTDNhiwXnzBIVGwc65PRDLKE9 VOVoySjFAGTjnX8+vF42s4BBco9gr65T8MmZnGfxsDzyFPy8UeUZwMu8FrerDjUBORJl nie1bURmN/U5Af3WKcA0GG10xcV8aDIIeiXFjDG81hUTOiYDhbVgT+ozF76OCcvPhBEs 2zvw== X-Gm-Message-State: AOAM531UX0oI4cH9PQUYNEtXIe586FWLuIZhItNInNmHQltUnUJz6QkJ m0FjIqjJXl4ag9bnFPKzAZHi64PU0f4= X-Google-Smtp-Source: ABdhPJyxeuwq56MkP+OtMsFKbWOzjw0CRm5JCwir/4dNS3pslbz4XwyzJTCooK4gHTSKz98Buf84Pg== X-Received: by 2002:adf:c3c9:: with SMTP id d9mr2988242wrg.339.1631094570127; Wed, 08 Sep 2021 02:49:30 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c4sm1909256wme.14.2021.09.08.02.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 02:49:29 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 08 Sep 2021 09:49:22 +0000 Subject: [PATCH 11/11] rebase: dereference tags Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: 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 | 18 +++++++++++------- t/t3407-rebase-abort.sh | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 93fcc0df2ad..8bf7660a24b 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1903,13 +1903,17 @@ 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)) - options.head_name = NULL; - else - die(_("fatal: no such branch/commit '%s'"), - branch_name); + } else { + struct commit *commit = + lookup_commit_reference_by_name(branch_name); + if (commit) { + oidcpy(&options.orig_head, &commit->object.oid); + options.head_name = NULL; + } else { + die(_("fatal: 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 2f41b06e028..310cd0c736c 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 &&