From patchwork Thu Jun 17 16:17:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12328817 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 B0469C49361 for ; Thu, 17 Jun 2021 16:18:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79FD361185 for ; Thu, 17 Jun 2021 16:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbhFQQUL (ORCPT ); Thu, 17 Jun 2021 12:20:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233010AbhFQQTY (ORCPT ); Thu, 17 Jun 2021 12:19:24 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C545C061574 for ; Thu, 17 Jun 2021 09:17:15 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id s23so7082157oiw.9 for ; Thu, 17 Jun 2021 09:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c24Ox0/bSsimtusx1FwnsjZ6u0xEkq52lZzV9m3iDis=; b=Ejgo+mjnEq5dF/FtHIqqWbhf3HMAd1Flh307pmra76raMhwaIlrhLdzbmbu28IeNga f77v1CkkGuOIH5uAUUrVOPqDq5gaBYVIZTu3PreLyAD72TecvD+XlbYcMSFlKeaF3jB8 xIk9np27QfTQAXyI9Ejn1FSpU2UAiyyH8l3hMRGAKhbz1GOzMmIhg/NxtH36vMB3z6KD 3ukCRHsS4Ire6RrGL1mp4n7poT9PoyF+MkmxgKkrH75W+IGhju958vg9OWxpDfrPKsqX 5KNFw8sheCPxkk6fFxbuT+4dwr+DsnomNea7+dD896SC1EkoDwtj8lbFJ3461muys2/L GWwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c24Ox0/bSsimtusx1FwnsjZ6u0xEkq52lZzV9m3iDis=; b=LSa3R7rqTXYbJdDTiqK9g8XZgqL/Y/s9PqMwkIi6vZpCvHwHncBGFnxTlYgb98lxQh EO6181gy3jYP2EiI1ksdNVQYye3Bv3hunFUpItQhNamLK+rTyFjiRzh3raksyLTFmkj6 BX6TrkhS1r/I6MKHS2Ub/CUG8NCmFZiurUTz3VJffPEhQHT+vG/bN9xsz/WsueKnxuix bX4LL3eknqrTtbMZITrlVS6KNpbV0OPniuUhRKKRHKYyezbPzDsJ7A0fwM+lMAbqGQea C+lLVMvjweDPFuq7hI5IIiWu2uoDtc1NmRr3AM6FLG66nNowXVW4RAy/f93HtkQgutl6 wClA== X-Gm-Message-State: AOAM533UhWIyk9qnh8BcVM9janqU7pfDW4MYG2p/XLIDUdUmR2Z/vBuU ONEFN1upET94KteHjk9Y+UDgU/uRpmaYqw== X-Google-Smtp-Source: ABdhPJyU0Ygvi1uNJn/mdXhj+43q2EL5c+s4N4TS/EPDtdo/2iHwmxkNEc6WKH2iEpnFcbkMrlhLBA== X-Received: by 2002:aca:b145:: with SMTP id a66mr3853508oif.177.1623946634314; Thu, 17 Jun 2021 09:17:14 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id h1sm1377072otq.59.2021.06.17.09.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 09:17:13 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Elijah Newren , Felipe Contreras Subject: [PATCH v2 1/3] pull: cleanup autostash check Date: Thu, 17 Jun 2021 11:17:08 -0500 Message-Id: <20210617161710.81730-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617161710.81730-1-felipe.contreras@gmail.com> References: <20210613045949.255090-1-felipe.contreras@gmail.com> <20210617161710.81730-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently "git pull --rebase" takes a shortcut in the case a fast-forward merge is possible; run_merge() is called with --ff-only. However, "git merge" didn't have an --autostash option, so, when "git pull --rebase --autostash" was called *and* the fast-forward merge shortcut was taken, then the pull failed. This was fixed in commit f15e7cf5cc (pull: ff --rebase --autostash works in dirty repo, 2017-06-01) by simply skipping the fast-forward merge shortcut. Later on "git merge" learned the --autostash option [a03b55530a (merge: teach --autostash option, 2020-04-07)], and so did "git pull" [d9f15d37f1 (pull: pass --autostash to merge, 2020-04-07)]. Therefore it's not necessary to skip the fast-forward merge shortcut anymore when called with --rebase --autostash. Let's always take the fast-forward merge shortcut by essentially reverting f15e7cf5cc. Signed-off-by: Felipe Contreras --- builtin/pull.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e8927fc2ff..a22293b7db 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -947,7 +947,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) struct oid_array merge_heads = OID_ARRAY_INIT; struct object_id orig_head, curr_head; struct object_id rebase_fork_point; - int autostash; int rebase_unspecified = 0; int can_ff; @@ -982,8 +981,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (get_oid("HEAD", &orig_head)) oidclr(&orig_head); - autostash = config_autostash; if (opt_rebase) { + int autostash = config_autostash; if (opt_autostash != -1) autostash = opt_autostash; @@ -1065,13 +1064,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && submodule_touches_in_range(the_repository, &upstream, &curr_head)) die(_("cannot rebase with locally recorded submodule modifications")); - if (!autostash) { - if (can_ff) { - /* we can fast-forward this without invoking rebase */ - opt_ff = "--ff-only"; - ran_ff = 1; - ret = run_merge(); - } + + if (can_ff) { + /* we can fast-forward this without invoking rebase */ + opt_ff = "--ff-only"; + ran_ff = 1; + ret = run_merge(); } if (!ran_ff) ret = run_rebase(&newbase, &upstream); From patchwork Thu Jun 17 16:17:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12328819 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 2502DC2B9F4 for ; Thu, 17 Jun 2021 16:18:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D816613A9 for ; Thu, 17 Jun 2021 16:18:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232079AbhFQQUN (ORCPT ); Thu, 17 Jun 2021 12:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233018AbhFQQTY (ORCPT ); Thu, 17 Jun 2021 12:19:24 -0400 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6AA8C06175F for ; Thu, 17 Jun 2021 09:17:16 -0700 (PDT) Received: by mail-oo1-xc29.google.com with SMTP id d27-20020a4a3c1b0000b029024983ef66dbso1719019ooa.3 for ; Thu, 17 Jun 2021 09:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dJwpQVDU2xZwafgpxfkEmqLIxA1focJGGFitdRyBInI=; b=Wn+zQfjYKX+gVkYR1m7W9haDU03lI/mcSwv36jbVTCKN96oWOOwDeotkCFwBOYXGA1 c4qC5wF8PVcPWQrKj8uEHxw8YlzU/5uHRrbVKvEBDWgNA7msWmEZEAZiFPYLdrwZawmv qQrhLlPUGCPb/euVpkGIIRfaaL1xy5rgG6Oe84kM79dIuiggLNfSIuPE7os0AWOdHxML TiOPvY9fo/NMxAirjEu5ARAoNTfcvYBGaH/GqY81fS46uftgSWCvgKuup1et4FA8xZk5 tRdOA4/MxiJXyS4bfN+zeEhfihDjfbD2XLgg63Mb822jtINzQZxbOSmXW2djM90Lwp2D jc6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJwpQVDU2xZwafgpxfkEmqLIxA1focJGGFitdRyBInI=; b=Aey2br2yhoSdCswjPoEOf+pQ6xqyBoby219MEUNSHuvA508mQXrNHvDwLoRsQ8jVtr qh9RXTpP4Fa2+3nI/75WJjVHtfkY+x5Wya7e8tuc+gyoXWgHtD6cUMMJcHW4UtOEIxck ItZZCu4Q7V244tLRcPfC+cs4mP1y5Cl5TBszpfk5LtCmjRTcXhQso8nouwZTMbtpuVLK cgRjhH38SKDgGLswT3hUo3K58ffcKNZj2Q1+e7YGyZvZq6Zx4v0cFqMsIBNzpCtq2vEJ BmvBZ7zP1McfQys+az65QPPcsZrRTp+16VMYKzoIEB3be+uDn5/kLt/nQZrU13BMgCRi xm/A== X-Gm-Message-State: AOAM5332cz+TP2rPD1NuRwojzw4NGIbCgyI1BBT3iGt4X81zTtcNrfJz IthlLIObzN8ibWUYdE+sTaKXN8yEPY8BJA== X-Google-Smtp-Source: ABdhPJxFdfRe5TrSKUnWFXKffZNnS7gvjhrtmbGB3fPDIJpIMzv4XxLy9ZGl6g2hbrm9bYHcB5WPaA== X-Received: by 2002:a4a:e887:: with SMTP id g7mr5217665ooe.64.1623946636078; Thu, 17 Jun 2021 09:17:16 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id e15sm1196282oow.38.2021.06.17.09.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 09:17:15 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Elijah Newren , Felipe Contreras Subject: [PATCH v2 2/3] pull: trivial cleanup Date: Thu, 17 Jun 2021 11:17:09 -0500 Message-Id: <20210617161710.81730-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617161710.81730-1-felipe.contreras@gmail.com> References: <20210613045949.255090-1-felipe.contreras@gmail.com> <20210617161710.81730-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no need to store ran_ff. Now it's obvious from the conditionals. Signed-off-by: Felipe Contreras --- builtin/pull.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index a22293b7db..80e2f55cbc 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1053,7 +1053,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_rebase) { int ret = 0; - int ran_ff = 0; struct object_id newbase; struct object_id upstream; @@ -1068,11 +1067,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (can_ff) { /* we can fast-forward this without invoking rebase */ opt_ff = "--ff-only"; - ran_ff = 1; ret = run_merge(); - } - if (!ran_ff) + } else { ret = run_rebase(&newbase, &upstream); + } if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)) From patchwork Thu Jun 17 16:17:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12328821 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 C2B94C49361 for ; Thu, 17 Jun 2021 16:18:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E52C6117A for ; Thu, 17 Jun 2021 16:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231176AbhFQQUR (ORCPT ); Thu, 17 Jun 2021 12:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbhFQQT0 (ORCPT ); Thu, 17 Jun 2021 12:19:26 -0400 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1167C061574 for ; Thu, 17 Jun 2021 09:17:18 -0700 (PDT) Received: by mail-ot1-x329.google.com with SMTP id f3-20020a0568301c23b029044ce5da4794so59388ote.11 for ; Thu, 17 Jun 2021 09:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vuoDBBZDUEBUj/UnRKf0FOhatbeeX6da52mTvAVLt6Y=; b=P1CM6Dy/tS+yxZW1VsEPCXj16r3YoHELRo6F3feFkQbMGa0DiW95GwsNb9bri660ez XZdBjgW9IAzUIW7LLU70qqiap4+anV3+Lb/x3elsroV5s7Qg6PWeJ4Iae7ImIj1IDGAy F59TlYJASsM5HiR9akqccv3U3Jioc0+u1gxQRzB9YYH5VRBuv/KKlj99XFR9q8oqLROp CoobKRHzZ72+IbtFj6s9Rp8CSuNPhjnMgCuBhOOHU4fyDlGZNG2WHa4RsCNw7zqLvq8t 7trNd8W2mSbogAh+v/tGQcas6i3P9FpryDeyCl3k5myNE4/C5KB6R+xLP9Ou1Q0MhkGo mvbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vuoDBBZDUEBUj/UnRKf0FOhatbeeX6da52mTvAVLt6Y=; b=koh8ZTQ9P1UMUUrAX/KTmOcMxf7IdCZyiAHB4m0bl90SpKK/1i2/xLzf1G7g4M66Oc ns6c+LZB2p33vJkDYwh08NZyL/p0eRIvJ0/1cNYk2Fp9ADs6Th65/pZ5czT7uBP1e3+j gExF5N11RF8T4DaNB8LWhugmM52Vybi5dIG/YFdDjh3M6Fuv5ifs7JmulYNeuhRx2dkM sGDmH38YaMA+zTleOBGe64QbFevshME/SkvOMGlW5pAyaY4dHxPDNmCkWk1Shv3gpnq0 ZVTMY6KEhXLXXIuTp6TRv9GZZfRuDKxbH94s+HcbodiHQF5x3+JtVwzPhgenEFERudjp 5f9g== X-Gm-Message-State: AOAM532SNcjJ5C4BmOr+lZnFaK5cbDgjCNpRcj6Vu6YEsVCrdM4R2YA3 difrB0pNPY3MTHJJvpc9j4XxD902pBwR8g== X-Google-Smtp-Source: ABdhPJxApN6sXFRGWuHz8aqJJ87/c0Z1/EjJU4ILmCkcTEYCIKF2e40XXkr869Bq4E7DCahYA8NWFQ== X-Received: by 2002:a9d:2f62:: with SMTP id h89mr5155991otb.225.1623946637724; Thu, 17 Jun 2021 09:17:17 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id c184sm100079oob.43.2021.06.17.09.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 09:17:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Elijah Newren , Felipe Contreras Subject: [PATCH v2 3/3] pull: trivial whitespace style fix Date: Thu, 17 Jun 2021 11:17:10 -0500 Message-Id: <20210617161710.81730-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210617161710.81730-1-felipe.contreras@gmail.com> References: <20210613045949.255090-1-felipe.contreras@gmail.com> <20210617161710.81730-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Two spaces unaligned to anything is not part of the coding-style. A single tab is. Signed-off-by: Felipe Contreras --- builtin/pull.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 80e2f55cbc..3e13f81084 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -126,9 +126,9 @@ static struct option pull_options[] = { /* Options passed to git-merge or git-rebase */ OPT_GROUP(N_("Options related to merging")), OPT_CALLBACK_F('r', "rebase", &opt_rebase, - "(false|true|merges|preserve|interactive)", - N_("incorporate changes by rebasing rather than merging"), - PARSE_OPT_OPTARG, parse_opt_rebase), + "(false|true|merges|preserve|interactive)", + N_("incorporate changes by rebasing rather than merging"), + PARSE_OPT_OPTARG, parse_opt_rebase), OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL, N_("do not show a diffstat at the end of the merge"), PARSE_OPT_NOARG | PARSE_OPT_NONEG),