From patchwork Sun Jun 13 04:59:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317297 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 B517CC48BDF for ; Sun, 13 Jun 2021 05:00:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C185611CE for ; Sun, 13 Jun 2021 05:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230286AbhFMFCL (ORCPT ); Sun, 13 Jun 2021 01:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbhFMFCJ (ORCPT ); Sun, 13 Jun 2021 01:02:09 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91ECC061766 for ; Sat, 12 Jun 2021 21:59:53 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 5-20020a9d01050000b02903c700c45721so7480939otu.6 for ; Sat, 12 Jun 2021 21:59:53 -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=GQXe6buHltMr+p0yRZf8Iowfc7T/6kp9lrkEYVN+kJw=; b=TUwyqBIqbfew1LMd5iFQ/Z/4+ATrdpxKqDjxTYQhfXvDfReKuWcYIR5RLbWqN44Gau LsRXmjApET7hZ44hJDDmgW6qbrhk8L4a4+SfOZQvsUfU7MNRD++xGP9/bm3nFp3bmKi6 tviqeruXs0PxBJ1xk4ze5YvQrJgjROibax7hs9usvVgoebfKaLpHvi68fyjQQikNWSaB ScGC/2mhNKpA7r8ryq0jskAxoLCg0VElrKfZ1HIlapWUpiITpRwZ06XQ1EK6RCUDNeOr tnmOcnCAO2VFOSSsUxtbFJLx6nZTcgnkWpIFw2GFchaHSU4R35FEtj3jL0PUl7uL07Tv Q+Ug== 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=GQXe6buHltMr+p0yRZf8Iowfc7T/6kp9lrkEYVN+kJw=; b=bB3+dNWKEAaCvloSQ8frkM5bexvOj4u8/S1Hjl6rIXqBjlSEV8gJER8XBkHUB6LsWw P5+a1k3MCVNs6XRjLJaphjz3DTtIiN4M6NN2phbhMHsFW8AJ8zFdJTxsaJYIJ0WtaSRV LJPiIZxZajJC80qJqK106usUQPKsgLuvca2NshSS5lzZnic4jF+QnYO46sMryx9tFA8h GiM4f1UpW9Wv/ivFdgfJTHSHsfQmi6TBbTPaHjPTm7KErrA1jCOBkZlS2dIvm9p9o276 dMOTiQeiDXVuFkxPZ2nkpeLK9FoDxRxmwUYhekfU7px8suZqWX5PeM4cuXCGAZkl8udS qcRQ== X-Gm-Message-State: AOAM533z88Ptt2uELs4vMPxQeDjaO53OU2A45axNXxbYUQKl2ptTJnoi NZbxKyPWltMLUltzpfZhRA30gjOeN6CHKQ== X-Google-Smtp-Source: ABdhPJxB7xk12rkRVPvuRG7Yz6uxr7aqvPp6N3BZYkmZWHYq5TKxQ7wa6qynSH0kqttDSrdTkzVOfA== X-Received: by 2002:a05:6830:22ec:: with SMTP id t12mr9132520otc.243.1623560392953; Sat, 12 Jun 2021 21:59:52 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id p5sm2129015oip.35.2021.06.12.21.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 21:59:52 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 1/3] pull: cleanup autostash check Date: Sat, 12 Jun 2021 23:59:47 -0500 Message-Id: <20210613045949.255090-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613045949.255090-1-felipe.contreras@gmail.com> References: <20210613045949.255090-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. Reviewed-by: Elijah Newren 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 Sun Jun 13 04:59:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317293 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 AFD2CC48BDF for ; Sun, 13 Jun 2021 05:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76E52611B0 for ; Sun, 13 Jun 2021 05:00:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbhFMFCE (ORCPT ); Sun, 13 Jun 2021 01:02:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbhFMFCE (ORCPT ); Sun, 13 Jun 2021 01:02:04 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBACFC061767 for ; Sat, 12 Jun 2021 21:59:55 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id w22-20020a0568304116b02904060c6415c7so5145501ott.1 for ; Sat, 12 Jun 2021 21:59:55 -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=o1OFqMiAY69dnqH6QVqttr7q9rQCRRCLiuyW6PPw32LFTkOxzHqude2Nboq0AkbDi3 yakDPvH5T0EvS7q3vRL8LB/nw8AA8wkmLZu+2gMkFw2CFFu7cwnsAUHS2Tu7KWy04t8t 53ys7u/rueAEevB8hOrmuGEhqrFA40YEDLUwOKMKN98RQFFX0tkXslLRZxGvGSC1Da+/ 6XzSoSHvgjTLuKdKW+lbvOXy+wMpnv83lQ+Roifm32rA+Mtwh6A/oBIEGAOQ2PaOc91W KFsASJ+IhQvnZIQr/Wfd4cHymn7DG+DWwJtypC/Q6CYm/unftLWB2H3EiNhkDQ71ATtH dt5w== 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=JYBO/mvUA9GJWEdDDWBzn6KON1Xj9PzOGL0S96VENiXNSjMXCvSXPOwFvYoMXqWoSo P1/FMamzVtr8M3HlfXfhmX9HbVSUXEGUoxpzzdL49BiZKaMQUR3/QaSzasLILzI4JBRf yCP9k2blWC0SABe1oTv6LaK+L/hwvXPRQ3R0JY/u31llu3G8z6QbeYWRGL/Y3DgdFgUH C44eECwvg7gNEk6WcftneSL5ODSZ+Jx/QGl+EztfXYPc1uPmMhyQWvz50LezlhgeCGbV XH5aTj7vYcuZDfRjlPA2CrAWQap13WJxw1vbT9Bm5zB59bca6GzbrWMSfqHICFfEyLzu j3xQ== X-Gm-Message-State: AOAM532kDXsQq1QUBt0W6rOZOFFfWN7dIUw/9EWB+XS1PPvC4CxkMrSJ mWr+PKxoLRxxT1KuPJHx9+lrunrFylUkrw== X-Google-Smtp-Source: ABdhPJw2FtjMPvCV86bIvyutphBtE52A087oItfgu5+embc6CaG/1F77QjFOS8C2/jOf4aEIriYYtg== X-Received: by 2002:a9d:5d14:: with SMTP id b20mr9076003oti.307.1623560394552; Sat, 12 Jun 2021 21:59:54 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id b26sm2446167otq.43.2021.06.12.21.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 21:59:54 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 2/3] pull: trivial cleanup Date: Sat, 12 Jun 2021 23:59:48 -0500 Message-Id: <20210613045949.255090-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613045949.255090-1-felipe.contreras@gmail.com> References: <20210613045949.255090-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 Sun Jun 13 04:59:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12317291 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 15690C48BDF for ; Sun, 13 Jun 2021 04:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C413C611B0 for ; Sun, 13 Jun 2021 04:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbhFMFB5 (ORCPT ); Sun, 13 Jun 2021 01:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbhFMFB5 (ORCPT ); Sun, 13 Jun 2021 01:01:57 -0400 Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0535FC0617AF for ; Sat, 12 Jun 2021 21:59:57 -0700 (PDT) Received: by mail-ot1-x330.google.com with SMTP id 5-20020a9d01050000b02903c700c45721so7481004otu.6 for ; Sat, 12 Jun 2021 21:59:56 -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=riP4F5XjB1f+FxGhoCoK0u6fIuyLigtmBfKKglbaukPcz7FhS12QEUAR3vy8uuVqeP gV1JT94MglsmlrS/A4qqziVj/3a+GgoVvwVlKb2QUieh+tq5vGjGqe1LCfbHOL6JBjze yUCTiZesWuUIPsuIYCV4DpysU+JQY9w06YAMz4DU+ry4w2GBSUQNque4/1zNf5CVWjmd XfSARGwu4pIisWGN84zHYZFK+KLZr3qaXltNfc5OUseApyR+5eb+zoT85JLqHy5R+JZ4 qrFgo3kNgelGPKWQV01IcnqPLFs/sCdqsNar46b3+yDAcftkGGpT25gDDcbKR233/CwH hlEw== 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=eWltjZcBUwRN3HHZlPk8wwc4qQmMzbY+KnOgLhNW3IJU0vynogcJTABRySXLTqpMEq p/OF/x8kZXWtVHqogg+UhfGGF/UOJ03+IrX/y0qE1qEiutFp2lifqzu4ogUfpc0JbuXL z+pPI4Ze4PoLLSDXB1MWXEYmOHsRv8K7odMsB8w/SfVFXz6lJM2IlPHRtJR8tICNAhEY ARifgxq/I49kx3vhcWEkwZw5N8JhdmRJ3KjfyhKLUuwtFmyYsgRyk2w9yKhqIj/v+VEb BBRus3/O9WYKOX0MFyjopb6EQZv9owMsnCXkrbwzSkOG6IIablSPLQTc+x60J3Xo2DVy ngYw== X-Gm-Message-State: AOAM530Nm4lnW6VwEcx7mD8RkH9E6dxVO2QiMXUzeG9D7Ia9d+aDeFX4 TgvTHTQ7dJ0Vj0FlQXH8Or5qJ7q8DR3PHQ== X-Google-Smtp-Source: ABdhPJy4Y0poi8BcIglqc5G4GMmV3zeojJdTY5en17wxlGJDsrV8PoDQvdIsWsFjss+pCYrnr87FLA== X-Received: by 2002:a05:6830:923:: with SMTP id v35mr8822731ott.358.1623560396206; Sat, 12 Jun 2021 21:59:56 -0700 (PDT) Received: from localhost (fixed-187-188-155-231.totalplay.net. [187.188.155.231]) by smtp.gmail.com with ESMTPSA id u1sm2214171ooo.18.2021.06.12.21.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Jun 2021 21:59:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Philip Oakley , Alex Henrie , Jeff King , Junio C Hamano , Felipe Contreras Subject: [PATCH 3/3] pull: trivial whitespace style fix Date: Sat, 12 Jun 2021 23:59:49 -0500 Message-Id: <20210613045949.255090-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210613045949.255090-1-felipe.contreras@gmail.com> References: <20210613045949.255090-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),