From patchwork Tue Dec 8 00:26:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957191 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.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,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 809D0C433FE for ; Tue, 8 Dec 2020 00:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3350723A04 for ; Tue, 8 Dec 2020 00:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbgLHA1d (ORCPT ); Mon, 7 Dec 2020 19:27:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgLHA1d (ORCPT ); Mon, 7 Dec 2020 19:27:33 -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 D64CFC061793 for ; Mon, 7 Dec 2020 16:26:52 -0800 (PST) Received: by mail-oo1-xc42.google.com with SMTP id g20so1776482oos.9 for ; Mon, 07 Dec 2020 16:26:52 -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=kzr6hpKrAlHfjV96VJaCsV+AczHLhVlKsiTxozFVnHY=; b=HX2pQagnM5gJOhy4ZqNgH0Oc67lDwhOKbQBMqOVRdGYV8+DIW5idsH++l4NGZGjV+G H39CYZc0p1x2V+XvQiXpH5BKN+BArfQe2MuSjgAmT/06XfSDNx+azxn841yCdFih9euC yxUoXvUKIKqvwDXnCMsOfjGU53vFdc8PnciGaZIcpi+JhJnUb3bCRdxOVRAhgozDcKOV 3IR7pPQ/zx2e8n5Y7KcoOSecDWsdMizes6xzoDYnI239IDhcUqW/V1tGXhCOVNgemdIB 7jGF1+u+B0av/7etMEOE+D+axeKNrCj+CBdEqf5I6v/0DJD1ZaejWHor3g0CDwS7ySPb rr+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=kzr6hpKrAlHfjV96VJaCsV+AczHLhVlKsiTxozFVnHY=; b=FU2V/p/tEevdu+zxWgujFTa+9ptYTQ430OzdjkmlGUcbMJTCs2GxukrBawg+pZc/jR s4xddx60PxZ29abcUKc3Z3x75uRb++7DW0XMSliImY1zm/4Jvl5aFEjW3jXBMPgNRIfj 1eEeQfYmOa0iaWUwtuks4uZCF9mcoqkBlV5MlU7SHl9a6TBw6B8BMxuePg1Wb7UlNGcf rAcRC8wSbURbq7ZcWG3WO32gUpJF9fjKVE0awwcPWSC5/mjCggN0czjoTsPJCctqEZQD 4hoE9ceI+2v04OBoFwYXqi2ckqEl0EMTmqzds0DPWHUHuUWqZqHnjMa8lGoj/A+3Rs4P UvCQ== X-Gm-Message-State: AOAM531Hkpr2Y+00SiQQOtESmLqyCxs+5v5wuA/1ujYcF4KYqYSixVj0 ISQYQ0pMwT+nrPFCZltQvc9lZhdSC/w2wjgd X-Google-Smtp-Source: ABdhPJxsu/9Oh2uCgBFZ/2IRWRxhmtJnllt0PvLxzYqQwiknSV/1MBhBlFsZo9CtyVvrVlikNDv/FA== X-Received: by 2002:a4a:d148:: with SMTP id o8mr4485376oor.16.1607387212101; Mon, 07 Dec 2020 16:26:52 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id u10sm3052782otj.31.2020.12.07.16.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:51 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 01/19] doc: pull: explain what is a fast-forward Date: Mon, 7 Dec 2020 18:26:30 -0600 Message-Id: <20201208002648.1370414-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-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. Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 5c3fb67c01..e1605a81b3 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -38,6 +38,20 @@ as set by linkgit:git-branch[1] `--track`. Assume the following history exists and the current branch is "`master`": +------------ + A---B---C master on origin + / + D---E master +------------ + +Then `git pull` will merge in a fast-forward way up to the new master. + +------------ + D---E---A---B---C master, origin/master +------------ + +However, a non-fast-forward case looks very different. + ------------ A---B---C master on origin / From patchwork Tue Dec 8 00:26:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957193 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.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,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 B4E9EC433FE for ; Tue, 8 Dec 2020 00:27:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E38723A1D for ; Tue, 8 Dec 2020 00:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728616AbgLHA1f (ORCPT ); Mon, 7 Dec 2020 19:27:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgLHA1f (ORCPT ); Mon, 7 Dec 2020 19:27:35 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3BD6C061794 for ; Mon, 7 Dec 2020 16:26:54 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id w3so13718605otp.13 for ; Mon, 07 Dec 2020 16:26:54 -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=q7vfJsdKwpyOOb5B9x65dJX00pCAZfHVrRHwfnSlfxI=; b=IA0C/LLGir2Fk2anVfpb6JTwNxyEakNdoL/xGvCd0+YkHPEK7fSb5jFjYj0xQOtIVF XdSrwFki+Q+2axzYNdhKOT4Q0OBhw1iNuwiuyYg8ifXequUbN8w9Z+IF/RD+gd/81nVI CJ/9OwsdAo2u9x31KUU0e+ESb3KXTY7Kr2UAIvgP0C/RpRIm99SSpDbeeDEwUdWcNPC9 HESdBLKPR7P2U1+5u9HaZU/ouu/t1x1N9qx8oeZxhNTTMSnTNjpfdyDXq/cqPhiEA1nw r30KsW+ZkUYsFb7YV4khezCLmi9gt5u4469aVSwyKOtAj9bPMbKu8wGcDTOChCwBYD6V yS1w== 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=q7vfJsdKwpyOOb5B9x65dJX00pCAZfHVrRHwfnSlfxI=; b=eFhR98t4N8eelZIPX4fxYgF2bwTnC93NW28+S8nsqCC2HVUNJ8KYoSEkQvQV/jNnr0 nnPZYkM4A2LgT1QThp3EFYW+8ErXQ5r6pWnu2P6qBzSJVlOrod9l0BIXF13Ym4bVe1ux dOthbdLx88kuymY6HibzGJyMvb6+IE8Kp1U1zOvse7NEO/VvLxpXXlwuCO3HCYvF3wu9 jOHLnUkH6NXXvzm4Q6PBtFX0mXLTib1qB5WnZJY/706E9cWt/hkjQcRELbG1BM4ieFZd BSmOaWP2BmXMgOSqb41fxEbOHLQhRwo1x1FNrVjZBDMTcG4pZ2QEEiRVHGMHBuf+vV2c TgKQ== X-Gm-Message-State: AOAM533Q+8yZEEXRcYC+TOdlLgZIA1mBdylabKZfmnWPZOWcDynarRvF pPBvTEbzPMYX+Eih5KrAm7ZkwIt/2fdH5Wrq X-Google-Smtp-Source: ABdhPJxuTShMlsDmwhtj9F5Th8QKxMlcxWBvEK0tN1aX8vFlb14gzMFR07PtmwMpEB3T3iGvKsfjBQ== X-Received: by 2002:a9d:6d05:: with SMTP id o5mr14598316otp.158.1607387213985; Mon, 07 Dec 2020 16:26:53 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id i82sm3324862oif.33.2020.12.07.16.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:53 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 02/19] pull: improve default warning Date: Mon, 7 Dec 2020 18:26:31 -0600 Message-Id: <20201208002648.1370414-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We want to: 1. Be clear about what "specifying" means; merge, or rebase. 2. Mention a direct shortcut for people that just want to get on with their lives: git pull --no-rebase. 3. Have a quick reference for users to understand what this "fast-forward" business means. This patch does all three. Thanks to the previous patch now "git pull --help" explains what a fast-forward is, and a further patch changes --no-rebase to --merge so it's actually user friendly. Signed-off-by: Felipe Contreras --- builtin/pull.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index aa56ebcdd0..d6e707f8f9 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -345,18 +345,18 @@ static enum rebase_type config_get_rebase(void) return parse_config_rebase("pull.rebase", value, 1); if (opt_verbosity >= 0 && !opt_ff) { - 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" - "\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" - "\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")); + 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" + "You can squelch this message by running one of the following commands:\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" + "\n" + "You can replace \"git config\" with \"git config --global\" to set a default\n" + "preference for all repositories.\n" + "If unsure, run \"git pull --no-rebase\".\n" + "Read \"git pull --help\" for more information.")); } return REBASE_FALSE; From patchwork Tue Dec 8 00:26:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957195 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.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,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 E223AC4361B for ; Tue, 8 Dec 2020 00:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4DCB23A1D for ; Tue, 8 Dec 2020 00:27:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728626AbgLHA1g (ORCPT ); Mon, 7 Dec 2020 19:27:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbgLHA1g (ORCPT ); Mon, 7 Dec 2020 19:27:36 -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 62C3AC06179C for ; Mon, 7 Dec 2020 16:26:56 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id 15so6406916oix.8 for ; Mon, 07 Dec 2020 16:26:56 -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=q5RrNL3qbISKSNn6BgL5TY0SZIXjZv8UUv/8SSWrHc8=; b=BIBi2FwhnWaxBQCzkaKleji8X/rDhnrje+rEix+FlHKowqcdDs2AAiLoX5coRzopZw 5odTBwCVYzgOqc55qSwThurYammqceoAs3wVIL8kVkc22u7Zw7DduLOmJ8nokCqi+kiK iodUD2rRr67MmgRTjoNsgRPt0tSSLGcUTuD/1asvTgUkHosLdLkdPlpW4PQxeVjrPkXm Yl9i/ImyBXW2k4gu7ek6lmxjOfkKJhh/fHNrnUMvWUwi883KKAxLXrUYO5SIb98Hx8s+ 00vRgUJBx7kqd10lFO/ixA7KWIpEUSz7BVP7BZuNqtR1MGkLZfRIHOMMugqh8/iUubPN iP2Q== 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=q5RrNL3qbISKSNn6BgL5TY0SZIXjZv8UUv/8SSWrHc8=; b=pXTQcQl22LGGA4QoO6YaKP7rdNLAnUoV8FTeebYPYkIiIWuxD/AIITEHEzxf1f4W58 ppbsjC9QaVRRKAWMpQaCjXKGIw9d7DJ6vCHVe/1t8OZsF13EF1TjmqDTKITyVIYCctbx sXeU4dm6wm4ExRt9jIRocB2mImYBeiXAjJ5p2ZfTADvguWrxmbtDk4C2w+MMQGdJwS+p iIA/FmdVrRyAiGX04XbH+O8BWrd2KnqNoyryaPBcg3GWNK4lJtAFVykkKhONaKWuqnlf iN+2a1rJBelcOT5WlZ8KjUWIBvsPkw0JZqC6YZrZepDeB5SSQuEtOQabPyHiUST3uzDq RHZQ== X-Gm-Message-State: AOAM530z+Y6a+I7VFBVT2SWCK8FlglzxhXxF8/4+R05KRns4ZKzf7r7h oddp/wex+Qe0IOh6BkDUBHvDCc2whrZ8n0KD X-Google-Smtp-Source: ABdhPJzOqEa+RAZ/NhOv9y2DZbyedQA53NH/2uUCzEHMq6BaQ7CTgCAS/UWpE8G82j9ezlTej9yRag== X-Received: by 2002:aca:5792:: with SMTP id l140mr845778oib.175.1607387215633; Mon, 07 Dec 2020 16:26:55 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id r15sm3034259otk.38.2020.12.07.16.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:55 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 03/19] pull: refactor fast-forward check Date: Mon, 7 Dec 2020 18:26:32 -0600 Message-Id: <20201208002648.1370414-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This way we will be able to do the check unconditionally (merge or rebase). Signed-off-by: Felipe Contreras --- builtin/pull.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index d6e707f8f9..e2964a0b5f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -924,6 +924,20 @@ static int run_rebase(const struct object_id *newbase, return ret; } +static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_head) +{ + int ret; + struct commit_list *list = NULL; + struct commit *merge_head, *head; + + head = lookup_commit_reference(the_repository, orig_head); + commit_list_insert(head, &list); + merge_head = lookup_commit_reference(the_repository, orig_merge_head); + ret = repo_is_descendant_of(the_repository, merge_head, list); + free_commit_list(list); + return ret; +} + int cmd_pull(int argc, const char **argv, const char *prefix) { const char *repo, **refspecs; @@ -1040,22 +1054,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) submodule_touches_in_range(the_repository, &upstream, &curr_head)) die(_("cannot rebase with locally recorded submodule modifications")); if (!autostash) { - struct commit_list *list = NULL; - struct commit *merge_head, *head; - - head = lookup_commit_reference(the_repository, - &orig_head); - commit_list_insert(head, &list); - merge_head = lookup_commit_reference(the_repository, - &merge_heads.oid[0]); - if (repo_is_descendant_of(the_repository, - merge_head, list)) { + if (get_can_ff(&orig_head, &merge_heads.oid[0])) { /* we can fast-forward this without invoking rebase */ opt_ff = "--ff-only"; ran_ff = 1; ret = run_merge(); } - free_commit_list(list); } if (!ran_ff) ret = run_rebase(&newbase, &upstream); From patchwork Tue Dec 8 00:26:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957197 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.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,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 D0048C433FE for ; Tue, 8 Dec 2020 00:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98CEC23A04 for ; Tue, 8 Dec 2020 00:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbgLHA1k (ORCPT ); Mon, 7 Dec 2020 19:27:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA1i (ORCPT ); Mon, 7 Dec 2020 19:27:38 -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 0E5B2C0617B0 for ; Mon, 7 Dec 2020 16:26:58 -0800 (PST) Received: by mail-oi1-x241.google.com with SMTP id q25so9505305oij.10 for ; Mon, 07 Dec 2020 16:26:58 -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=CIQP+pvUK3D2Gs8X4af48HlNAB2MlOCj8t5tszm79nM=; b=JtutgEb5ZgguMPNWSLWR1ksu6ofK2Mlxh6lnzi3XpNxlya+H/pUOx20Ds3R9XLBfGu kzeo1f5xJkxKiJA1Tq6lwsl9jIY3PO8rAylBTTEsdODemyPiVnfT+P3mw77AMqeTawQn nUx8RNg4XoPwSBv1WGKkzvtVezKl0swMkLDe/NVKIWSEZUE/UQvG67F966UDrtG24FwW cXiUGGsw2QXWt0Rv/HJMNgrFFagPfliFr20w5TjH7Nnv5I0qtHt8W93bBaJQvJ319ycN aQ0ppAvVOyd96WMNt5+0n3H69gND4FXiYkZzKPTHW3+F9Ii5kSyHkw+/u9iqHvaE3D+C 9muQ== 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=CIQP+pvUK3D2Gs8X4af48HlNAB2MlOCj8t5tszm79nM=; b=dIEpXfCl/lAMihCM19d/h3g3NKzWLDBgoGKySPh1mH1Ywk/um78RjlyZlEG3lTrc4F wvz7j2hPG3a1LCmlHtPpGLe2jGdcfSA4h/lkyvvJuJX9A+rbkOvQWRNqZnN8dV4Eg87Y nMq9fU8Pjgs6Ac78926OkYam+91b9Qr7WrNFVzU/WMC0fKKtz2qfC2Z9UJUYa1wUjtpy IZewqi/xxdkhGetsNgbALb9vefnOGOKs3o0N1VPMbvkQRfKabk2YURDqYgRsYHzMBHja QBrlUTpuXo6jY37MWtA9rUj1gQv8V/UQ5blDt3nfgBuYFiECOKTITo+jkO8yYhbgWuTD Yt3g== X-Gm-Message-State: AOAM530uplRilJ8dqEv8zK/qy59ciVllO9jOu0ulmLKOFlSFFEDlk8ev HYpQi62SPEDfgDmpkXc5j37E9njEol5W33wo X-Google-Smtp-Source: ABdhPJzGaH5OBalHGpe3b/ohd3XcXiD43+PglVDprjHUrr1hErCPxloDS/NIKs6w8AyVfHP8PdtRMA== X-Received: by 2002:aca:fd0d:: with SMTP id b13mr983340oii.27.1607387217276; Mon, 07 Dec 2020 16:26:57 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id n190sm2981525oob.11.2020.12.07.16.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:56 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 04/19] pull: cleanup autostash check Date: Mon, 7 Dec 2020 18:26:33 -0600 Message-Id: <20201208002648.1370414-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-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 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e2964a0b5f..d44ca2ffde 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -944,7 +944,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; if (!getenv("GIT_REFLOG_ACTION")) set_reflog_message(argc, argv); @@ -977,8 +976,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; @@ -1053,13 +1052,11 @@ 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 (get_can_ff(&orig_head, &merge_heads.oid[0])) { - /* we can fast-forward this without invoking rebase */ - opt_ff = "--ff-only"; - ran_ff = 1; - ret = run_merge(); - } + if (get_can_ff(&orig_head, &merge_heads.oid[0])) { + /* 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 Tue Dec 8 00:26:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957203 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.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,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 AA2A5C4167B for ; Tue, 8 Dec 2020 00:28:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CA2623A04 for ; Tue, 8 Dec 2020 00:28:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728650AbgLHA2N (ORCPT ); Mon, 7 Dec 2020 19:28:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728645AbgLHA2N (ORCPT ); Mon, 7 Dec 2020 19:28:13 -0500 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99F2DC06138C for ; Mon, 7 Dec 2020 16:26:59 -0800 (PST) Received: by mail-ot1-x343.google.com with SMTP id b62so14358790otc.5 for ; Mon, 07 Dec 2020 16:26:59 -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=vykQSok/eZns+ORGhIYQlK+pzsgI831hsB1aSrSXMWg=; b=BKQchG0MvuEA9WhHcjWqyLTugml/HxKKw8a2PynC5fJmo6rhCTwwLLkKVU57jEkuQE FbI/L4KLhpzAL0ZjwME0MgFw37mqH7TtaFKPUdGc4HZJWxgC/whk5I3bwQUQdysXiiFq MQxa2d8RQrinh2sPZemjtmadBpQjsRWqE0FpNM9uIkiTZBZ5jksgPRUi/YpCqJk0Y/3C xdePlO6lSZjVgkd1MhO0/pWe1uEQ6yu6WU+eVwrB9EnQ4gOONYPyWV8Q7xwx7e+g4aLt 5xOpMojsjCvOtoymk3OgrX5U+rp978sPSz4y2ay7Jl5PZP6h+iQ8YV4/j0cXUS5VoDmF 3Qyg== 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=vykQSok/eZns+ORGhIYQlK+pzsgI831hsB1aSrSXMWg=; b=BWE5LhRu+vd7ePkoZH5unGvLp09YyW85f8g8BxKegRllNpnvrU6pBDRH5XOpehH5Rw 21JTdQHwertU74obFoqs5tkHVcDTwvSRwKwSPT7rK/U0iK3eh5SpMQsb2Guu91WmodV1 jiqSGblWtT4FnTGGU9o8a8hE6HRCDcQBtU40QSASK/gw1/DyrD5tDq7xJRkvWX//lpyd ku3mNY3CXePhEsKF3vUAh1gZDE9B/QAL72S9O9ROQyK6PFnPYqpyga6qFXd97f+dpwtQ LfJF+JBTRO3bfvQcYhmINwh7V1C+Dd2rm1ikCNCWefPTLZlUXJ2UC+Z4pl/0pw97m7+L U2Ag== X-Gm-Message-State: AOAM530ovl9ibp+2LAFFaqLs/T6O07Ve7ZZBhOaMRTJw3B/cwUAHPGJt RUXk0G3wdvFXrrgwQXXeHMvYluHDkAGSi/ej X-Google-Smtp-Source: ABdhPJw3Ih2hrp94dvYTydJDugLvRIy0HOuhR0LucKHynZ9vfTENld9ko7cEivgzZq0sYz2Onuf8VQ== X-Received: by 2002:a9d:4d05:: with SMTP id n5mr14940646otf.99.1607387218851; Mon, 07 Dec 2020 16:26:58 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id n190sm2981533oob.11.2020.12.07.16.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:58 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 05/19] pull: trivial cleanup Date: Mon, 7 Dec 2020 18:26:34 -0600 Message-Id: <20201208002648.1370414-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index d44ca2ffde..6aeca4aeae 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1041,7 +1041,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; @@ -1052,14 +1051,14 @@ 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 (get_can_ff(&orig_head, &merge_heads.oid[0])) { /* 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 Tue Dec 8 00:26:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957201 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.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,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 9CFD5C4361B for ; Tue, 8 Dec 2020 00:28:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C990239EF for ; Tue, 8 Dec 2020 00:28:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728654AbgLHA2N (ORCPT ); Mon, 7 Dec 2020 19:28:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728646AbgLHA2N (ORCPT ); Mon, 7 Dec 2020 19:28:13 -0500 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4441CC061285 for ; Mon, 7 Dec 2020 16:27:01 -0800 (PST) Received: by mail-oi1-x242.google.com with SMTP id x16so17628827oic.3 for ; Mon, 07 Dec 2020 16:27:01 -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=QkhDG3b3RniLLbtnc8hYE3uxSx5Awo6T7b6avTc03t4=; b=o3Qdysh2k0A0S7MqPg/AersSDD2xDnwFwZDNulCpZF+5NtU/mw8m0tEkHbxSc1GUev zrNjHtrQNLVUUFEU780fEyA9Hv5DAx9paqpSPaZGqXfG6zk3NAHDQB/wHxA+4lfpvcB7 mbY2IVfOk9XrRI9tLkgoWpxbuR+70mIpWrA5o/f+t2QZKK31OnzncKa+tOGKrY3RO7ej +Gd3O5Y15lWQ3ZmHUzZe8gd+JLMFi9OVBfIYVGhSe6apxSEzet6n2vlW9KYeQrtF0A8b bRVi+ny8mzR16TS8EXorsu0ql8NhnrjJBaQXJhAcsmmpq7PCRH8/dBfVwsnLzZ6udZDn T4Ww== 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=QkhDG3b3RniLLbtnc8hYE3uxSx5Awo6T7b6avTc03t4=; b=lpBl9MdGBd+JAgDDiNjvUXG7Eayw0RuaeRqmfVPP6Jho+e3Kgx2AOrzfTl6H8PNoa/ Kocp+qvkqvjbleMcfH7h+j3vWbI+YMd2GfTn7W7bcdvLnBEcT7sZW8wg0FIqxPmu9Cnw 9AkhavUemT07MFIdPZ0qxQgpSTQVJfOY1r77SamNylA1zIJ4l/OcaUdr2t0aQcKvI9o+ DF33RIclgwA0rkkfGDZMvc+4QqZct9Frhi3Nz3dVeiaXw5pgHj0ERIIDWVUFWhfXVlHX +kHx4gXYj+EBvfxiJh7n4NogtsbK6fcz9ExPE0Veb/xs0TvCmplxyoQ2K/KGI9WeIXsm IWNw== X-Gm-Message-State: AOAM530oVCmbteSTxWP2St2U9E9BGWy/Tj2LLu6ctMBPeF7nJGMtQJSV 6Zq+zcorXZui8N/usjHEQAW9RLT/yAqxhaaj X-Google-Smtp-Source: ABdhPJwYDDkpIeA6QM2lpR8JHYLvDLHY9pobVo/FYMXBB/RqmfYiYEZ/Arpt3fANz+de9TlBaOxGLA== X-Received: by 2002:aca:5594:: with SMTP id j142mr1017754oib.164.1607387220455; Mon, 07 Dec 2020 16:27:00 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id r19sm3026701ota.14.2020.12.07.16.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:26:59 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 06/19] pull: move default warning Date: Mon, 7 Dec 2020 18:26:35 -0600 Message-Id: <20201208002648.1370414-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Eventually we want to be able to display the warning only when fast-forward merges are not possible. In order to do so we need to move the default warning up to the point where we can check if we can fast-forward or not. Additionally, config_get_rebase() was probably never its true home. This requires a temporary variable to check if we are in the "default mode" (no --rebase or --no-rebase specified). But this is only temporary; another patch in the series gets rid of that. Signed-off-by: Felipe Contreras --- builtin/pull.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 6aeca4aeae..3b84ebf100 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -27,6 +27,8 @@ #include "commit-reach.h" #include "sequencer.h" +static int default_mode; + /** * Parses the value of --rebase. If value is a false value, returns * REBASE_FALSE. If value is a true value, returns REBASE_TRUE. If value is @@ -344,20 +346,7 @@ static enum rebase_type config_get_rebase(void) if (!git_config_get_value("pull.rebase", &value)) return parse_config_rebase("pull.rebase", value, 1); - if (opt_verbosity >= 0 && !opt_ff) { - 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" - "You can squelch this message by running one of the following commands:\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" - "\n" - "You can replace \"git config\" with \"git config --global\" to set a default\n" - "preference for all repositories.\n" - "If unsure, run \"git pull --no-rebase\".\n" - "Read \"git pull --help\" for more information.")); - } + default_mode = 1; return REBASE_FALSE; } @@ -944,6 +933,7 @@ 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 can_ff; if (!getenv("GIT_REFLOG_ACTION")) set_reflog_message(argc, argv); @@ -1039,6 +1029,23 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_rebase && merge_heads.nr > 1) die(_("Cannot rebase onto multiple branches.")); + can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); + + if (default_mode && opt_verbosity >= 0 && !opt_ff) { + 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" + "You can squelch this message by running one of the following commands:\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" + "\n" + "You can replace \"git config\" with \"git config --global\" to set a default\n" + "preference for all repositories.\n" + "If unsure, run \"git pull --no-rebase\".\n" + "Read \"git pull --help\" for more information.")); + } + if (opt_rebase) { int ret = 0; @@ -1052,7 +1059,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) submodule_touches_in_range(the_repository, &upstream, &curr_head)) die(_("cannot rebase with locally recorded submodule modifications")); - if (get_can_ff(&orig_head, &merge_heads.oid[0])) { + if (can_ff) { /* we can fast-forward this without invoking rebase */ opt_ff = "--ff-only"; ret = run_merge(); From patchwork Tue Dec 8 00:26:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957205 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 80939C433FE for ; Tue, 8 Dec 2020 00:28:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5814D23A04 for ; Tue, 8 Dec 2020 00:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728658AbgLHA2P (ORCPT ); Mon, 7 Dec 2020 19:28:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728655AbgLHA2P (ORCPT ); Mon, 7 Dec 2020 19:28:15 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2031C061257 for ; Mon, 7 Dec 2020 16:27:02 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id h18so10375383otq.12 for ; Mon, 07 Dec 2020 16:27:02 -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=habUPnnnxlYAPznzCqdlYUCrF6OMdG/MNePaYSfpy2M=; b=ql1t08S9J8T5KPQF46jvNUWamAyfBJ9UKoSeZC9MKSi+6IkqqQncsF+M7g/hsgMJgc 5g+wlN+KmmKr+K6rihnch+AvMRBqsc59SLzR92XtedMMk+RBBEy6PPDqPP72GAfGjq1Y BrfDpNIpCum/7B2kVUqlvmciNDHIG+oN8pKjbpTD6lTYvsQyu+1f2rM4FFAnaOUet43N 1vy67QWfF7Fv/5h+EVXb9pL0TNlmWeA1FHqr5QIiI5kWqUC1YN2be0qLSVauN79Y7KYV qip/bPJh/SG+evh2ag3fRW0pdz/SVCASmxlil8tf3pXdATM6l2cPocP+JCKA6dPDKol7 uSeQ== 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=habUPnnnxlYAPznzCqdlYUCrF6OMdG/MNePaYSfpy2M=; b=teH07zhgdWsSGnbnPQ+ZRMTupbfOL8QYog9EoVkJV872f6Cd2iq3k+F1dWNA+u+oY7 HdfSE2231Av+3rqNV39RtvsS4ERFCX4dSi3P+rDLcPBAXS6+ITn1/XqNQubiuJIhCnfs 1nfGUHRuSoA27TOUQGvqHMyfKhmqqyrLzDmMECar7AJtc5KnOuy/MZGBa3R1fy+qcJa6 F0c17k4jQwceyTSadPHwaGEO9IH+tHFuzVC+0jK5vcvug5Hv3DbW/wz36xB3qmg5HMIl vBhGPvM4CTCN02QTgAsOxg6AmducZhbzUo2qNrDMqB85eJ7YHabmDPQ0jaSqejXLjRKR vqVQ== X-Gm-Message-State: AOAM533ojbMgchHtu+bZLmtDneHzBBwKke+CiAnE7kZd84FRxGMgXk99 4csnkMpfcqNvAmTG03Ex90rf1WqQSVQZJ+43 X-Google-Smtp-Source: ABdhPJzrRX/VtZCX0Bqya2rfGKhTFHXBcTeKEpUY5mo/26LPWynX4SR8xqHQE49NHl7YlZAcCnyerA== X-Received: by 2002:a9d:ec5:: with SMTP id 63mr1996858otj.181.1607387222080; Mon, 07 Dec 2020 16:27:02 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id z9sm1700631otj.67.2020.12.07.16.27.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:01 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 07/19] pull: display default warning only when non-ff Date: Mon, 7 Dec 2020 18:26:36 -0600 Message-Id: <20201208002648.1370414-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-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 display the annoying warning on every pull... only the ones that are not fast-forward. This requires the tests to pick another base, so the merge is not fast-forward. And in the cases where --ff-only is specified add test_must_fail (since now they are non-fast-forward). Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 3 +++ builtin/pull.c | 2 +- t/t7601-merge-pull-config.sh | 28 +++++++++++++++++----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index e1605a81b3..2fb184ab5f 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -60,6 +60,9 @@ However, a non-fast-forward case looks very different. origin/master in your repository ------------ +By default `git pull` will warn about these situations, however, most likely +you would want to force a merge, which you can do with `git pull --no-rebase`. + 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 diff --git a/builtin/pull.c b/builtin/pull.c index 3b84ebf100..ab410d675f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1031,7 +1031,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (default_mode && opt_verbosity >= 0 && !opt_ff) { + if (default_mode && !can_ff && opt_verbosity >= 0 && !opt_ff) { 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" "You can squelch this message by running one of the following commands:\n" diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6774e9d86f..6b4adab8b1 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -28,7 +28,7 @@ test_expect_success 'setup' ' ' test_expect_success 'pull.rebase not set' ' - git reset --hard c0 && + git reset --hard c2 && git -c color.advice=always pull . c1 2>err && test_decode_color decoded && test_i18ngrep "hint: " decoded && @@ -36,54 +36,60 @@ test_expect_success 'pull.rebase not set' ' ' -test_expect_success 'pull.rebase not set and pull.ff=true' ' +test_expect_success 'pull.rebase not set (fast-forward)' ' git reset --hard c0 && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + +test_expect_success 'pull.rebase not set and pull.ff=true' ' + git reset --hard c2 && test_config pull.ff true && git pull . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and pull.ff=false' ' - git reset --hard c0 && + git reset --hard c2 && test_config pull.ff false && git pull . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and pull.ff=only' ' - git reset --hard c0 && + git reset --hard c2 && test_config pull.ff only && - git pull . c1 2>err && + test_must_fail git pull . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --rebase given' ' - git reset --hard c0 && + git reset --hard c2 && git pull --rebase . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --no-rebase given' ' - git reset --hard c0 && + git reset --hard c2 && git pull --no-rebase . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --ff given' ' - git reset --hard c0 && + git reset --hard c2 && git pull --ff . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --no-ff given' ' - git reset --hard c0 && + git reset --hard c2 && git pull --no-ff . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --ff-only given' ' - git reset --hard c0 && - git pull --ff-only . c1 2>err && + git reset --hard c2 && + test_must_fail git pull --ff-only . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' From patchwork Tue Dec 8 00:26:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957207 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.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,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 3AA39C4361B for ; Tue, 8 Dec 2020 00:28:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AAC423A04 for ; Tue, 8 Dec 2020 00:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728659AbgLHA2Q (ORCPT ); Mon, 7 Dec 2020 19:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbgLHA2P (ORCPT ); Mon, 7 Dec 2020 19:28:15 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1BBBC0611C5 for ; Mon, 7 Dec 2020 16:27:04 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id q25so2559516otn.10 for ; Mon, 07 Dec 2020 16:27:04 -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=M4mcn83DsMB5yCouEjda20f4zIKR9PizsgSx6M/zUz8=; b=M0fKvmEmqq/b39/N8D23K6mv3StzF/lCLq56DhoQuDfo38VuNQnS/FFyrNT9g75VML 8zmoOpvP8y7REk3e806dCFkHo9EqDowWHGf/fzl1mpvq0g39on+y8EzAdjWyf0n5k10o IUBERqscDC8+7js0ZbmIy7oAyfHfeXUnWK8T8Fz1/ssMFl+C1PmuWO29dKrgIpopuLbW hJ5TbBGSHOq+iSDFC/gNUYEh7HujFU/noaZ7o2gE1t8JsLFQLCxSJScgGkuePApyOK+V BZeJImlqnft7LsVBOa7qgIm/oqkdHQcyOEm9qH/LlgEiluj44OmBKIMJ7wux8K52mtsK hcsA== 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=M4mcn83DsMB5yCouEjda20f4zIKR9PizsgSx6M/zUz8=; b=p04ca/BTfUr6fqfrL7CBL+509u9Rp7Hp6q2vNwe7U3xpmlKxf1xeifLTJQLvec0/Ao EgFSI3TA1A2qxH30etOU+3xK1MJ2wjmhhsNo1f2W3VNyyRfnfwR3Gb/bfPqmGoRYhPz1 01Tm7v18yi61RYAN+Q4k3SNU9HPcv7CgxsE2j56qoBpdeVq6VpyqCliP4CwwtN5UGyL6 eZnbulONbt7Nho4ipl0metNBiGeMTWOnM5HxndpiweTPsXSv5aZcq8MbGsLfWA/PEWdE PNSy54mYwSm6q5ztSuMJwWVojsnSlSf+K78SIrv0JKMzISQzVIaGiTieKSW94zxjtBOP uVog== X-Gm-Message-State: AOAM533nKA8iKf4ynUYdmNZJHPOD42Kfw7zxElqtfUY9DLYPOKqN63/9 evAKfTHgLS09k/n6WEGV2au7dDNXV/UuhE84 X-Google-Smtp-Source: ABdhPJxJH9VSQDb4uHEOhrxeVKVjIRQb/oNTySW42YXDif9E0dn90xIx3mFA9cSVoQ2gZvuQwWo6eg== X-Received: by 2002:a9d:64da:: with SMTP id n26mr767821otl.283.1607387223872; Mon, 07 Dec 2020 16:27:03 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id c18sm3158125oib.31.2020.12.07.16.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:03 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 08/19] pull: trivial whitespace style fix Date: Mon, 7 Dec 2020 18:26:37 -0600 Message-Id: <20201208002648.1370414-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-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 ab410d675f..4c91dd291b 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -128,9 +128,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), From patchwork Tue Dec 8 00:26:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957209 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 27628C4167B for ; Tue, 8 Dec 2020 00:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7AB223A04 for ; Tue, 8 Dec 2020 00:28:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbgLHA2R (ORCPT ); Mon, 7 Dec 2020 19:28:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbgLHA2Q (ORCPT ); Mon, 7 Dec 2020 19:28:16 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25009C0611CA for ; Mon, 7 Dec 2020 16:27:06 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id h18so10375478otq.12 for ; Mon, 07 Dec 2020 16:27:06 -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=3f3M963Q1DaGohU8WNwVTKIRG8ZNG36/Yd3vo2HW6M0=; b=X5gb3DkchzBSG/Ub03LBjWWFv2u+HR+quchLLNJxejCIFeIK1sOqKJ0VWQq0a2pvRC gHGPj3WFYNyZ+WcOvDyi+Fue9LLfIceE3fT8bLBM0I/9581BX8jztmdpcmC8A26y1zRS vMPsZd7MmQvLA601dCbTU+eH1sS+NexMzQPXiuTSi3zXJCrk3CIi/ZNeG090pyaAnq3F jGjN4zxesU3rwLvEnZZJGw+5OtPc7UvpCUyRNlmbodNQCdVE1WefP451TuHfT+ssxOPl C8LjrRiT5pFqfftSxseL9yj69M6yFdim+O0toAuqJbRibTF+VM2BupVKyCpqKfhxJISj 0tEg== 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=3f3M963Q1DaGohU8WNwVTKIRG8ZNG36/Yd3vo2HW6M0=; b=M6q2W+lnm3hIz0t+sp90pb4N61FH8ljruGDUiWljKrsiIwbd9GRAHOr39llg6v8RVM FpI11BFdAXWXLZr6wZkg98bCjYYLpKoGibiL1W/NMw6+mshmU/mGd6V9TGjhR8p0+qIe Kgy3/LMSxpCKgAWAa4lxaC8Lb3d1M+P5M8Be7sfMBP9xk21gQnYCzU5i1dGcMXDdSuxx NS3s33J7PeNLlepHcdxNvtIvhCcKRXsdpcl60iKKR+WPUADrOo5LWgrkJ1B70D06bw2y bIxmPP6VQ4x/vbBp1VM1AaYjI7UHf31ovG1OupBuxYx3gFWMKW0fnHGeRqxBnEbU0yCF sZFA== X-Gm-Message-State: AOAM530VxCvHOqSh9dymZE2TxdAoAzWcpeZsU7k6pWYpj8n0xx76IE9n TKRXxkO9MkhjtpG76SpdfSfOL0tYt+jurBau X-Google-Smtp-Source: ABdhPJyNPtWQK2xY7YaVhc6hDvaP86PN5lQlDGjqy6BU95EK2UyyEbUKbN5gDGd8YbXeVUlvkYytmQ== X-Received: by 2002:a9d:6207:: with SMTP id g7mr14465893otj.22.1607387225330; Mon, 07 Dec 2020 16:27:05 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id q18sm2712256ood.35.2020.12.07.16.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:04 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 09/19] pull: introduce --merge option Date: Mon, 7 Dec 2020 18:26:38 -0600 Message-Id: <20201208002648.1370414-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Previously --no-rebase (which still works for backwards compatibility). Now we can update the default warning, and the git-pull(1) man page to use --merge instead of the non-intuitive --no-rebase. Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 9 ++++++--- builtin/pull.c | 4 +++- t/t7601-merge-pull-config.sh | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 2fb184ab5f..21b50aff77 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -61,7 +61,7 @@ However, a non-fast-forward case looks very different. ------------ By default `git pull` will warn about these situations, however, most likely -you would want to force a merge, which you can do with `git pull --no-rebase`. +you would want to force a merge, which you can do with `git pull --merge`. Then "`git pull`" will fetch and replay the changes from the remote `master` branch since it diverged from the local `master` (i.e., `E`) @@ -148,8 +148,11 @@ It rewrites history, which does not bode well when you published that history already. Do *not* use this option unless you have read linkgit:git-rebase[1] carefully. ---no-rebase:: - Override earlier --rebase. +-m:: +--merge:: + Force a merge. ++ +Previously this was --no-rebase, but that usage has been deprecated. Options related to fetching ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/builtin/pull.c b/builtin/pull.c index 4c91dd291b..3874434421 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -131,6 +131,8 @@ static struct option pull_options[] = { "(false|true|merges|preserve|interactive)", N_("incorporate changes by rebasing rather than merging"), PARSE_OPT_OPTARG, parse_opt_rebase), + OPT_SET_INT('m', "merge", &opt_rebase, + N_("incorporate changes by merging"), REBASE_FALSE), 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), @@ -1042,7 +1044,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) "\n" "You can replace \"git config\" with \"git config --global\" to set a default\n" "preference for all repositories.\n" - "If unsure, run \"git pull --no-rebase\".\n" + "If unsure, run \"git pull --merge\".\n" "Read \"git pull --help\" for more information.")); } diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6b4adab8b1..1de64e6cc5 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -69,9 +69,9 @@ test_expect_success 'pull.rebase not set and --rebase given' ' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' -test_expect_success 'pull.rebase not set and --no-rebase given' ' +test_expect_success 'pull.rebase not set and --merge given' ' git reset --hard c2 && - git pull --no-rebase . c1 2>err && + git pull --merge . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' From patchwork Tue Dec 8 00:26:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957211 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.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,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 4866CC197BF for ; Tue, 8 Dec 2020 00:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F8B023A22 for ; Tue, 8 Dec 2020 00:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728666AbgLHA2R (ORCPT ); Mon, 7 Dec 2020 19:28:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728660AbgLHA2Q (ORCPT ); Mon, 7 Dec 2020 19:28:16 -0500 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 C77BEC0611CB for ; Mon, 7 Dec 2020 16:27:07 -0800 (PST) Received: by mail-ot1-x32b.google.com with SMTP id x13so6834567oto.8 for ; Mon, 07 Dec 2020 16:27:07 -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=kMAJv4uj8ftdk5LXHn2yCEjBfJ/TR6LfKZhTE9hG4fI=; b=aEDcFAllCxmYmyw2muyQf2jMZQnRb9D3VlLQGOZKOY/JoKdrZjyMP2fLM2HaR9JpCA xjgGRvUnEZ3PDV9QAWxzf4oPEmclcvWa8+bFMcAamH1l1YjAh2MqYtlNnk3FFamfCxPT 82XEopWCOnK2PMNHcIXH0ZjyONcXxvo8vHYjFUjvy/EkMmn5ei6kXccJyqR4nZDf9dZB SJQ5Ap7CL2NScBq4bunTCZ6FyJK1uCrRcRaspRGYVvW5rONUsukytYb0Fb3rHvX1ibn5 yuWUnY6eCUJfTO/yTyb2g8PZsqtlYaTVqixME7NUKsgFGVsYUiM+b6jlmQnDK29y3US7 il9Q== 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=kMAJv4uj8ftdk5LXHn2yCEjBfJ/TR6LfKZhTE9hG4fI=; b=pZvdc4Us+XpKwhzGsy0bNvFb7iOyKuSatOLV32t5A86OAyP9QsHo8IeNz9HVtKta4a 355XQrh40aEHN0cZt4InTb/g5xxSUHQjtcqjYX4469Yv3Iswy2EiSi+Gfdb4fzkY/xao u6rTc9p0DDF7UGSemB3KSRB7D1yu2oFXPBP56mEuhSmHC1o1F/aRPaUVsTx2SEa4VbdK t7UwNe3C0oso5uOI4dOaQ8HNUTyoW572MWl1YpBVYHkFkmhVM/oble4g/JbxvZtzx17g 6I2c2mhjiYkGmZ6t58C+5KdpTeu1SNxuTTCHOKs9aneCsQTW7spJegzRPtUHwtfzccsR MY9Q== X-Gm-Message-State: AOAM530YuXACkKHhvNcfeWSAp5yDOoi2hrRb7uGJPwooj/iFPQS2xuAz UV3YuCtOIZTQbiG0mUz9R/e4mfefpn5H9stM X-Google-Smtp-Source: ABdhPJyXBI9iWBY/+gHmztwkLOchhhise2mfJyrs9O1MwnfCkL0fWXZRh9sgFNAo3EI2V5VKmGq5qA== X-Received: by 2002:a05:6830:4036:: with SMTP id i22mr3387844ots.127.1607387226899; Mon, 07 Dec 2020 16:27:06 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id s189sm3331898oia.7.2020.12.07.16.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:06 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 10/19] pull: show warning with --ff Date: Mon, 7 Dec 2020 18:26:39 -0600 Message-Id: <20201208002648.1370414-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's unclear why --ff should remove the warning, since: git pull --ff Is implicitly the same as: git pull Unless of course pull.ff is specified otherwise. Signed-off-by: Felipe Contreras --- builtin/pull.c | 2 +- t/t7601-merge-pull-config.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 3874434421..f5bdae680f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1033,7 +1033,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (default_mode && !can_ff && opt_verbosity >= 0 && !opt_ff) { + if (default_mode && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { 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" "You can squelch this message by running one of the following commands:\n" diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 1de64e6cc5..d709799f8b 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -46,7 +46,7 @@ test_expect_success 'pull.rebase not set and pull.ff=true' ' git reset --hard c2 && test_config pull.ff true && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and pull.ff=false' ' @@ -78,7 +78,7 @@ test_expect_success 'pull.rebase not set and --merge given' ' test_expect_success 'pull.rebase not set and --ff given' ' git reset --hard c2 && git pull --ff . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --no-ff given' ' From patchwork Tue Dec 8 00:26:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957213 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 82A96C433FE for ; Tue, 8 Dec 2020 00:28:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AE9523A04 for ; Tue, 8 Dec 2020 00:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728671AbgLHA2U (ORCPT ); Mon, 7 Dec 2020 19:28:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA2T (ORCPT ); Mon, 7 Dec 2020 19:28:19 -0500 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41568C0611CC for ; Mon, 7 Dec 2020 16:27:09 -0800 (PST) Received: by mail-ot1-x332.google.com with SMTP id 11so14337212oty.9 for ; Mon, 07 Dec 2020 16:27:09 -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=0m5bCYu2A+ygXSPWwHnLigdWBuets4CxIRyPFOoEgDk=; b=k2uMycxdWV6kS3rCfSghVHGfFQUpLuxDhUSZtIF6B6WlgGw96+yjK2YDl/JEEHaV6m HG1HPgvne4BWaJf/ejEz8yUMeet3t0fGPjch4P7mbPRBoOA2+T3pUJKLPyTPgytmrFtu ycJUDHO/5w2bQuLkdmIo/PtLr4pFsPKrKdbx8kNZhQAweEjAkvAVAYsiIqcgJZUrqlea WMOzs6ntpExNAcWkDe9IWRGoglb5JFMJwDRHZOY2tAQ12SKReaP5lPlQjZEVY4YK33Dn PpFnQ7SwkI6IbYryy+ysq6fx+9Gp2ioE5tf5cl0COf9yIwopsc7qPeIGEo2zRyFUT08V wVRg== 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=0m5bCYu2A+ygXSPWwHnLigdWBuets4CxIRyPFOoEgDk=; b=Cn8I1+wiX754CToBbOcmJxBhKK/IJBIpGt8B3YkDQuurR90NvNjXQj/0Rqp3RcABWr 05MIyge/W1Ib0Bgm0KToziD2Tq0JXHn8N+TLOWMlyGyH8L1fWTjMH2IuF1hLweYQJ5Kp GHZOGapKIxACa9EQuxgIZ5dOMZP1P5GUZQXt+vmnBp5YQbDF8kjbNSXCaXdHqbFLCJL8 nht3knKAiCx5OKt8LaPrdlY07ulWd65zRK6ol81wBbqkdNkPk7avrJrKV3wTvsMoU64d kHIGLuVsVriky9mSo7jQjfHl36ibhEOXm2byJcHzT7M4lKYP1f2iRG0v6n9A6CXvt7az GKfA== X-Gm-Message-State: AOAM533oJn3rs8M0qaGCvkXcYxEbR9qJduFb7gA4exjXhAQTFBcqMdwS sJcByUYS2+VtxXcWzXx7k3vD7qTLAj15QI8h X-Google-Smtp-Source: ABdhPJyV4zKS9VybKZfrI0MENRsjXwHdCBJZepnlb2G29pWIxorBcxQt13/VUF3cBnK7R4/1MhS8rg== X-Received: by 2002:a05:6830:10:: with SMTP id c16mr7312121otp.162.1607387228342; Mon, 07 Dec 2020 16:27:08 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id d194sm3338637oig.3.2020.12.07.16.27.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:07 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 11/19] rebase: add REBASE_DEFAULT Date: Mon, 7 Dec 2020 18:26:40 -0600 Message-Id: <20201208002648.1370414-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org By introducing a default we can distinguish when the user has forced an option. Therefore there's no need for an extra "default_mode" variable (it's the same as opt_rebase == REBASE_DEFAULT), not is there any need to initialize opt_rebase to an invalid value. Signed-off-by: Felipe Contreras --- builtin/pull.c | 24 ++++++++++-------------- rebase.h | 3 ++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index f5bdae680f..350df6f3c5 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -27,8 +27,6 @@ #include "commit-reach.h" #include "sequencer.h" -static int default_mode; - /** * Parses the value of --rebase. If value is a false value, returns * REBASE_FALSE. If value is a true value, returns REBASE_TRUE. If value is @@ -76,7 +74,7 @@ static char *opt_progress; static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT; /* Options passed to git-merge or git-rebase */ -static enum rebase_type opt_rebase = -1; +static enum rebase_type opt_rebase; static char *opt_diffstat; static char *opt_log; static char *opt_signoff; @@ -348,9 +346,7 @@ static enum rebase_type config_get_rebase(void) if (!git_config_get_value("pull.rebase", &value)) return parse_config_rebase("pull.rebase", value, 1); - default_mode = 1; - - return REBASE_FALSE; + return REBASE_DEFAULT; } /** @@ -445,7 +441,7 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs const char *remote = curr_branch ? curr_branch->remote_name : NULL; if (*refspecs) { - if (opt_rebase) + if (opt_rebase >= REBASE_TRUE) fprintf_ln(stderr, _("There is no candidate for rebasing against among the refs that you just fetched.")); else fprintf_ln(stderr, _("There are no candidates for merging among the refs that you just fetched.")); @@ -458,7 +454,7 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs repo); } else if (!curr_branch) { fprintf_ln(stderr, _("You are not currently on a branch.")); - if (opt_rebase) + if (opt_rebase >= REBASE_TRUE) fprintf_ln(stderr, _("Please specify which branch you want to rebase against.")); else fprintf_ln(stderr, _("Please specify which branch you want to merge with.")); @@ -473,7 +469,7 @@ static void NORETURN die_no_merge_candidates(const char *repo, const char **refs remote_name = _(""); fprintf_ln(stderr, _("There is no tracking information for the current branch.")); - if (opt_rebase) + if (opt_rebase >= REBASE_TRUE) fprintf_ln(stderr, _("Please specify which branch you want to rebase against.")); else fprintf_ln(stderr, _("Please specify which branch you want to merge with.")); @@ -956,7 +952,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (!opt_ff) opt_ff = xstrdup_or_null(config_get_ff()); - if (opt_rebase < 0) + if (!opt_rebase) opt_rebase = config_get_rebase(); if (read_cache_unmerged()) @@ -968,7 +964,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (get_oid("HEAD", &orig_head)) oidclr(&orig_head); - if (opt_rebase) { + if (opt_rebase >= REBASE_TRUE) { int autostash = config_autostash; if (opt_autostash != -1) autostash = opt_autostash; @@ -1028,12 +1024,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) die(_("Cannot merge multiple branches into empty head.")); return pull_into_void(merge_heads.oid, &curr_head); } - if (opt_rebase && merge_heads.nr > 1) + if (opt_rebase >= REBASE_TRUE && merge_heads.nr > 1) die(_("Cannot rebase onto multiple branches.")); can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (default_mode && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { + if (!opt_rebase && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { 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" "You can squelch this message by running one of the following commands:\n" @@ -1048,7 +1044,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) "Read \"git pull --help\" for more information.")); } - if (opt_rebase) { + if (opt_rebase >= REBASE_TRUE) { int ret = 0; struct object_id newbase; diff --git a/rebase.h b/rebase.h index cc723d4748..34d4acfd74 100644 --- a/rebase.h +++ b/rebase.h @@ -3,7 +3,8 @@ enum rebase_type { REBASE_INVALID = -1, - REBASE_FALSE = 0, + REBASE_DEFAULT = 0, + REBASE_FALSE, REBASE_TRUE, REBASE_PRESERVE, REBASE_MERGES, From patchwork Tue Dec 8 00:26:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957215 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.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,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 2BCC0C4361B for ; Tue, 8 Dec 2020 00:28:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00FE923A04 for ; Tue, 8 Dec 2020 00:28:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728669AbgLHA2U (ORCPT ); Mon, 7 Dec 2020 19:28:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728660AbgLHA2T (ORCPT ); Mon, 7 Dec 2020 19:28:19 -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 E553EC0611CD for ; Mon, 7 Dec 2020 16:27:10 -0800 (PST) Received: by mail-oo1-xc42.google.com with SMTP id f8so3663598oou.0 for ; Mon, 07 Dec 2020 16:27:10 -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=FIiIvKGrRC9ZgYiQSc1H/0su0AeBYRauG0YEoj/P8M8=; b=vK5YCgR1qhFwfveeactIR8dG8xDJbC+/JWEfM6H3p/qeVOY3OcFVixZqpYQvXvw3q1 x85fRzCEvXVrhZSYYCLdOeyNnC35ELAxjYQPgXokZm5Te6vcZwY8WXTlTfqpm/jwfzTe zZCI5DkPttNhdgLhezCUIODj22cwCZOQJZioSPQV32rETREvPrPEFSGaugh/d+1GN5pb 9RHbSdYyaLKv9wnFvoPmxT6n15HuFj6K9G5Ed92+TysG9RG7J9GeFh+7Se1BIohUEn1z SdFzLiRcAfcU0+qGA6/4Ng974Czp2ckcPtvy18S4L1oBR0RYstWmtG7aYfSI4tXm3Fxl JlXg== 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=FIiIvKGrRC9ZgYiQSc1H/0su0AeBYRauG0YEoj/P8M8=; b=YaP2dSYqiMd9jUO9KY5XwbJSXRYLUGR6raJUS5M80JjOCsu+BpTMqcsfkuo034sud9 nhkyU+eMIGL5FzdqIwJYHDEpJa42V0K3pinsqKsOSJLK/Bdf47nJoC56IS9Qz44ZJJ4V sQjQc5FfRphYenrq8V44JhX5/82EcihHvKBvSnJoELE6aXkmp3K3c2HbjpzOwfqzvNmy y6bD5R22FhYnYnZEfk04dz9RFrqhdsJECcuAVAYHtYl9xmqcAaeptqpz1PijyCXgnk5K iAlIJ17hfTbangffKGf1a0FUrrVjv4sYHQ6xakjqyALZ9xh5XPmosggeIOW458mRSoZv Ri4w== X-Gm-Message-State: AOAM533yy+xhKXDgC3WM1FmF6eivlP0fOQR89H8NlZ/rs9PG9mX6ONov YoNFFIktR1bFm/MVc3sXHf8jcFg1ML553qrZ X-Google-Smtp-Source: ABdhPJzLX9rnhNO6PjGsC9+Tux2fb0ZiLvR8PBLpffMfqc4YLfUs76xo3j82xS37ZduZqp3E7qd/+w== X-Received: by 2002:a4a:6152:: with SMTP id u18mr14319505ooe.7.1607387230139; Mon, 07 Dec 2020 16:27:10 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id v5sm2973158oob.40.2020.12.07.16.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:09 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 12/19] pull: move configurations fetches Date: Mon, 7 Dec 2020 18:26:41 -0600 Message-Id: <20201208002648.1370414-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we have FETCH_DEFAULT we can fetch the configuration before parsing the argument options. The options will override the configuration, and if they don't; opt_rebase will remain being FETCH_DEFAULT. Signed-off-by: Felipe Contreras --- builtin/pull.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 350df6f3c5..addb454e63 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -933,6 +933,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) struct object_id rebase_fork_point; int can_ff; + opt_ff = xstrdup_or_null(config_get_ff()); + opt_rebase = config_get_rebase(); + if (!getenv("GIT_REFLOG_ACTION")) set_reflog_message(argc, argv); @@ -949,12 +952,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) parse_repo_refspecs(argc, argv, &repo, &refspecs); - if (!opt_ff) - opt_ff = xstrdup_or_null(config_get_ff()); - - if (!opt_rebase) - opt_rebase = config_get_rebase(); - if (read_cache_unmerged()) die_resolve_conflict("pull"); From patchwork Tue Dec 8 00:26:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957221 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.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,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 175A0C433FE for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C67D0239EF for ; Tue, 8 Dec 2020 00:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728682AbgLHA20 (ORCPT ); Mon, 7 Dec 2020 19:28:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728678AbgLHA2Z (ORCPT ); Mon, 7 Dec 2020 19:28:25 -0500 Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFF4EC0611CE for ; Mon, 7 Dec 2020 16:27:12 -0800 (PST) Received: by mail-oo1-xc34.google.com with SMTP id q20so1890424oos.12 for ; Mon, 07 Dec 2020 16:27:12 -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=uWptlYuhXDCZAz0F+eIUPJTkgpL8Oxwz7vgAz6RQJ08=; b=fhWY3ahhNMCfmMlPDMOVOslN69oMTHuYac98Tqji6pVL47IUPWB1LOsJMGWCtVQ934 oy79u8bCLqhpXvZzUI9c7ON46zeHM6T8eRBLDLI5pTTVQGTEhbxDhpJcYOJ+FPWqpoq7 T+vmM3r9OcXv/O9GqoFXVOAnE0LCiHiwDaO+qf0LmYetfritp5UzD/P4IQuOybRz39EU Nuz5aqznyyQR2p4kEQzjbz6CGMfjWB7VF9Jp1juVfT2AYfSzTUEuG0cd5taOxXkofKJu HHWhBcPTVCM5t0zYDIJxSkZB3pWdEoyF+tks6mUJ88qlXLVp+PwbjmXYFV2iuZe/rH9d 1LYw== 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=uWptlYuhXDCZAz0F+eIUPJTkgpL8Oxwz7vgAz6RQJ08=; b=DAS3TIISjKCgM42V7Ws4560p6ld+ybr7IBqeiWNAW5PixXt/2jR2MPLztrDjEM5Uwz eoQj6tAa+BgTjNISoBg0kqPbUZ7uXc32AmaRobRZVnNKLI1cHpDvV+wkW6qjW3cnYvW1 YqbHxLCNX8aXN4a8c1bcJChx/RnboL+nP1Yll/LNPfLhR9DP+PTrGHtyK9ZjFlNh9ZOF bHyFnjrGIh4fypiBqU81MgaWy1NQ7PVDK+c3npqAGw87i+OXMbhe3Rd+I+1v8iUvU5Kc 2WzZnxE+yIhscllcHjQREho5+9FLa/ybO+vpdPkq5SdLyo9gpkis+9MgE+jHk2MCLlvW AyRg== X-Gm-Message-State: AOAM533PmFrDSNnaFex4vCkfGdYJ3F1MfNRrM2+niMzRFowwAy1GjKga PX6DOspQmD7qp/Tro+vjTOUqdY8+dARtWMNC X-Google-Smtp-Source: ABdhPJzKlDL4anH/gYoTZSD18RoTNry1PbJSMXlLiJYdy3uGvMwXSO7449FvDPl3fRr0AsitC0YvnQ== X-Received: by 2002:a4a:b144:: with SMTP id e4mr14579735ooo.3.1607387231767; Mon, 07 Dec 2020 16:27:11 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id s189sm3331938oia.7.2020.12.07.16.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:11 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 13/19] test: merge-pull-config: trivial cleanup Date: Mon, 7 Dec 2020 18:26:42 -0600 Message-Id: <20201208002648.1370414-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Commit e01ae2a4a7 introduced an extra space. Signed-off-by: Felipe Contreras --- t/t7601-merge-pull-config.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index d709799f8b..8a6aae564a 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -33,7 +33,6 @@ test_expect_success 'pull.rebase not set' ' test_decode_color decoded && test_i18ngrep "hint: " decoded && test_i18ngrep "Pulling without specifying how to reconcile" decoded - ' test_expect_success 'pull.rebase not set (fast-forward)' ' From patchwork Tue Dec 8 00:26:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957217 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.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,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 16AA1C433FE for ; Tue, 8 Dec 2020 00:28:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDE29239EF for ; Tue, 8 Dec 2020 00:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728684AbgLHA20 (ORCPT ); Mon, 7 Dec 2020 19:28:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA2Z (ORCPT ); Mon, 7 Dec 2020 19:28:25 -0500 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BB46C0611CF for ; Mon, 7 Dec 2020 16:27:14 -0800 (PST) Received: by mail-oo1-xc31.google.com with SMTP id w9so3632005ooh.13 for ; Mon, 07 Dec 2020 16:27:14 -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=32vlhwz0aXXfZWItJvhvqAt2z1EPs0fSK/cBA/4mVks=; b=EhmLsuYR3gEmycMKiV5g10wWJ6QS+dsrwgWHd8ZulfFKxuVkITDi9LnhkUMJX+RsAv U9LNybItlL5RJekn8d7a94AgOAMnshz7B8y90TotWCLjhlRx7FQqdfg3SPHuNlQHI4dn RH+zYowPfkrDNlvdZAZTF2xkT6u0ul+AGwc4Kc6v4ncdcZc8ZC+BZ5kgnml/53FKSrO2 xKurAdyDLtUAo+nt0eLPnxc9KHdz3cp0Nf2Tq6TfA0h+bg83C3CCCTvo+tpeOUvmoQGD b89YcjVwD4ZkjGkzxIxz6smcv4aVxmjHndQdgj5lmJVMtM4/UpGH3biAbvsMgIoXIWDJ q4pQ== 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=32vlhwz0aXXfZWItJvhvqAt2z1EPs0fSK/cBA/4mVks=; b=cJrr4ogHV8GYQY4PgNZPzzJT5IjDT43Eg4Q8QJR6cxWZNoxcERPmk7BYa9qHmid0F6 K52wTZH+aFXjARvLINRd9XNKE0/R/bYO+zfln/6M5vzgh6KLBZQXepGRC38b9ReC7VXI li4sEEDm8DXOOU6DqQtkLTSH0hnRLgeMbz10cN7djL3xtNRygrb9DjsjYNiHdVOaGvQ1 VMa7Jc/vBDI791wG+hIgO49EcKc+eCEWfwpPbrGiLSL2mV9owye6aWXnUpvtt0Rt9OTL AtYbNocr8Dez/dZVFv5ktxRmmM3HWEPiCOZ3+cF/WmU/KVKNjdMY+9fJfS5SF7cAaWNZ P/GA== X-Gm-Message-State: AOAM530NuMNjFmXQ/Ws5END090bu3svx0inMlFVMA2aKPYj0/vQ/OXfL L5z0wPJgoE3ibONdTgZgG//N2m8AgU+QQWlh X-Google-Smtp-Source: ABdhPJwbgL8dyulDnto0F6Phgie7i8pzDZJYKRBqbtt5jLZS+D1rnIr/CPJyWwbnc9duQZLaXr5UWw== X-Received: by 2002:a4a:8606:: with SMTP id v6mr14457893ooh.37.1607387233355; Mon, 07 Dec 2020 16:27:13 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id k10sm3023244otn.71.2020.12.07.16.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:12 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 14/19] test: pull-options: revert unnecessary changes Date: Mon, 7 Dec 2020 18:26:43 -0600 Message-Id: <20201208002648.1370414-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Commit d18c950a69 (pull: warn if the user didn't say whether to rebase or to merge, 2020-03-09) changed a number of tests in t5521 and added some new tests in t7601, but it was not explained why the changes in t5521 were made. The reason seems to be to silence the warnings while running the tests, but we want to see the warnings if they happen. Cc: Alex Henrie Signed-off-by: Felipe Contreras --- t/t5521-pull-options.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh index db1a381cd9..1a4fe2583a 100755 --- a/t/t5521-pull-options.sh +++ b/t/t5521-pull-options.sh @@ -11,10 +11,10 @@ test_expect_success 'setup' ' git commit -m one) ' -test_expect_success 'git pull -q --no-rebase' ' +test_expect_success 'git pull -q' ' mkdir clonedq && (cd clonedq && git init && - git pull -q --no-rebase "../parent" >out 2>err && + git pull -q "../parent" >out 2>err && test_must_be_empty err && test_must_be_empty out) ' @@ -30,10 +30,10 @@ test_expect_success 'git pull -q --rebase' ' test_must_be_empty out) ' -test_expect_success 'git pull --no-rebase' ' +test_expect_success 'git pull' ' mkdir cloned && (cd cloned && git init && - git pull --no-rebase "../parent" >out 2>err && + git pull "../parent" >out 2>err && test -s err && test_must_be_empty out) ' @@ -46,10 +46,10 @@ test_expect_success 'git pull --rebase' ' test_must_be_empty out) ' -test_expect_success 'git pull -v --no-rebase' ' +test_expect_success 'git pull -v' ' mkdir clonedv && (cd clonedv && git init && - git pull -v --no-rebase "../parent" >out 2>err && + git pull -v "../parent" >out 2>err && test -s err && test_must_be_empty out) ' @@ -62,25 +62,25 @@ test_expect_success 'git pull -v --rebase' ' test_must_be_empty out) ' -test_expect_success 'git pull -v -q --no-rebase' ' +test_expect_success 'git pull -v -q' ' mkdir clonedvq && (cd clonedvq && git init && - git pull -v -q --no-rebase "../parent" >out 2>err && + git pull -v -q "../parent" >out 2>err && test_must_be_empty out && test_must_be_empty err) ' -test_expect_success 'git pull -q -v --no-rebase' ' +test_expect_success 'git pull -q -v' ' mkdir clonedqv && (cd clonedqv && git init && - git pull -q -v --no-rebase "../parent" >out 2>err && + git pull -q -v "../parent" >out 2>err && test_must_be_empty out && test -s err) ' test_expect_success 'git pull --cleanup errors early on invalid argument' ' mkdir clonedcleanup && (cd clonedcleanup && git init && - test_must_fail git pull --no-rebase --cleanup invalid "../parent" >out 2>err && + test_must_fail git pull --cleanup invalid "../parent" >out 2>err && test_must_be_empty out && test -s err) ' From patchwork Tue Dec 8 00:26:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957219 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.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,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 2D1EDC4361B for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF0F623A04 for ; Tue, 8 Dec 2020 00:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728689AbgLHA22 (ORCPT ); Mon, 7 Dec 2020 19:28:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA22 (ORCPT ); Mon, 7 Dec 2020 19:28:28 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1CFFC0611D0 for ; Mon, 7 Dec 2020 16:27:15 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id h19so14383802otr.1 for ; Mon, 07 Dec 2020 16:27:15 -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=omRN6cu9jlXBiqEmC3Q+sivLK1sz2Rnpfu7HmctbeU4=; b=gePo0YefrPeiLEtO6BSpzUWMdEsKhEZPUp7GYOSsUdi8D+HWyi4eknQvId4T7qvV68 Vt0q3sskEQ6sU6frc31fvieG1muyxja+/h0eQOX7ID6Aojj6pu7RSL7A0RoExwUqBtDP ftsht4wd/Y48vJhC3RITkivUNxwlO2Xn+WLjkpF8zE6FnaZTLQnji1Lz+Qm2qDjMJUyo Aa9JX78GA5/IBtIqIUEoD99heYUn5VuBeo2vdakbOi5JwNqc6IhOyKJT8nyitrYv+C/B BVoS6cBk5fkz2jeNWq72wcHsL5JPrshLGSnDn4RxsaSRbI5AM9vp/9r85tp06vAPKFVM vcxw== 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=omRN6cu9jlXBiqEmC3Q+sivLK1sz2Rnpfu7HmctbeU4=; b=fOZvs0ee8TcDeRMpqGNhSwg5yI8Eq89+jFW9uETrB6TzZGMiNXaOx1pL5oCvPSOr9u XJvvDgYi6JWap51lhbzRG5Ff+QkEXzGwZZoU8OnniZM45JOo6j/VUI6yMyHJsVPlUZlG aYeT6SJ9xwJk7fj4RSJhLQewPOj/hrRNQGICBQiIH8nPdb8VpYI5eaESoh+pZ4rYW/z9 Yuq5hruTYHR2239ryG8ixleyatKfdr8MntMGEqtSpfOGo9Ci5/AoKuvLWrulSkfFXwIj Ae9fYQBgrLOVW8by7iP0DY/pqI5VVGAWFEF7Qv5yA/CWI7Aai/HkpyAcFsVHvQeeXe+H KiLg== X-Gm-Message-State: AOAM531TXr8uix9YMoReeWU3wz7cvHIIoGCLGfGOPWL/WHweOpRWTnib 6fnSP0hOz1jPmer9mfAKvBeMeeOGFQpK4igC X-Google-Smtp-Source: ABdhPJwMA1+xhxScbjbOBn02E68BxxyyeRsOMdo1jHoV9Llhsz6mYEE4EmzsSNorNvDEajj/LodGag== X-Received: by 2002:a05:6830:1458:: with SMTP id w24mr2151473otp.66.1607387235031; Mon, 07 Dec 2020 16:27:15 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id m109sm3018542otc.30.2020.12.07.16.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:14 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 15/19] pull: trivial memory fix Date: Mon, 7 Dec 2020 18:26:44 -0600 Message-Id: <20201208002648.1370414-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The opt_ff variable is supposed to have an allocated string (strdup), we can't just overwrite it with a const char *. Functionally it doesn't matter, since after this point opt_ff is never freed, only accessed, but still... It's better to be consistent. Signed-off-by: Felipe Contreras --- builtin/pull.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/pull.c b/builtin/pull.c index addb454e63..118fbdeb62 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1056,7 +1056,8 @@ 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"; + free(opt_ff); + opt_ff = xstrdup_or_null("--ff-only"); ret = run_merge(); } else { ret = run_rebase(&newbase, &upstream); From patchwork Tue Dec 8 00:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957227 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.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,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 66ECCC0018C for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2479B239EF for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728698AbgLHA2g (ORCPT ); Mon, 7 Dec 2020 19:28:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA2e (ORCPT ); Mon, 7 Dec 2020 19:28:34 -0500 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C831FC0611E4 for ; Mon, 7 Dec 2020 16:27:17 -0800 (PST) Received: by mail-oo1-xc44.google.com with SMTP id k9so964232oop.6 for ; Mon, 07 Dec 2020 16:27:17 -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=b+JU+H8odgkCR4y5wP1x8X+yM+DdAZrJ4ITDgCktrRo=; b=l9QjJQI9ZhJqSbyd8TaGpy3rs7WlDnrnE/fGkS4x4du9q35JY3LIg4Q2ltxOM9YnGw jJEP80V3kneBACN+awN8l/5SFJupQAh6nIEBKm8ocEitIvMy2DJRl6uR3MEw/cUoj8H7 1G121C+BNtr3wRfM5EebdRExqNq3EQO3ZGsmOBiEe6DAkynOKmg46u8XSW2l8AJjIyeX KS81/2jY5XFFp+2mpWGB1JkKq7F+aJLRqNupI9G/obzSsTC/j/XmZpr8SsPKXBFSpJdi cEouZzPPHqmotkElmMmaAQi6iN6BooyTkGmw3NFhoUtuV4Nsl9K6AfhK2Bu5cmWvOB4r Frzg== 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=b+JU+H8odgkCR4y5wP1x8X+yM+DdAZrJ4ITDgCktrRo=; b=WfcJunSTj4d4YkWWPkDT9m1fBzvLZO8TSVvHBSIfus3mG524HZ1mX1BwPyznZz8Mds OfYL26Bif1SkFegEEHxMiLZXiOcyrQKeAJHagoT6QJC1DhilEpcLKCZdnBCyX/6gpi4U 9rvgE9Cl7temjIi8Q5tcwkRJKh0OyhGQXhLlfL4EObdhQkFOYNyEECCCOlx7I+d/0DYt h5uIicZ4KPKb4mLD0sScjRKTqHfak8Uj6X62Jcozl3cqWe9BjmaTIWw1P+5jXTFXcp9B TokT14E/LZZ9FZJOsy1gpEtG3gu2SVx+O3Bt6ZZwe7tT8/HWdJgTq6LdvOpIwPz4lfp8 rXvA== X-Gm-Message-State: AOAM531JMUbE8VsfCS05V3MPtROZLi7ep/iPJUxJf0Q7t64ay2BI0x5G DeMtTUX4/G6PDhK5iqY72Frx6i61/kSTcKBC X-Google-Smtp-Source: ABdhPJxXSIyvPevKUsSVBsCISPR17PmE/wVOjkkjMaMpmE/2LZayn7Lo/lYhYkzPUyZe0H2S+J5Veg== X-Received: by 2002:a4a:8606:: with SMTP id v6mr14458020ooh.37.1607387236745; Mon, 07 Dec 2020 16:27:16 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id f10sm2702140oti.11.2020.12.07.16.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:16 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 16/19] pull: add pull.mode Date: Mon, 7 Dec 2020 18:26:45 -0600 Message-Id: <20201208002648.1370414-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This way we can add more modes and the default can be something else, namely it can be set to "ff-only", so eventually we can reject non-fast-forward merges by default. Also 'branch..pullmode'. For now we simply override the rebase mode. And when any --rebase or --merge options are specified the mode is updated accordingly. Signed-off-by: Felipe Contreras --- Documentation/config/branch.txt | 6 +++ Documentation/config/pull.txt | 6 +++ builtin/pull.c | 70 +++++++++++++++++++++++++++++++-- builtin/remote.c | 19 ++++++++- rebase.c | 10 +++++ rebase.h | 9 +++++ t/t5520-pull.sh | 42 ++++++++++++++++++++ t/t7601-merge-pull-config.sh | 7 ++++ 8 files changed, 164 insertions(+), 5 deletions(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index cc5f3249fc..b57bf2c308 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -96,6 +96,12 @@ mode. it unless you understand the implications (see linkgit:git-rebase[1] for details). +branch..pullmode:: + When "git pull" is run, this determines if it would either merge or + rebase the fetched branch. The possible values are 'merge', and + 'rebase'. See "pull.mode" for doing this in a non + branch-specific manner. + branch..description:: Branch description, can be edited with `git branch --edit-description`. Branch description is diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index 5404830609..f4385cde33 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -29,6 +29,12 @@ mode. it unless you understand the implications (see linkgit:git-rebase[1] for details). +pull.mode:: + When "git pull" is run, this determines if it would either merge or + rebase the fetched branch. The possible values are 'merge', + and 'rebase'. See "branch..pullmode" for setting this on a + per-branch basis. + pull.octopus:: The default merge strategy to use when pulling multiple branches at once. diff --git a/builtin/pull.c b/builtin/pull.c index 118fbdeb62..7756c8aea1 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -27,6 +27,8 @@ #include "commit-reach.h" #include "sequencer.h" +static enum pull_mode_type mode; + /** * Parses the value of --rebase. If value is a false value, returns * REBASE_FALSE. If value is a true value, returns REBASE_TRUE. If value is @@ -49,6 +51,14 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value, return REBASE_INVALID; } +static enum pull_mode_type parse_config_pull_mode(const char *key, const char *value) +{ + enum pull_mode_type v = pull_mode_parse_value(value); + if (v == PULL_MODE_INVALID) + die(_("Invalid value for %s: %s"), key, value); + return v; +} + /** * Callback for --rebase, which parses arg with parse_config_rebase(). */ @@ -60,9 +70,21 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset *value = parse_config_rebase("--rebase", arg, 0); else *value = unset ? REBASE_FALSE : REBASE_TRUE; + + if (*value > 0) + mode = *value >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE; + return *value == REBASE_INVALID ? -1 : 0; } +static int parse_opt_merge(const struct option *opt, const char *arg, int unset) +{ + enum rebase_type *value = opt->value; + mode = PULL_MODE_MERGE; + *value = REBASE_FALSE; + return 0; +} + static const char * const pull_usage[] = { N_("git pull [] [ [...]]"), NULL @@ -129,8 +151,9 @@ static struct option pull_options[] = { "(false|true|merges|preserve|interactive)", N_("incorporate changes by rebasing rather than merging"), PARSE_OPT_OPTARG, parse_opt_rebase), - OPT_SET_INT('m', "merge", &opt_rebase, - N_("incorporate changes by merging"), REBASE_FALSE), + OPT_CALLBACK_F('m', "merge", &opt_rebase, NULL, + N_("incorporate changes by merging"), + PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_merge), 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), @@ -349,6 +372,29 @@ static enum rebase_type config_get_rebase(void) return REBASE_DEFAULT; } +static enum pull_mode_type config_get_pull_mode(void) +{ + struct branch *curr_branch = branch_get("HEAD"); + const char *value; + + if (curr_branch) { + char *key = xstrfmt("branch.%s.pullmode", curr_branch->name); + + if (!git_config_get_value(key, &value)) { + enum pull_mode_type ret = parse_config_pull_mode(key, value); + free(key); + return ret; + } + + free(key); + } + + if (!git_config_get_value("pull.mode", &value)) + return parse_config_pull_mode("pull.mode", value); + + return PULL_MODE_DEFAULT; +} + /** * Read config variables. */ @@ -935,6 +981,22 @@ int cmd_pull(int argc, const char **argv, const char *prefix) opt_ff = xstrdup_or_null(config_get_ff()); opt_rebase = config_get_rebase(); + mode = config_get_pull_mode(); + + if (!opt_rebase && mode) { + switch (mode) { + case PULL_MODE_MERGE: + opt_rebase = REBASE_FALSE; + break; + case PULL_MODE_REBASE: + opt_rebase = REBASE_TRUE; + break; + default: + break; + } + } else if (opt_rebase > 0) { + mode = opt_rebase >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE; + } if (!getenv("GIT_REFLOG_ACTION")) set_reflog_message(argc, argv); @@ -1031,8 +1093,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix) "you need to specify if you want a merge, or a rebase.\n" "You can squelch this message by running one of the following commands:\n" "\n" - " git config pull.rebase false # merge (the default strategy)\n" - " git config pull.rebase true # rebase\n" + " git config pull.mode merge # (the default strategy)\n" + " git config pull.mode rebase\n" " git config pull.ff only # fast-forward only\n" "\n" "You can replace \"git config\" with \"git config --global\" to set a default\n" diff --git a/builtin/remote.c b/builtin/remote.c index c1b211b272..51b1e675e3 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -269,7 +269,7 @@ static int config_read_branches(const char *key, const char *value, void *cb) char *name; struct string_list_item *item; struct branch_info *info; - enum { REMOTE, MERGE, REBASE, PUSH_REMOTE } type; + enum { REMOTE, MERGE, REBASE, PUSH_REMOTE, PULL_MODE } type; size_t key_len; if (!starts_with(key, "branch.")) @@ -284,6 +284,8 @@ static int config_read_branches(const char *key, const char *value, void *cb) type = REBASE; else if (strip_suffix(key, ".pushremote", &key_len)) type = PUSH_REMOTE; + else if (strip_suffix(key, ".pullmode", &key_len)) + type = PULL_MODE; else return 0; name = xmemdupz(key, key_len); @@ -324,6 +326,21 @@ static int config_read_branches(const char *key, const char *value, void *cb) warning(_("more than one %s"), orig_key); info->push_remote_name = xstrdup(value); break; + case PULL_MODE: { + int mode = pull_mode_parse_value(value); + switch (mode) { + case PULL_MODE_MERGE: + info->rebase = REBASE_FALSE; + break; + case PULL_MODE_REBASE: + info->rebase = REBASE_TRUE; + break; + default: + info->rebase = REBASE_INVALID; + break; + } + break; + } default: BUG("unexpected type=%d", type); } diff --git a/rebase.c b/rebase.c index f8137d859b..bdfca49886 100644 --- a/rebase.c +++ b/rebase.c @@ -33,3 +33,13 @@ enum rebase_type rebase_parse_value(const char *value) return REBASE_INVALID; } + +enum pull_mode_type pull_mode_parse_value(const char *value) +{ + if (!strcmp(value, "merge") || !strcmp(value, "m")) + return PULL_MODE_MERGE; + else if (!strcmp(value, "rebase") || !strcmp(value, "r")) + return PULL_MODE_REBASE; + + return PULL_MODE_INVALID; +} diff --git a/rebase.h b/rebase.h index 34d4acfd74..5ab8f4ddd5 100644 --- a/rebase.h +++ b/rebase.h @@ -13,4 +13,13 @@ enum rebase_type { enum rebase_type rebase_parse_value(const char *value); +enum pull_mode_type { + PULL_MODE_INVALID = -1, + PULL_MODE_DEFAULT = 0, + PULL_MODE_MERGE, + PULL_MODE_REBASE +}; + +enum pull_mode_type pull_mode_parse_value(const char *value); + #endif /* REBASE */ diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 9fae07cdfa..eb0086bd1c 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -449,6 +449,16 @@ test_expect_success 'pull.rebase' ' test_cmp expect actual ' +test_expect_success 'pull.mode rebase' ' + git reset --hard before-rebase && + test_config pull.mode rebase && + git pull . copy && + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual +' + test_expect_success 'pull --autostash & pull.rebase=true' ' test_config pull.rebase true && test_pull_autostash 1 --autostash @@ -523,6 +533,17 @@ test_expect_success 'pull.rebase=false create a new merge commit' ' test_cmp expect actual ' +test_expect_success 'pull.mode=merge create a new merge commit' ' + git reset --hard before-preserve-rebase && + test_config pull.mode merge && + git pull . copy && + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual +' + test_expect_success 'pull.rebase=true flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase true && @@ -552,6 +573,16 @@ test_expect_success REBASE_P \ test_cmp_rev HEAD^2 keep-merge ' +test_expect_success REBASE_P \ + 'pull.rebase=preserve rebases and merges keep-merge with pull.mode' ' + git reset --hard before-preserve-rebase && + test_config pull.mode rebase && + test_config pull.rebase preserve && + git pull . copy && + test_cmp_rev HEAD^^ copy && + test_cmp_rev HEAD^2 keep-merge +' + test_expect_success 'pull.rebase=interactive' ' write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF && echo I was here >fake.out && @@ -593,6 +624,17 @@ test_expect_success '--rebase=false create a new merge commit' ' test_cmp expect actual ' +test_expect_success '--rebase=false create a new merge commit with pull.mode' ' + git reset --hard before-preserve-rebase && + test_config pull.mode rebase && + git pull --rebase=false . copy && + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual +' + test_expect_success '--rebase=true rebases and flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase preserve && diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 8a6aae564a..25ca239c17 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -41,6 +41,13 @@ test_expect_success 'pull.rebase not set (fast-forward)' ' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' +test_expect_success 'pull.mode set' ' + git reset --hard c2 && + test_config pull.mode merge && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + test_expect_success 'pull.rebase not set and pull.ff=true' ' git reset --hard c2 && test_config pull.ff true && From patchwork Tue Dec 8 00:26:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957223 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.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,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 88979C197BF for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4203223A04 for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728701AbgLHA2x (ORCPT ); Mon, 7 Dec 2020 19:28:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA2x (ORCPT ); Mon, 7 Dec 2020 19:28:53 -0500 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AA5EC0619D2 for ; Mon, 7 Dec 2020 16:27:19 -0800 (PST) Received: by mail-ot1-x341.google.com with SMTP id d8so6432162otq.6 for ; Mon, 07 Dec 2020 16:27:19 -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=cLBST7XuQMRlRmpenlHz+E1zD00nV0tWGMj9WDorV8g=; b=X9XBRzF1tdImRROTKB2SLTRFz2hFtSB4y31PrbuOUR244LlP7afnGyVTtJ6HTax7e5 Bw/ERp9qRUvkv0uzeIoqceiewKVW5xsss/j7+ycDc0DopfVDw1mi+H6YLiT06Am+uWrN ZsrfLTQoFiViJ0b8yNhsS446sq99N8cmE+Qc60gSR1O/Me+2gWRC7xYoYlZddvOCIOdJ Zh631Fq00daAjOMzhWONt8kW0+n9v2voKjDmQvAWoCGJF+ThQQMRzT2f3F0OwouTTBHq Q+Fk8e+bhf4eNW0XslNL75fziIvga++ETwf8eEmu2zWFtAg10pQtO2SNkVopT7DFhZnh 6wag== 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=cLBST7XuQMRlRmpenlHz+E1zD00nV0tWGMj9WDorV8g=; b=CSVhrQOX72Q7h+8T7jYnOqr9CYeeKrKf7nhO6O68a9kSaD05O/qx3t1EtU13NR127w C1947wdC2WbwNSpKrRhn6JTSI/ibCXf60rSoojxudJUH350Q6fBriLxi4Zu+nCGFirhF 6nP5ibVAX7k2iOXu+2SVx/6RoiEXUS/yuMAqlptj+ynkmP6ffjMG5es+AoP+OS7vz+OG ZusY9e8SuYpyv4V/HfiK+7ltMluffexUsISXQ3enZtjLlcgCEKtjYGzhJiYdYLZ3HkgD 97Yr9QlfSw0yoLQfx9CZMkAqbBwJqyenEfYQ6oR753/AfQDQnsRO7rj/XCry53XKyZF3 gvUw== X-Gm-Message-State: AOAM5305R8Av3FTRdGMKJb+14LHD2FvDv+/9+KRRPqBcpoyB5rm9/tdk p6jemSJIpqU1xYV/jDkZKMEwlWmyTWB69pcN X-Google-Smtp-Source: ABdhPJwtODRuhYVS791Oyy3unm9hTqr8J7N4ln0dPGf4mbVQY5WsUQcIiMlITVpRkTihIlHw/XOmoA== X-Received: by 2002:a9d:3423:: with SMTP id v32mr15297263otb.129.1607387238327; Mon, 07 Dec 2020 16:27:18 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id q18sm2712374ood.35.2020.12.07.16.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:17 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 17/19] pull: add pull.mode=ff-only Date: Mon, 7 Dec 2020 18:26:46 -0600 Message-Id: <20201208002648.1370414-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It is very typical for Git newcomers to inadvertently create merges and worse; pushing them. This is one of the reasons many experienced users prefer to avoid 'git pull', and recommend newcomers to avoid it as well. To escape these problems--and keep 'git pull' useful--it has been suggested that 'git pull' barfs by default if the merge is non-fast-forward, which unfortunately would break backwards compatibility. This patch leaves everything in place to enable this new mode, but it only gets enabled if the user specifically configures it; pull.mode = ff-only. Later on this mode can be enabled by default. For the full discussion you can read: https://lore.kernel.org/git/5363BB9F.40102@xiplink.com/ Signed-off-by: Felipe Contreras --- Documentation/config/branch.txt | 4 +-- Documentation/config/pull.txt | 4 +-- builtin/pull.c | 5 +++- builtin/remote.c | 3 +++ rebase.c | 2 ++ rebase.h | 3 ++- t/t5520-pull.sh | 45 +++++++++++++++++++++++++++++++++ 7 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index b57bf2c308..39f60cd8f7 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -98,8 +98,8 @@ for details). branch..pullmode:: When "git pull" is run, this determines if it would either merge or - rebase the fetched branch. The possible values are 'merge', and - 'rebase'. See "pull.mode" for doing this in a non + rebase the fetched branch. The possible values are 'merge', + 'rebase', and 'ff-only'. See "pull.mode" for doing this in a non branch-specific manner. branch..description:: diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index f4385cde33..40778d9120 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -32,8 +32,8 @@ for details). pull.mode:: When "git pull" is run, this determines if it would either merge or rebase the fetched branch. The possible values are 'merge', - and 'rebase'. See "branch..pullmode" for setting this on a - per-branch basis. + 'rebase', and 'ff-only'. See "branch..pullmode" for setting + this on a per-branch basis. pull.octopus:: The default merge strategy to use when pulling multiple branches diff --git a/builtin/pull.c b/builtin/pull.c index 7756c8aea1..5a67667b79 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1088,6 +1088,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); + if (mode == PULL_MODE_FF_ONLY && !can_ff) + die(_("The pull was not fast-forward, please either merge or rebase.\n")); + if (!opt_rebase && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { 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" @@ -1095,7 +1098,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) "\n" " git config pull.mode merge # (the default strategy)\n" " git config pull.mode rebase\n" - " git config pull.ff only # fast-forward only\n" + " git config pull.mode ff-only # fast-forward only\n" "\n" "You can replace \"git config\" with \"git config --global\" to set a default\n" "preference for all repositories.\n" diff --git a/builtin/remote.c b/builtin/remote.c index 51b1e675e3..34d3ea9d38 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -335,6 +335,9 @@ static int config_read_branches(const char *key, const char *value, void *cb) case PULL_MODE_REBASE: info->rebase = REBASE_TRUE; break; + case PULL_MODE_FF_ONLY: + info->rebase = REBASE_TRUE; + break; default: info->rebase = REBASE_INVALID; break; diff --git a/rebase.c b/rebase.c index bdfca49886..c6233e888f 100644 --- a/rebase.c +++ b/rebase.c @@ -40,6 +40,8 @@ enum pull_mode_type pull_mode_parse_value(const char *value) return PULL_MODE_MERGE; else if (!strcmp(value, "rebase") || !strcmp(value, "r")) return PULL_MODE_REBASE; + else if (!strcmp(value, "ff-only") || !strcmp(value, "f")) + return PULL_MODE_FF_ONLY; return PULL_MODE_INVALID; } diff --git a/rebase.h b/rebase.h index 5ab8f4ddd5..432bcb55c4 100644 --- a/rebase.h +++ b/rebase.h @@ -17,7 +17,8 @@ enum pull_mode_type { PULL_MODE_INVALID = -1, PULL_MODE_DEFAULT = 0, PULL_MODE_MERGE, - PULL_MODE_REBASE + PULL_MODE_REBASE, + PULL_MODE_FF_ONLY }; enum pull_mode_type pull_mode_parse_value(const char *value); diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index eb0086bd1c..b5b007b175 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -861,4 +861,49 @@ test_expect_success 'git pull --rebase against local branch' ' test_cmp expect file2 ' +setup_other () { + test_when_finished "git checkout master && git branch -D other test" && + git checkout -b other $1 && + >new && + git add new && + git commit -m new && + git checkout -b test -t other && + git reset --hard master +} + +setup_ff () { + setup_other master +} + +setup_non_ff () { + setup_other master^ +} + +test_expect_success 'fast-forward (pull.mode=ff-only)' ' + setup_ff && + git -c pull.mode=ff-only pull +' + +test_expect_success 'non-fast-forward (pull.mode=ff-only)' ' + setup_non_ff && + test_must_fail git -c pull.mode=ff-only pull +' + +test_expect_success 'non-fast-forward with merge (pull.mode=ff-only)' ' + setup_non_ff && + git -c pull.mode=ff-only pull --merge +' + +test_expect_success 'non-fast-forward with rebase (pull.mode=ff-only)' ' + setup_non_ff && + git -c pull.mode=ff-only pull --rebase +' + +test_expect_success 'non-fast-forward error message (pull.mode=ff-only)' ' + setup_non_ff && + test_must_fail git -c pull.mode=ff-only pull 2> error && + cat error && + test_i18ngrep "The pull was not fast-forward" error +' + test_done From patchwork Tue Dec 8 00:26:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957229 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 F2622C4361B for ; Tue, 8 Dec 2020 00:29:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BC8F223A04 for ; Tue, 8 Dec 2020 00:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728707AbgLHA3A (ORCPT ); Mon, 7 Dec 2020 19:29:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA27 (ORCPT ); Mon, 7 Dec 2020 19:28:59 -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 09F97C0619D4 for ; Mon, 7 Dec 2020 16:27:21 -0800 (PST) Received: by mail-oi1-x241.google.com with SMTP id l207so14697294oib.4 for ; Mon, 07 Dec 2020 16:27:21 -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=w+FpBGrJUGE/gqxlvUfo1tzXM7j/IGNmBxyZkunuGXA=; b=FeOwcNj9GQ4bcdPRq32RLaFFfgcIhzFEwP/e4bfeeci7bSX2N/QbAr8XzZALi4thhG lIKtHRc7rxL8ATy+JtAS2WVbq94vzwFeB36Ylv3tS6SQc/GQ7PvM646yutgfFLNFgZcs 2ClXekkfIeUEn/EuD5eREHNfL1N9aor3btG1Cx4C9m2CiKBnrVQ6G6K49JeBlnWGv3On 5n8itw2EpC6YdIz9zwfniyNpKsMjH4CyiznZAN/+Q1oXYHczfThxg1uf0I6OcZyUQicd MTvPqoEsl6wn2Z/UQZgbx7JsMTOg1YquES/ak5GuuK7FjFzVTGFXyU+WubvsRp02RSvT IB8g== 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=w+FpBGrJUGE/gqxlvUfo1tzXM7j/IGNmBxyZkunuGXA=; b=R/XAHJ65gVg/Mm4xz7jKNhjMZdUQxoTMgBL9m7wqlNcx+YnQbXmWvsOZUC/ASEY94r VC/sr2AqQkx7flWX/fi6rIzwEmYFISLZtvUa332JxKe5TLuEoHRibP4fmR5u/eAMDokT heSm5XEhN31tppvjIQyG9z5oZKLCpCkvfMwWulMPd7SRPhpT5RD3Tzufnt81HVNmaTcs 90NCgm//byj2usDkw5O8Ddrztp7LgvzYlhVg63qfUpa5R2o/mAkJzp5yFT5H1Alf+zaB ZfcvTUdK+3zg0eZM0OAt9Xi7KpkkAI3mFAtJfEpZBNtLjwc0JIMiCWTyF1QRMz05nQbD LGVQ== X-Gm-Message-State: AOAM531+BiQwPvY8JNENSH2wgMk//2PfwcIzrOzgwub1QuM6qJCMfDXq h8ZDDrK2sos0mAkvuaHihVX9vw02q87mTCCD X-Google-Smtp-Source: ABdhPJzU38ob+hG1shH1wI3tiXRu2YavqnBCU1BZMfCMs7lh0pXLm0jcW0i8Cp0dnKkndFaHEoWKMA== X-Received: by 2002:a05:6808:a0e:: with SMTP id n14mr999217oij.75.1607387240061; Mon, 07 Dec 2020 16:27:20 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id z3sm366911otq.22.2020.12.07.16.27.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:19 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 18/19] pull: advice of future changes Date: Mon, 7 Dec 2020 18:26:47 -0600 Message-Id: <20201208002648.1370414-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we have "pull.mode=ff-only", we can make it the default any time we want to. For now, simply explain the upcoming changes in the default warning, and mention how to turn on the future default mode. Signed-off-by: Felipe Contreras --- builtin/pull.c | 20 +++++++++++--------- t/t5520-pull.sh | 8 ++++++++ t/t7601-merge-pull-config.sh | 22 +++++++++++----------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 5a67667b79..734a2c04b8 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1092,17 +1092,19 @@ int cmd_pull(int argc, const char **argv, const char *prefix) die(_("The pull was not fast-forward, please either merge or rebase.\n")); if (!opt_rebase && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { - 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" - "You can squelch this message by running one of the following commands:\n" + advise(_("The pull was not fast-forward, in the future you will have to choose a merge, or a rebase.\n" "\n" - " git config pull.mode merge # (the default strategy)\n" - " git config pull.mode rebase\n" - " git config pull.mode ff-only # fast-forward only\n" + "To quell this message you have two main options:\n" "\n" - "You can replace \"git config\" with \"git config --global\" to set a default\n" - "preference for all repositories.\n" - "If unsure, run \"git pull --merge\".\n" + "1. Adopt the new behavior:\n" + "\n" + " git config --global pull.mode ff-only\n" + "\n" + "2. Maintain the current behavior:\n" + "\n" + " git config --global pull.mode merge\n" + "\n" + "For now we will fall back to the traditional behavior (merge).\n" "Read \"git pull --help\" for more information.")); } diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index b5b007b175..d4718dbc02 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -906,4 +906,12 @@ test_expect_success 'non-fast-forward error message (pull.mode=ff-only)' ' test_i18ngrep "The pull was not fast-forward" error ' +test_expect_success 'non-fast-forward warning (default)' ' + setup_non_ff && + git pull 2> error && + cat error && + test_i18ngrep "The pull was not fast-forward" error && + test_i18ngrep "in the future you will have to choose" error +' + test_done diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 25ca239c17..149fc2a009 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -32,71 +32,71 @@ test_expect_success 'pull.rebase not set' ' git -c color.advice=always pull . c1 2>err && test_decode_color decoded && test_i18ngrep "hint: " decoded && - test_i18ngrep "Pulling without specifying how to reconcile" decoded + test_i18ngrep "in the future you will have to choose" decoded ' test_expect_success 'pull.rebase not set (fast-forward)' ' git reset --hard c0 && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.mode set' ' git reset --hard c2 && test_config pull.mode merge && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=true' ' git reset --hard c2 && test_config pull.ff true && git pull . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=false' ' git reset --hard c2 && test_config pull.ff false && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=only' ' git reset --hard c2 && test_config pull.ff only && test_must_fail git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --rebase given' ' git reset --hard c2 && git pull --rebase . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --merge given' ' git reset --hard c2 && git pull --merge . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff given' ' git reset --hard c2 && git pull --ff . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --no-ff given' ' git reset --hard c2 && git pull --no-ff . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff-only given' ' git reset --hard c2 && test_must_fail git pull --ff-only . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'merge c1 with c2' ' From patchwork Tue Dec 8 00:26:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11957225 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.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 451CCC4167B for ; Tue, 8 Dec 2020 00:28:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 047DA23A1D for ; Tue, 8 Dec 2020 00:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgLHA2a (ORCPT ); Mon, 7 Dec 2020 19:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbgLHA2a (ORCPT ); Mon, 7 Dec 2020 19:28:30 -0500 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B902FC0619D5 for ; Mon, 7 Dec 2020 16:27:22 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id h18so10375928otq.12 for ; Mon, 07 Dec 2020 16:27:22 -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=AFvRhfO7Js7M74kjQk4ZtlBYBpJXOoYG9/v9Opl3OuE=; b=EYdBJvWpXGzzDp1j9r8UqYVnLhQ1R2IiVBzAIBkklwq2W8K2QEv+Ji/4NyGQ9tvjuY Im+TWEQzQHxOvb0KDI15yUE2h5c/c89a9Mf5hVzx06tGeElV79FJJxg5c4UoAPGK9d/p 5BRSdUZ5163tUNE32Y1BzaQTzI4EURVqf0gfDkreGtr4Hmn5bQ2fA4lYnvPo2G1EiZA7 33zhc6TlqF/j4z7FIjgh6ra5FEa7laEyT4td3drRo7mYOBnTG2+7N8SvHMInZzocw8+z AnFeLed3BUlElYPZmq1/ySVvmYt/IoRGKj4um4emhHTU/r871bVL9I5svTXXNyZmLy7I jRYg== 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=AFvRhfO7Js7M74kjQk4ZtlBYBpJXOoYG9/v9Opl3OuE=; b=mDkseL4iMKTKXQUHfVZYaS/1Y1iZNfrR5raWBAi/TGtSPP9e5mZhNmKV2/HGGrgo1l ONAg24IgIj7jXUSRMHl/IovwH+O7TnG9PMQ9us+4xxB9SZcVC7N1AtGESiNtp7d4V8uI h8v9sM8isL3jyihMBqKHMnvAShelFM7IwZTQOr9PWFH44YIhLlY5/ShvAz4ulhb7zARc BALTjQqlM/fTZeslGyhoGbEYGd9Up3nqlPwjbznTsC3qIYEKz34NQZNRi26Yp9HrsYwO sTmkx95oNHuKEWgGy5ibkQVHxc16arCpMAourCxMJJMzWeQQxvbgkRXTWmXOsSmeUs0/ Cfgw== X-Gm-Message-State: AOAM531uJ8J7LjYILuRIfhLnIxb8DMYLrXAsGbqUXRYdBxj0uBo6IRLR DTiWfOjc9QSlAPOfh3QOHS+aMFI8Le3d3+ih X-Google-Smtp-Source: ABdhPJyjPuLvBtlKqRncNjfg4ceEqubzEbPID1t/fAfUEADpeGjh7NwepOg+V48kciW9yhu51QbkMQ== X-Received: by 2002:a9d:3f49:: with SMTP id m67mr9100873otc.327.1607387241756; Mon, 07 Dec 2020 16:27:21 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id i43sm3038345ota.39.2020.12.07.16.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 16:27:21 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Elijah Newren , Alex Henrie , Junio C Hamano , Jeff King , Philip Oakley , Felipe Contreras Subject: [PATCH v4 19/19] future: pull: enable ff-only mode by default Date: Mon, 7 Dec 2020 18:26:48 -0600 Message-Id: <20201208002648.1370414-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201208002648.1370414-1-felipe.contreras@gmail.com> References: <20201208002648.1370414-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The user has been warned that this change was coming and should have already configured his/her preference. It's time to flip the switch and make ff-only the default. There's no need for the annoying warning anymore. TODO: Do we want to keep the "pull.mode=ff-only" tests and essentially run them twice? Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 4 +- builtin/pull.c | 19 +--------- t/t5520-pull.sh | 28 +++++--------- t/t7601-merge-pull-config.sh | 72 ------------------------------------ 4 files changed, 13 insertions(+), 110 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 21b50aff77..672371e989 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -60,8 +60,8 @@ However, a non-fast-forward case looks very different. origin/master in your repository ------------ -By default `git pull` will warn about these situations, however, most likely -you would want to force a merge, which you can do with `git pull --merge`. +By default `git pull` will fail on these situations, you will have to +specify whether you want `--merge` or `--rebase`. Then "`git pull`" will fetch and replay the changes from the remote `master` branch since it diverged from the local `master` (i.e., `E`) diff --git a/builtin/pull.c b/builtin/pull.c index 734a2c04b8..7ddc11a4bc 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -392,7 +392,7 @@ static enum pull_mode_type config_get_pull_mode(void) if (!git_config_get_value("pull.mode", &value)) return parse_config_pull_mode("pull.mode", value); - return PULL_MODE_DEFAULT; + return PULL_MODE_FF_ONLY; } /** @@ -1091,23 +1091,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (mode == PULL_MODE_FF_ONLY && !can_ff) die(_("The pull was not fast-forward, please either merge or rebase.\n")); - if (!opt_rebase && !can_ff && opt_verbosity >= 0 && (!opt_ff || !strcmp(opt_ff, "--ff"))) { - advise(_("The pull was not fast-forward, in the future you will have to choose a merge, or a rebase.\n" - "\n" - "To quell this message you have two main options:\n" - "\n" - "1. Adopt the new behavior:\n" - "\n" - " git config --global pull.mode ff-only\n" - "\n" - "2. Maintain the current behavior:\n" - "\n" - " git config --global pull.mode merge\n" - "\n" - "For now we will fall back to the traditional behavior (merge).\n" - "Read \"git pull --help\" for more information.")); - } - if (opt_rebase >= REBASE_TRUE) { int ret = 0; diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index d4718dbc02..84685786da 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -879,39 +879,31 @@ setup_non_ff () { setup_other master^ } -test_expect_success 'fast-forward (pull.mode=ff-only)' ' +test_expect_success 'fast-forward (default)' ' setup_ff && - git -c pull.mode=ff-only pull + git pull ' -test_expect_success 'non-fast-forward (pull.mode=ff-only)' ' +test_expect_success 'non-fast-forward (default)' ' setup_non_ff && - test_must_fail git -c pull.mode=ff-only pull + test_must_fail git pull ' -test_expect_success 'non-fast-forward with merge (pull.mode=ff-only)' ' +test_expect_success 'non-fast-forward with merge (default)' ' setup_non_ff && - git -c pull.mode=ff-only pull --merge + git pull --merge ' -test_expect_success 'non-fast-forward with rebase (pull.mode=ff-only)' ' +test_expect_success 'non-fast-forward with rebase (default)' ' setup_non_ff && - git -c pull.mode=ff-only pull --rebase + git pull --rebase ' -test_expect_success 'non-fast-forward error message (pull.mode=ff-only)' ' +test_expect_success 'non-fast-forward error message (default)' ' setup_non_ff && - test_must_fail git -c pull.mode=ff-only pull 2> error && + test_must_fail git pull 2> error && cat error && test_i18ngrep "The pull was not fast-forward" error ' -test_expect_success 'non-fast-forward warning (default)' ' - setup_non_ff && - git pull 2> error && - cat error && - test_i18ngrep "The pull was not fast-forward" error && - test_i18ngrep "in the future you will have to choose" error -' - test_done diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 149fc2a009..c6c44ec570 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -27,78 +27,6 @@ test_expect_success 'setup' ' git tag c3 ' -test_expect_success 'pull.rebase not set' ' - git reset --hard c2 && - git -c color.advice=always pull . c1 2>err && - test_decode_color decoded && - test_i18ngrep "hint: " decoded && - test_i18ngrep "in the future you will have to choose" decoded -' - -test_expect_success 'pull.rebase not set (fast-forward)' ' - git reset --hard c0 && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.mode set' ' - git reset --hard c2 && - test_config pull.mode merge && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=true' ' - git reset --hard c2 && - test_config pull.ff true && - git pull . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=false' ' - git reset --hard c2 && - test_config pull.ff false && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=only' ' - git reset --hard c2 && - test_config pull.ff only && - test_must_fail git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --rebase given' ' - git reset --hard c2 && - git pull --rebase . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --merge given' ' - git reset --hard c2 && - git pull --merge . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff given' ' - git reset --hard c2 && - git pull --ff . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --no-ff given' ' - git reset --hard c2 && - git pull --no-ff . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff-only given' ' - git reset --hard c2 && - test_must_fail git pull --ff-only . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - test_expect_success 'merge c1 with c2' ' git reset --hard c1 && test -f c0.c &&