From patchwork Tue Dec 15 08:46:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11974241 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 D3FE8C4361B for ; Tue, 15 Dec 2020 08:47:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85F2720702 for ; Tue, 15 Dec 2020 08:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727633AbgLOIrE (ORCPT ); Tue, 15 Dec 2020 03:47:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726982AbgLOIrD (ORCPT ); Tue, 15 Dec 2020 03:47:03 -0500 Received: from mail-oi1-x241.google.com (mail-oi1-x241.google.com [IPv6:2607:f8b0:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8731BC0617A6 for ; Tue, 15 Dec 2020 00:46:23 -0800 (PST) Received: by mail-oi1-x241.google.com with SMTP id f132so22497827oib.12 for ; Tue, 15 Dec 2020 00:46:23 -0800 (PST) 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=ZHFmxjQaoPxg9Bw0aqjYCzyRsQtdoz95gXOxQnZESo8=; b=AYYTfKlhIIAF2P85Yx0seJNu0JVc1cOwUqmV0ECt86pJJ6/EAUbAx+egxEIivo/UgF mWN49iYkL4N4P7X1StAl+V2S74R23QYC9aPK0U3VM1JG17ONMhNhcxXe01KdNDiyDFJW M0IBZKX0GTR/+vPXouZ4GrtbLfOwHdZt6cONMJZOctgddHCzWUueXndbbJWydn6nqdcq +hO6kVXefUl2dUFigOK+oxMxlptH2v0JIfg4EWVU+0CeVqUfywc/OYPp8mdMK2z6UzME 5O4JAemWtuK9ljv2hd3KoRuWCNujPzZ069qB1ML5lAO2JNvPJtlZZNTvZr+MtMPmioAH Z4SA== 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=ZHFmxjQaoPxg9Bw0aqjYCzyRsQtdoz95gXOxQnZESo8=; b=ecf2yONesKY0X1y+dARAJ0v5OyoFw6mDQbpK+yUZCr1A6YX/7NRpROnyLCgQuq1AJG NG68KfX3stus1xPOiMD++yaPERJZCF5pM4oXuiDcD1IiXQC/SX8UJN6uZO/0pWDJgJou NJw6XLPjnsbJYpf0qV4uNn65zMjg644QY1QFkB4ShJTJFSYOC/9LIijUQE8ljUZDJXHm 9N0mbJU8Re6kw7e3TIHPgszCv6emPKzal/zGB6oLpO3AaI3Q4Xt3CC7ofkfwSuiFm5JH dlzme5svKv3UmvXsBSPUBXwfYT92AtZ9hn8+49ML8iqVgWIxKjTMifb+m0aAO8ozWJG9 jd1w== X-Gm-Message-State: AOAM531D1OIsTmyLy2rOgTEHp+TFjZM2TgTM0s9A6dBSdyKZ1czuix4d nkcEkOqIlQ/y2EFEXHurDcoOJNFnu0KZjA== X-Google-Smtp-Source: ABdhPJx/J9k+VSN8hv0yMswvZ2RzGNJnp8dNnZpVRXGKBHV2HG1SylqAwkddAGZvLdXmbxRiN+/kfw== X-Received: by 2002:aca:c3c3:: with SMTP id t186mr21005146oif.53.1608021982733; Tue, 15 Dec 2020 00:46:22 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id u85sm158841oif.57.2020.12.15.00.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 00:46:22 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Elijah Newren , Felipe Contreras Subject: [RFC/PATCH 1/3] doc: pull: explain what is a fast-forward Date: Tue, 15 Dec 2020 02:46:17 -0600 Message-Id: <20201215084619.1631180-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215084619.1631180-1-felipe.contreras@gmail.com> References: <20201215084619.1631180-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We want users to know what is a fast-forward in order to understand the default warning. Let's expand the explanation in order to cover both the simple, and the complex cases with as much detail as possible. Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 5c3fb67c01..e89d391b3b 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -41,16 +41,41 @@ Assume the following history exists and the current branch is ------------ A---B---C master on origin / - D---E---F---G master + D---E master ^ origin/master in your repository ------------ Then "`git pull`" will fetch and replay the changes from the remote `master` branch since it diverged from the local `master` (i.e., `E`) -until its current commit (`C`) on top of `master` and record the -result in a new commit along with the names of the two parent commits -and a log message from the user describing the changes. +until its current commit (`C`) on top of `master`. + +After the remote changes have been synchronized, the local `master` will +be fast-forwarded to the same commit as the remote one, therefore +creating a linear history. + +------------ + D---E---A---B---C master, origin/master +------------ + +However, a non-fast-forward case looks very different: + +------------ + A---B---C origin/master + / + D---E---F---G master +------------ + +If there are additional changes in the local `master`, it's +not possible to fast-forward, so a decision must be made how to +synchronize the local, and remote brances. + +In these situations `git pull` will warn you about your possible +options, which are either merge, or rebase. However, by default it will +continue doing a merge. + +A merge will create a new commit with two parent commits (`G` and `C`) +and a log message describing the changes, which you can edit. ------------ A---B---C origin/master @@ -58,8 +83,11 @@ and a log message from the user describing the changes. D---E---F---G---H master ------------ +Once the merge commit is created (`H`), your local `master` branch has +incorporated the changes of the remote `master` branch. + See linkgit:git-merge[1] for details, including how conflicts -are presented and handled. +are presented and handled, and also linkgit:git-rebase[1]. In Git 1.7.0 or later, to cancel a conflicting merge, use `git reset --merge`. *Warning*: In older versions of Git, running 'git pull' From patchwork Tue Dec 15 08:46:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11974243 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 5FA66C2BB9A for ; Tue, 15 Dec 2020 08:47:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 241EC206C3 for ; Tue, 15 Dec 2020 08:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726985AbgLOIre (ORCPT ); Tue, 15 Dec 2020 03:47:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727637AbgLOIrF (ORCPT ); Tue, 15 Dec 2020 03:47:05 -0500 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 667ACC0617A7 for ; Tue, 15 Dec 2020 00:46:25 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id d203so1352858oia.0 for ; Tue, 15 Dec 2020 00:46:25 -0800 (PST) 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=KYDiKYX/5IAMfGrlhEdxXBHLvJIRGCS8whMuAeHVwi4=; b=YYWmotE234DNWoQwuw0zeKplEESpaeGFGqYhq+Mc1tJikAKg8zdy495Ne5Ofxrc7zc sx6pKgYzkXuEUgEqVWiNjo1HbOaKCrnJSxxK/EmcOA+wmgGfPlT8ozhVZeSV0AgfNSOq OP+/sanFfIK+lmMKXFGFs44HWqvfrLx/VWhix9UBB7m44YioL3jJKTu/QHNgWjgigLIZ LewsBP5IPA7gum0WDUMPyFen5MTRR5l9WZt9l9UQARosQFVTKV9vZXvzMpamhGKt3/ka OPlsJ0QBGOMG44BZjBzKicMqefflYlJL8wWRDk/MR7+2pO6dVfgdOmHrhYtMURcjHZml 2uPQ== 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=KYDiKYX/5IAMfGrlhEdxXBHLvJIRGCS8whMuAeHVwi4=; b=r0+t287PmRxlsGOdHVSYtRVSGZB/J55THmrV9451iM7W5uBuT9+iJBTfJ6JVLgnQ1Y tJkP8pP1s6hFOCBNMD4iq5S1BlS7P535aoi0Sh6ECKhpU8etFZb3BJSy2XjzRqWcl/bH zRNIkeWRmyQditxoFn569avZa2IffAmhNMFnznhE50wN9bn9xWWxp/+8zT+XPjT2jMqH vhZfWIWDhsLSRTeupDa11IpQeC3lEdJzoGOn7BBtYpD4DQHLgW5i4ZVhGCZS5Ccg//oV DDBU5u+upMgR88GL5L3uuQrSpwZVOe3NpM8jxhge0YawGP/Vvx4mgrB+JnsfDRzZOX4G wEZA== X-Gm-Message-State: AOAM532tEw/yO+iG86np27TlnfNJVF9Xmbvz2SaUFrK3b/Ms1Z2+EIGc ArUemGIFI590TrFJ5K798hzspmhqPoMS4Q== X-Google-Smtp-Source: ABdhPJx9VMYK9U1vwVLAOhM68wdREkhjw28N7F1khWooQLDJnssui6pLyDIWT5CxHv8978fWfCWPdw== X-Received: by 2002:aca:b789:: with SMTP id h131mr12896286oif.83.1608021984540; Tue, 15 Dec 2020 00:46:24 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id e81sm4928519oia.30.2020.12.15.00.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 00:46:24 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Elijah Newren , Felipe Contreras Subject: [RFC/PATCH 2/3] pull: improve default warning Date: Tue, 15 Dec 2020 02:46:18 -0600 Message-Id: <20201215084619.1631180-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215084619.1631180-1-felipe.contreras@gmail.com> References: <20201215084619.1631180-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org According to feedback from GitHub trainers [1], most newcomers don't understand what a rebase is. So in the default warning we want to provide our users with a command that does the most sensible thing, fixes the divergence, gets rid of the warning, with the minimum mental effort, and happens to be the default: git pull --no-rebase (later --merge) In addition, we don't want to start by recommending a permanent configuration, but a temporary solution so they start training their fingers and maybe learn how to do a rebase. So we start with the commands. Also, we need to be clear about what we mean by "specifying"; merge, or rebase. Moreover, thanks to the previous patch now "git pull --help" explains what a fast-forward is, let's mention that reference. And finally, use --global in the configuration commands like we did with push.default. [1] https://lore.kernel.org/git/20130909201751.GA14437@sigill.intra.peff.net/ Signed-off-by: Felipe Contreras --- builtin/pull.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e8927fc2ff..a766d9762c 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -927,18 +927,20 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_ static void show_advice_pull_non_ff(void) { - advise(_("Pulling without specifying how to reconcile divergent branches is\n" - "discouraged. You can squelch this message by running one of the following\n" - "commands sometime before your next pull:\n" + advise(_("Pulling without specifying how to reconcile divergent branches is discouraged;\n" + "you need to specify if you want a merge, or a rebase.\n" "\n" - " git config pull.rebase false # merge (the default strategy)\n" - " git config pull.rebase true # rebase\n" - " git config pull.ff only # fast-forward only\n" + " git pull --no-rebase # the default (merge)\n" + " git pull --rebase\n" "\n" - "You can replace \"git config\" with \"git config --global\" to set a default\n" - "preference for all repositories. You can also pass --rebase, --no-rebase,\n" - "or --ff-only on the command line to override the configured default per\n" - "invocation.\n")); + "You can squelch this message by running one of the following commands:\n" + "\n" + " git config --global pull.rebase false # merge\n" + " git config --global pull.rebase true # rebase\n" + " git config --global pull.ff only # fast-forward only\n" + "\n" + "If unsure, run \"git pull --no-rebase\".\n" + "Read \"git pull --help\" for more information.")); } int cmd_pull(int argc, const char **argv, const char *prefix) From patchwork Tue Dec 15 08:46:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11974245 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 7E626C2BB48 for ; Tue, 15 Dec 2020 08:47:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4395A20702 for ; Tue, 15 Dec 2020 08:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727657AbgLOIr2 (ORCPT ); Tue, 15 Dec 2020 03:47:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbgLOIrH (ORCPT ); Tue, 15 Dec 2020 03:47:07 -0500 Received: from mail-oo1-xc42.google.com (mail-oo1-xc42.google.com [IPv6:2607:f8b0:4864:20::c42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30274C0617B0 for ; Tue, 15 Dec 2020 00:46:27 -0800 (PST) Received: by mail-oo1-xc42.google.com with SMTP id j21so2047319oou.11 for ; Tue, 15 Dec 2020 00:46:27 -0800 (PST) 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=KkYrVv2KHmTz7s4ZgMh7yIFtmkXt+jX3Cnc0G5u+1L8=; b=Fi3oR8FhthsO+oz+7anY+k0TFaTRghb3Rc0YU5sexmp77EoasRjivtA0EH8d83Pj0q iJg94utfRfSsfImwELVfUZ7/pcPJB/uGdJk9N4TN/eIJb0gXYBu1z2a8mkAhMV4idiGM YkWZltlDcYtydcuM8kFLKR4rSV0odBHQckMd4x6Wf5rJpB1TtwfvqKlwiY5u3MbGXs4G L+HOpi1XTwxZELyMLWu/WxgDLOwWBfacaM0du8MwH3e7e9iQ3EgyvzWjeEPZMCfjMLwp yP6IJoFWVyl0Z9QQ2g5YpJz4dGRekwGjmKs3erDc4koiRkaEgJgV3y+lunEM+6rHxvM9 TZ+g== 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=KkYrVv2KHmTz7s4ZgMh7yIFtmkXt+jX3Cnc0G5u+1L8=; b=deZ240WfKyV1BbPvDPv4ADHE1OmJu4BYdvz1iTrrYXQnpORY36/aX3qx+mkHJ1UoFb IHL5pvktZXtIDCArWc0wDIJy+M4aFDOnvJ7ZY4xl+lXsK0OkjK0hNaTlRV6/TVQu2FlR xugeQg7IOit9RjvgSiZ83vW/eVHjF3dN0GQ92jX5yR7ajVRW5lgUx361FreLeGcUyNkm FprRDUhWyOjZXfcqt1OidwBLgiLGGnGvoFNriUXME8RDhvh5M0v8nwGNFm+Uf5+Yrg2C asLeqV8rESnwleT3hcFZ8LMOPqjDrs8drgWRKKSMe5MDUOQBEW81WYcpyuFPNWyjlRsN F64g== X-Gm-Message-State: AOAM530lXOSevTK8GWjCn4kl8XzAHBEcD2TH5AEcIOsNyyis4k/iEo3T 9/+rKHzjr8LoC1vr11S9ds0a6YYVfdFvRA== X-Google-Smtp-Source: ABdhPJy+y7c9InlXpDFqlr/hU0X/nX66dADnDqDrNKa3FJ0PJFhpJJAAf4UCEodgkKx4BqFPtFBz0w== X-Received: by 2002:a4a:9c5:: with SMTP id 188mr12794810ooa.77.1608021986392; Tue, 15 Dec 2020 00:46:26 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id t24sm4584105oou.4.2020.12.15.00.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Dec 2020 00:46:25 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Elijah Newren , Felipe Contreras Subject: [RFC/PATCH 3/3] pull: cleanup autostash check Date: Tue, 15 Dec 2020 02:46:19 -0600 Message-Id: <20201215084619.1631180-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201215084619.1631180-1-felipe.contreras@gmail.com> References: <20201215084619.1631180-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 a766d9762c..42cd6c38d8 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -949,7 +949,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; @@ -984,8 +983,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; @@ -1067,13 +1066,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);