From patchwork Sat Dec 5 19:52:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953461 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 0B8B9C433FE for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D229E23110 for ; Sat, 5 Dec 2020 19:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725730AbgLETyA (ORCPT ); Sat, 5 Dec 2020 14:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725270AbgLETx6 (ORCPT ); Sat, 5 Dec 2020 14:53:58 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 114C0C061A4F for ; Sat, 5 Dec 2020 11:53:18 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id q25so2410239oij.10 for ; Sat, 05 Dec 2020 11:53:18 -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=J6aTBf0SDpHve48rTJ5EpUCFxp9EXKC/Z1a9387wUXY=; b=byXvS+/77dGepIA8hKXnG0fUMGhGLpTcO1C7e+B3QTCl7D221zogxXlNzFRD/Oqo2B UBLzbgqw1uZR5JmHICi0ObeTJInjx9t3Lsb+d3mBKJrSus6rYDZ+y8hddODb9owzHj5Z /WwY0p8yl94i1Ua1wDz9tQVOx2F1UwTkq6txyP1c3YqMRDdGHs10Kq/eL/AjSH+7MtSe KTpfHJyYgpH6ddQGNJq+pg/9wn8kGMZwTeS4d5lS+TOUK6GGFXi6/7MVhkaxDmiK5Ap6 VAkDvo91kRP0uDroY4aGMnafSk1CM52TwvOTUEocZm67EEzSpvjxWF3gYp1sgZCOrXX4 h1rg== 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=J6aTBf0SDpHve48rTJ5EpUCFxp9EXKC/Z1a9387wUXY=; b=tU5JP6XwM13IetLOtCh9gKMkDzmMV0jVS7HH7jHkiONB0EUem/r3D667y91fbelywC 6TC25Fh99Y2ymK09P3Rpe8ZdKoKMl9g4k5kL7INUOM0kWXGJbAnNoJ5KoZlX4rdFSSwb osdwvYTKMj7rv2xaKAQP1L9PY7waUHTbNLhG83XuiCj1pcj1EeMxQxjpowPJ+FfUd3gT GEV0f6jPXf6GywDwBYAHBRnFKjphSNqU947rhDHJ4vsr2MpvQDPzo2IM+6uc1V2ITyoE vlVbYghJs7JKoY2mLaHAR/YP7/ZBDKnZRM11ArPOxBDjxouYOAkg8JMbSsEMN5SdiBd2 ujkw== X-Gm-Message-State: AOAM533IxNHUMEgr82F3bEDAsyuJ3xg1jAr0l1Dki2zqKG1Ctbue5Q6Q aGb4Njgirw8ryLb+8+GdgM6lRw5rKisZeg== X-Google-Smtp-Source: ABdhPJyfT7bpEHGnf5suggmRWyREmZfGSSiELJusztzZdvsxjIi1ZeIzLxg4NbrjFyIdIWH6C1bq2w== X-Received: by 2002:a54:4704:: with SMTP id k4mr7307115oik.39.1607197997310; Sat, 05 Dec 2020 11:53:17 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id r13sm1524125otq.42.2020.12.05.11.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53: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 v3 01/16] doc: pull: explain what is a fast-forward Date: Sat, 5 Dec 2020 13:52:58 -0600 Message-Id: <20201205195313.1557473-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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..dc812139f4 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-foward way up to the new master. + +------------ + D---E---A---B---C master, origin/master +------------ + +However, a non-fast-foward case looks very different. + ------------ A---B---C master on origin / From patchwork Sat Dec 5 19:52:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953469 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 89DA2C18E57 for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F7DD23122 for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726202AbgLETyB (ORCPT ); Sat, 5 Dec 2020 14:54:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbgLETyA (ORCPT ); Sat, 5 Dec 2020 14:54:00 -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 EB977C061A51 for ; Sat, 5 Dec 2020 11:53:19 -0800 (PST) Received: by mail-ot1-x343.google.com with SMTP id b18so8760591ots.0 for ; Sat, 05 Dec 2020 11:53: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=GXVjGoem5f0NEAh1LIHoLSM7rqoa25uwUgcRLLmjpIE=; b=EhKNPo5D91/KxcsJmsEWxPtfhwJPdZialwKPcQI+e1NZdo6PLRQM1P28MyE+k4YqmR 4+M1ErXx0WvMFNHu4K/KXAEvBXde/8Dy1WyhIEfxfnr9m0cgLh7hyTPHH4Ubqu+KhsTC mhMX0DSwr3WsNxjwB50mF1tWKggVWs1ASJt3W0bBjfvqAGkNlszctrxOhHbs9K3XBych OuUYILIvO3AOwGB6VkndYoZmaIHu70ZZwzksC4gtHTExSZO77Cp/xIAN8FyMYVlV43hC Iqr1qnK0dHONXX9kssS52X7VabmGXyia/BnUM8FHxBxzqRwIS+TDAS7SE2RWX8nA3QV1 376g== 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=GXVjGoem5f0NEAh1LIHoLSM7rqoa25uwUgcRLLmjpIE=; b=T6ISnLcTNqgHlLBIDWfmn1yjx/7bAaM/uy4LHzuXvE7ocRZjr7uuqGeHZ1G4/gun9M 465KxjjaD8EbAwPBACpMMv1Qlwy2784iF2vPCZRlBArrHF7AMVyvDs1vcQBCU79iF889 YIeTIv6YhHiPSDEp7SZLgM+y0sJitssllVUv3jBgw0SX4Ea6E3G7vRyOiC+A6ulDBzYH g2xoFerWDi0X+GU8GHxP2zyT4EkG/jqUzHaL7P8Z8r2lPmK8sR9UUW5PIVUNBMCjVnOW VTfe4Qg30Dw/vySS1iZC8VQhxLX5lPCkEMxK6J+7tzzuU38RTEu0RO8sPppdoS3YpE0k ws4w== X-Gm-Message-State: AOAM532YxK9MGQubf+jaZrXZgTUArOgDvVjKMi+NfmeLGcv//2rcesBG Yh54VgRK8gnW0vIIj/WYI6T8wJq6DYytHQ== X-Google-Smtp-Source: ABdhPJzlaozsw9jW7BoHKtjCXAL9oqbfX55MYQjX3bq53LqgtuM2KQ7Vb4aiOMrAdlCQmhWqsYRQ9A== X-Received: by 2002:a9d:1b2:: with SMTP id e47mr8122745ote.45.1607197999104; Sat, 05 Dec 2020 11:53:19 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id w64sm1634910oie.49.2020.12.05.11.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:18 -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 v3 02/16] pull: improve default warning Date: Sat, 5 Dec 2020 13:52:59 -0600 Message-Id: <20201205195313.1557473-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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, rebase, or fast-forward. 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 | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 1034372f8b..d71344fe28 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -345,18 +345,19 @@ 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, a rebase, or a fast-forward.\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 Sat Dec 5 19:53:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953463 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 226A6C4361A for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7F1A23122 for ; Sat, 5 Dec 2020 19:54:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbgLETyE (ORCPT ); Sat, 5 Dec 2020 14:54:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbgLETyB (ORCPT ); Sat, 5 Dec 2020 14:54:01 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EBC0C061A52 for ; Sat, 5 Dec 2020 11:53:21 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id d27so2967352oic.0 for ; Sat, 05 Dec 2020 11:53: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=tuazQtJNSs6tffNRzPK8EmqGCGei5rCkO969r89wiak=; b=KoUcPmNiojV9NqrpSKnzmjmfByBn889SvujYsrGfB1Zy5d5nM/NZCHBGv6XyF3HQk3 VENGO3TSdWC+F26qeozoFi9LA8459qOYAWPjhybdgkL58dw+xr7SAb0uIOJUYxFnw/vm fTE7dA3vnijuFGY+r6Sz0D2RhrED+xI9JFx4FJiiW0qbm3UNUi8XJSPG7c30UxFig+ca A+kKZ2VbKvHCVk2i6d6x+DmTCtHOO6OzCbC+7zCAS1Nj0zVVUQ1n92KsWIyc5iv/ZpXi 4sS+Db/XV2XHaJtrzHii2kzkEBNydZCL0lQU0VrcI+jWp8otqNTzIlNsJg9/5UCLan6Q 1GbQ== 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=tuazQtJNSs6tffNRzPK8EmqGCGei5rCkO969r89wiak=; b=Uj9B5O9ILfpGQIfrPx2hbx4TVoOaqgcyZrOA1LSIcJBhZNofiWJg4Y176Lk2yGVjwv QhxJOsV0J106hLiXYIZoUFac3svZNYlgbpkQMrqz0HIFl62w9yoq32t3o6sq7cOlNSsN TCz7Q/wnoxGtRSKAt3bWGKXqu6z+Yq5cbmHmLAhU+2XKsBb0fVNGj4iqGuEt2sVA2y+E 8PuhzgN7tiw9/e9owcP1uXYsgYxENe3iW7rf+TstWj69y35pjm5ug3Oj9ouy3vA8WMzO 98cEDmX/dgnWsU2y3F2srau7PGDbppkNjdZUoEujD8AQUakNayw/Zrjndcwq0lARTiQF IrTg== X-Gm-Message-State: AOAM530yQ/9UKj050Vg+v8fdbrQZ9stNF0ZAqzp27e5DufqtqI+AgSA9 wEB9OW03mss2ftrEFIyUsUoUzxwi6pQZMA== X-Google-Smtp-Source: ABdhPJwTZMzo6Ro5K0Q9CYSUVUG07lOB9QcHeZGfsluLS6sm9bDCv/q2xZca4PDrpIhqBsGQGn69JQ== X-Received: by 2002:aca:b3c3:: with SMTP id c186mr7053050oif.39.1607198000595; Sat, 05 Dec 2020 11:53:20 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id e5sm1504895otl.75.2020.12.05.11.53.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:20 -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 v3 03/16] pull: refactor fast-forward check Date: Sat, 5 Dec 2020 13:53:00 -0600 Message-Id: <20201205195313.1557473-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 d71344fe28..7a5b343fe2 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -907,6 +907,20 @@ static int run_rebase(const struct object_id *curr_head, 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; @@ -1017,22 +1031,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) submodule_touches_in_range(the_repository, &rebase_fork_point, &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(&curr_head, merge_heads.oid, &rebase_fork_point); From patchwork Sat Dec 5 19:53:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953467 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 5139DC4361B for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2854023128 for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726522AbgLETyK (ORCPT ); Sat, 5 Dec 2020 14:54:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725379AbgLETyJ (ORCPT ); Sat, 5 Dec 2020 14:54:09 -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 DA441C061A53 for ; Sat, 5 Dec 2020 11:53:22 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id o11so6045048ote.4 for ; Sat, 05 Dec 2020 11:53: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=WnIyT7njW7HfFDcj0vGojFOZxzUAKjNyd8U81ofpohY=; b=nYHvGVtpyDkmfLaUN0JBEI7ZNYhKYtY1EzX6fmG3oK/KQ5dJ4DLVqrvQDbnTIRERFY tNrU2+kPErAeJ6Q3RMRF1R33OdEJlpslz4/3J9EwK6bvZqTLSvi6BJcMMQzX4BAeLaIv 9e5Ey7uTJ1SChcJx+xvjzwsdDHKnuhjf/TzCXrbCOET9bCH37q1BobNYhso41OHIqLZZ ePpXFlKFTmkJpdlK48gDGOczJICAkf8Ct3aTEv7rvLKB5AVmjtPoQD8pVDrYxbZ9qg9j cyZidvVhKt2Mh0zVkJylKuymh4ZnUbtJW6+6AsYS9xoUZBrCA37YhfHx6PlTRkLz2azE j97g== 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=WnIyT7njW7HfFDcj0vGojFOZxzUAKjNyd8U81ofpohY=; b=CAHaJddfb4aNWVwphEm7saSnsOUGQ5CIYN0ljUTPWrT8U4m+KIXF/qI50OX8/ysYrs tsKXlqtpTJ0yFm9Dj0sJm6IahR+IgoKHX8ks5YZ7PwwWSm39jjlEJeR+DTnU3BcVMo7H SR3Gyui80rIkO6r5dy2h7b+zQY+gA249URkeaJOClAQlGCPQVcHiSoBu6tj5ysI0V7rV qq7JiEmWYWuu98wgD2Bi00QePsMm5GjjfwUlPaJBSFBYhUw6+cC+AjsLuk92GQukiF+T D/fmmXLi68hbm2oETlksOXodKsvGU0j6FFaszGEHvJxEOTH7KuJgoWanA0l6bUpCzlXC vu2Q== X-Gm-Message-State: AOAM5317f4wKXAfcocOa+JQ0BW/QMNhx0Wu1S4w3ZVzqT2WnuhRj0KjV +JXkWTcr2OizT+K245w1HFp/QyKRCuZjrw== X-Google-Smtp-Source: ABdhPJy7qdr0/Lvjjp4F0B6i731FH0ukLIDw2EZCse8LVyKqk/RA1exzDL7G6cQoDXmPlOER3LEkPw== X-Received: by 2002:a05:6830:1e1c:: with SMTP id s28mr1704937otr.82.1607198002069; Sat, 05 Dec 2020 11:53:22 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id e1sm1045213oib.11.2020.12.05.11.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53: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 v3 04/16] pull: cleanup autostash check Date: Sat, 5 Dec 2020 13:53:01 -0600 Message-Id: <20201205195313.1557473-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 7a5b343fe2..d2f80e8615 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -927,7 +927,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); @@ -960,8 +959,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; @@ -1030,13 +1029,11 @@ int cmd_pull(int argc, const char **argv, const char *prefix) recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && submodule_touches_in_range(the_repository, &rebase_fork_point, &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(&curr_head, merge_heads.oid, &rebase_fork_point); From patchwork Sat Dec 5 19:53:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953465 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 72824C19437 for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4788F22DBF for ; Sat, 5 Dec 2020 19:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbgLETyL (ORCPT ); Sat, 5 Dec 2020 14:54:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgLETyJ (ORCPT ); Sat, 5 Dec 2020 14:54:09 -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 5E977C061A54 for ; Sat, 5 Dec 2020 11:53:24 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id w3so8102755otp.13 for ; Sat, 05 Dec 2020 11:53:24 -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=gEPr2/OPjoqlViE//B8E+wSUc/C0xsTCHmfwsNHnVOM=; b=e5z2u0WZxF6KGZN2DjvElT2jjq6XIEumcbvCarMOssozjZdpdzFBpZC1k7ZGJSUI26 0dDah5MkUqMZMB2KXFKiPefsOLebVffWJ/395GNDro3k4rLyXxFse0uYrwrv+51j8py5 EIWWwDzy8rWq82FQL8YtT79GH+3I+V1na+7vKC4/xOJEZyZLYYjhjq0s2o530v2xSokd 4dSJSVdrJc9kFNQx854HqMLraf/r/X4SahoCyk0U1QLEFE3QCt6b4x5MA0juiATwK8tV xBluPqFf3ggxFMN57W5pJ6IT1kI5y1cvU7HouIhNI5tFogb5rq5hXPkP96tzHsbuecw5 SD1Q== 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=gEPr2/OPjoqlViE//B8E+wSUc/C0xsTCHmfwsNHnVOM=; b=O7HB5v1WFePhUCn62uj7RoIrVCC3v+FDC10F+ScMFKOPwfWxfhnvsebL/RboLhZRQl xG44SjW0PPozTxogzNDhLThjpmr4djUJma7BYTkShmgjwJ+B+PSHlA5kNam40RyVoSqK xg1U3ncSZZYrM91E1ZCcF+vss7bw4F7bscCkl3mQZ5CHZBVQjYxChQoXDOkx6ZMJydNr d01+aWSO//NB4PiG1cyQDn9hHpae3AzyAEZezJB4O87FZ/dGLjYMPe0Oz+LtYzP9M6dD JC/GiN/KTpmsW12KO67gOpJdLZLbTxGj0zh9RH4p6jrXqqwrb3pP8h3JboCa/gaI4oi9 4xXw== X-Gm-Message-State: AOAM532LLaIZrZ7YJNB+U+ZqBDWlRZK699bN8bZwlL9kQinw9OHH+Q+x Ve2/+YO3h6x+3CHbe13Cit5kwxv+2ypwzQ== X-Google-Smtp-Source: ABdhPJyLC7GGgKntYVJ3+40BtmUEJbekcI4C4ntoWAUu7csiOqBrFSt/V9U7qEvNy9F7uP5lmpUIoA== X-Received: by 2002:a9d:38e:: with SMTP id f14mr8202467otf.176.1607198003580; Sat, 05 Dec 2020 11:53:23 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id u66sm1503971otb.48.2020.12.05.11.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:23 -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 v3 05/16] pull: trivial cleanup Date: Sat, 5 Dec 2020 13:53:02 -0600 Message-Id: <20201205195313.1557473-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 d2f80e8615..feadded1b6 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1024,19 +1024,18 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_rebase) { int ret = 0; - int ran_ff = 0; if ((recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && submodule_touches_in_range(the_repository, &rebase_fork_point, &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(&curr_head, merge_heads.oid, &rebase_fork_point); + } if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)) From patchwork Sat Dec 5 19:53:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953477 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 C6B43C4361A for ; Sat, 5 Dec 2020 19:54:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94E50230FA for ; Sat, 5 Dec 2020 19:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726751AbgLETyl (ORCPT ); Sat, 5 Dec 2020 14:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726196AbgLETyk (ORCPT ); Sat, 5 Dec 2020 14:54:40 -0500 Received: from mail-oo1-xc41.google.com (mail-oo1-xc41.google.com [IPv6:2607:f8b0:4864:20::c41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932ECC061A55 for ; Sat, 5 Dec 2020 11:53:26 -0800 (PST) Received: by mail-oo1-xc41.google.com with SMTP id l20so2270683oot.3 for ; Sat, 05 Dec 2020 11:53:26 -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=eRCv7dqEG6so68bCrDwg7EAcFS4AtjxzKQCNl/L3Wdk=; b=GmdETvTzriHHH2jfWZqH+TIcFva5kX4W7KenOXTjxR0UjxB5tqy5NXMPQ1Pe9dK578 D3aGXMwS7f2fJ5mJk6hqlRqnIaBVY+hahpWAlEqQjMiwDVBT1sT6lrWh24Q6VNFWy1vv A+mX67gMa6zC1Pgl3ymaThs0niqb3v6ZmcruVDiECIsaMezVjAY3rk6lg7YVTfHDbtdI kM+BnPicuipQDHzzfYaWYvypfQfedEvDkuOjLxVyIshI1bdrnOJ8MTTBUXtNj9OVC1aj H4cfR2t/u8TYmyfpdERgUnJ32J+Xw7gkmqT8eM/88nROQ/sV8ejdaepl1jWBGo4AXYKN AKAQ== 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=eRCv7dqEG6so68bCrDwg7EAcFS4AtjxzKQCNl/L3Wdk=; b=gzM7HLeqjK93fVM+6dKhOhe7Ro+L5Eysoo7+UWj9QHQLAoVNBNAwoB99pO5V4/afsT AqjzVnnJaxYBc/kLU780QHcEjOVS+xGNbCrWxT3kUf80Fj3SKKBaqQW8Y84TH3ypvp02 qYGIIQlo8CP6YokfZwXnmTFVoDhcmlBoqxGSAZ/v7XKliRIvNguZY+tlWWg7CG+rqf5H X6AZarsxxz0FUGY4y4KrfpWKtjHgm3f56XRvtjQmoOhez6Qmc1v+YCalJpQ70g5IPmdL HtRF0tt0USP3JS+idTK2edjdlN7s4evGoKZfTv1CTKt+BkxIe6WLZqBaaMvZj3e7ZmQs l+Bg== X-Gm-Message-State: AOAM533om9w8NXCRZ6aGyXyQCaJH5fG1s5EFjLd4bbv5HMLD+c+jUxew 2yuRWOuLYHvPRyOtlQpU/rnmERTkPjvk5A== X-Google-Smtp-Source: ABdhPJye4r2pgFZSvb8nwJF9G67LR2oa6z733/jmuRInqnC+ClfC7DdhNogWLciaWz9EjhmoCzYREQ== X-Received: by 2002:a4a:9563:: with SMTP id n32mr7855161ooi.53.1607198005704; Sat, 05 Dec 2020 11:53:25 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id d15sm1358576otk.62.2020.12.05.11.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:25 -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 v3 06/16] pull: move default warning Date: Sat, 5 Dec 2020 13:53:03 -0600 Message-Id: <20201205195313.1557473-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index feadded1b6..3fd9bd1bd2 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,21 +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, a rebase, or a fast-forward.\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; } @@ -927,6 +915,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); @@ -1022,6 +1011,24 @@ 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, a rebase, or a fast-forward.\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; if ((recurse_submodules == RECURSE_SUBMODULES_ON || @@ -1029,7 +1036,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) submodule_touches_in_range(the_repository, &rebase_fork_point, &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 Sat Dec 5 19:53:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953481 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 B4CB7C433FE for ; Sat, 5 Dec 2020 19:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88A7F230FA for ; Sat, 5 Dec 2020 19:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgLETyn (ORCPT ); Sat, 5 Dec 2020 14:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgLETyk (ORCPT ); Sat, 5 Dec 2020 14:54:40 -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 2CE7FC061A56 for ; Sat, 5 Dec 2020 11:53:28 -0800 (PST) Received: by mail-ot1-x344.google.com with SMTP id x13so1214676oto.8 for ; Sat, 05 Dec 2020 11:53:28 -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=dIjVNlDxbfW3e5eFM0I2zjl06KHCN+Uny4+Tmva6fqY=; b=JqxBKITfyqO23GKyxJsxLH4dFjX53wwKLsztacHDSFbSxYqrNY0jGiVZxYgQDECNZk sVa8K5Y3py13XLy0JFcpiy2OKebx8Z0OKEXqrUFGI9zJAyBR4ppy7mTwpahgwoDhRl2f ppqGOufyWVqGO3jQ5BdDEUMlcDzdEApGhF0ZDq8ZC7jEtcKH+NigPQDqMt38eCKzsIu1 H/lt8j+4oAJLi/rCTt1g6VvePkkEZs4pWUrhUGDdPD7vdCwb1mDGS7uZ1NJpldIRkqQi yhrxp+fpBdt4JUuwV07znUtJADyXjQPA81NNbVKKI6ri/SCSliX+ghPh14KisHFu58YZ cDMg== 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=dIjVNlDxbfW3e5eFM0I2zjl06KHCN+Uny4+Tmva6fqY=; b=VKklg6six/xaGndbqmE841jAp1ixSG/IsKvceAXr3EtKfg/Umlze+ohflM5Yk2GYj8 I4QirGUy5aheNkFwe4EbYWKkItXIHs1u067X8YDhbejDgZEZfzjvLLbID/HUq9Kqu23P bC914Xg5fFGYZaiC6YW7DDb6mQeL49cRaVFKSZp9ngwkdWOQIUWVBm5E4fK/HZTPW1El JEkdW6oaTuKo8ZutfffLfaKVR807FhOATf7bMqkgQMJrY+7O9Qm19wU8wlkkJ9R4ZnLr W24OWXm/gwmm0SlQ5S6MfRlCNuuqTQLBu2wsKg9p3Da8xq2AXhsXAkWCWs8Br6Cm0cI6 v0wA== X-Gm-Message-State: AOAM531cIPIsBzMQlAZ7CuuBJHbA+h9V95Z53Gsm3qooUdAYrrWIpHNK ayZGkiusPvgOC57eQSjFVj7+vIVBNZgXXA== X-Google-Smtp-Source: ABdhPJzTQ3XYyXzhKlOV5WjJfrb8J24n8VXBVzQdqg+4OK9O30OFEFZ/SyoomCINliGxchEiArylLA== X-Received: by 2002:a05:6830:3154:: with SMTP id c20mr8323404ots.286.1607198007319; Sat, 05 Dec 2020 11:53:27 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id t25sm1515401otj.13.2020.12.05.11.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:26 -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 v3 07/16] pull: display default warning only when non-ff Date: Sat, 5 Dec 2020 13:53:04 -0600 Message-Id: <20201205195313.1557473-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 dc812139f4..ad33d2472c 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -60,6 +60,9 @@ However, a non-fast-foward 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 3fd9bd1bd2..300b17b962 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1013,7 +1013,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, a rebase, or a fast-forward.\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 Sat Dec 5 19:53:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953479 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 5DA46C4361B for ; Sat, 5 Dec 2020 19:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F237230FA for ; Sat, 5 Dec 2020 19:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbgLETym (ORCPT ); Sat, 5 Dec 2020 14:54:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726684AbgLETyk (ORCPT ); Sat, 5 Dec 2020 14:54:40 -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 EEE77C0613D1 for ; Sat, 5 Dec 2020 11:53:29 -0800 (PST) Received: by mail-ot1-x343.google.com with SMTP id y24so8753578otk.3 for ; Sat, 05 Dec 2020 11:53:29 -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=4Th18jmzz2gIJS7cam+Q1w9jY+++oT0tBsLHK7wsR/c=; b=iKcZ0xJd0AU+NIM9/PuaOdR+nTD3dDC7lvFCDEOHyWfCjNR+NKXd9wCa0ihD7nltHt lV2ybAY7nT9qMbfozQDXpsfFUk8a74A8/9c5kqolXzkXFBge1Qi+dMsZka2E9u1wbOtr 10ett2BCeRdvPUKX9fLnTTCpCtXGmMtXZD9cJkQfTSrSyBuMBtOCvj8DX+SYRXxgSVgk i+Hws8g2QJ2FVxGrLRpgM6OZVM7UzmmnsscmBNjXY94QRwoSate1ZwMD5QBefMVLi604 kvsJJyzuBdQEAOLv0MbXZHii0Jys1Z5Ak9SNHSjtoDfel4z/PrRdmb79urhNSnenAOmR eeEA== 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=4Th18jmzz2gIJS7cam+Q1w9jY+++oT0tBsLHK7wsR/c=; b=GlrTfWDdXQMC/H40QTWfMWbO6eINSHQyRCKk1/7KddNGe9+jxqQKceoB7TsK8fgZhX D1x0QhRkuclbT+8eCtiOd2cLookGR5BhrpxywYdFvcP27dczXS9uiP27NiiP3xdl9tkf 9YnqijPnuK6Vby0OI5xdssnpfuCNpv3GsfuRnlVO/KMR6qOxUjCb2AqP2CxxtHm4zGl4 b7YjqGDnImYzy2qG05Qvr9HNvOQYPLVAtS+3J38SmkU9ctEj9WXZqZzVukkdDZk9YDEB qSUCEfeyzTO1SCBq8x5GfoI7JSCPZ+iO5pKwPKOImPxzECiSlumHkCm703MaDGwD6up1 OJ/A== X-Gm-Message-State: AOAM533/bfOZbwiTBdi+7pVJ4pWCbzBWyxbQseZeAJTMUEjatW6KBF3m 9doC4Kq+e2Lt2ww3DqY5oayvaMziUnyXgg== X-Google-Smtp-Source: ABdhPJxhI6Plpb/eV4z6zwTQa1NFtEYiEOUlNaqfdoueLd+FQ4JeBmCL5lQSj5cKqmU4eFn59F4fFQ== X-Received: by 2002:a05:6830:10c3:: with SMTP id z3mr2058743oto.143.1607198009056; Sat, 05 Dec 2020 11:53:29 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id q3sm1542775oot.33.2020.12.05.11.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:28 -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 v3 08/16] pull: trivial whitespace style fix Date: Sat, 5 Dec 2020 13:53:05 -0600 Message-Id: <20201205195313.1557473-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 300b17b962..cecbacc549 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 Sat Dec 5 19:53:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953483 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 5BBFAC4167B for ; Sat, 5 Dec 2020 19:54:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24CE2230FA for ; Sat, 5 Dec 2020 19:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726791AbgLETyn (ORCPT ); Sat, 5 Dec 2020 14:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgLETyl (ORCPT ); Sat, 5 Dec 2020 14:54:41 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044A3C08C5F2 for ; Sat, 5 Dec 2020 11:53:34 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id h3so10515986oie.8 for ; Sat, 05 Dec 2020 11:53:33 -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=ZvTQWkFYKQ2TyN5+/ZzotImNKcFX5+pavYv15u3tkKw=; b=hRDgk7eoCdr9Lttfx2KBa+XhFK+R8ZqzwGddXxE4qAqz9oVIFcFex3/SfI4PdtHI4K AIeetUb/cwHH/WDotB8OP4INdtT0SAQ1IUher0IUgcjbXFwgwIP4KiscP4Ryj6/rnJTK 3M2OpGxQbpsmxgv+ZJRO+LdAPP2XUdwPnbbwEJM5nhA4FkSgq5nA0deQHsr1O+r5wtUQ gV8xWKon6t3ASh/ExPTepKw4Lh3MDrXuaHSKoxRv3nJDSzFEQcVPDC8SNFVxERkYWuM4 MDXJu1sgCQX0SaImwaeo0toP7u143KOXFJMi5CNqOCoOi0FqYQwutaVJZ7U8nb8K6Rq2 XQgg== 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=ZvTQWkFYKQ2TyN5+/ZzotImNKcFX5+pavYv15u3tkKw=; b=POxMa2+rUAU9FLpP9iTYsdrlsphhVXWba4tjvP2avXQMwrqPv4P+8c6dW2wmnD81YS wM0Y4405XFOpOpv16m2uciFUd6nYNhEWFGpdpd9igJN/TWcehrs08x+pLhPF5CJFUwGh FrhA2D/a6o82JxRM1aEC+AiA3FGk6NHYWBOZXTBacnITo8D+EjiemmSQf8S806Wgc6T3 ltAblFsRtrtx4GPmNbZMvTREU7ejmSw8zwRXkgsHBs0Pvm77Fj8wFAqBWB50GaAPp/xd 9xgnyB5lCT/yUzwcG5/hIHqkNrdl+mD+6Ko0eGmlIYXvC7sAX2FYYynQfQfVJ+MQZbCC krVw== X-Gm-Message-State: AOAM530/0/oVr6U6O/dKirqZzW8isWSd6HEc3ejZ3wvL8YkzhEkG2aI5 RN43dyB76TuiP/1GIdJGEwkpqQFZwKxqhw== X-Google-Smtp-Source: ABdhPJwlyDJS38itWmUH4HXUkTGMrEQMsfO5yBRwpwcTjerHpQiGmHtLVQ4pTw6YGrAhJI+b40Dtxw== X-Received: by 2002:aca:1109:: with SMTP id 9mr7414932oir.129.1607198013152; Sat, 05 Dec 2020 11:53:33 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id g188sm1614528oia.19.2020.12.05.11.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:32 -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 v3 09/16] pull: introduce --merge option Date: Sat, 5 Dec 2020 13:53:06 -0600 Message-Id: <20201205195313.1557473-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 compatbility). 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 ad33d2472c..c220da143a 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -61,7 +61,7 @@ However, a non-fast-foward 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 cecbacc549..da91d78a22 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), @@ -1024,7 +1026,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 Sat Dec 5 19:53:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953491 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 A65E5C433FE for ; Sat, 5 Dec 2020 19:54:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76B01230FA for ; Sat, 5 Dec 2020 19:54:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726875AbgLETyv (ORCPT ); Sat, 5 Dec 2020 14:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgLETyu (ORCPT ); Sat, 5 Dec 2020 14:54:50 -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 5AC44C08E85E for ; Sat, 5 Dec 2020 11:53:37 -0800 (PST) Received: by mail-oo1-xc34.google.com with SMTP id t23so2271963oov.4 for ; Sat, 05 Dec 2020 11:53:37 -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=Z0c1tLf5NnIZPfC09YAx2DtCiMhMlSBI6uhXPoaXsLQ=; b=lD9Okr9yEzZAiIsN9Z6Ysjoa1ax2oC5hz0zj8DLgaDi6DU8KXhFtzAToDlSy/eWCNK jlOgbxr0Oddw2L40Sut3KWoKHYKoYefHmap1hWoD90+SPqWdPpWlGizy1UxuumbBiByb FF3xjFSpH4BTUXzPNsaDNO554jV0gn6xAPKb5BTEmWaoDx2bKc29DhpDEGqlNGKDXR2t A5eT5eVKhiRhcUqPaJ26OdVED+JyNnXSLcPL3vmwmjAegtLjqFpZGm8urHLzQH03utXQ 9Ski6T1OVLQcGNQrgjv7zK93AXUWHU/Q1pISoQsDHdL7CDWloE1LXkIsC/a5LD+oG1go bjWA== 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=Z0c1tLf5NnIZPfC09YAx2DtCiMhMlSBI6uhXPoaXsLQ=; b=GZpwDyqWrOSJOJsmMwi7xuGp4Xly0jOX0itGF5TebSgeEPcxlpzsvd8qRsTsMik3dB 6v5kBuwvQ74lCG+I9BZHIrEXZ6VMDQsbbxObL/U4rIoIIVZQmICTFMM/hioVl9Ht4iuZ F+ThjhNWKXfCdbUovIs98KNPE7LE/wBZEp3IfoOhIAkHz208JA3bWGzxlypqCmLJ9aAr M+Lk3e0rdUmyIvSUuFbsku9q24qIooCri+tnt1cTSAFLKS/lviHLGmCodMFyy/zGJEmM 7s/hzaGtHKq0yN04SOdNolJb8um2kZlYnMfiB2ztkCrdKqZ3h/bEYelC9R4JXK/fa1nf hEWw== X-Gm-Message-State: AOAM532bgtFBoYfYdn8pZoR7dzptUjWY95RrSXxIEiBP+3jSa5QQw4TU 6uy/b5qXTNTujGFMurSXsQMWGphxQthhkg== X-Google-Smtp-Source: ABdhPJwxxEkylnc1fmp54ZgYEeGrRLf4l9zIunb9ohpmLixUY+u2hpdG8NxZEexcNZVM5sjpYzYjMg== X-Received: by 2002:a4a:bb07:: with SMTP id f7mr7869587oop.44.1607198016558; Sat, 05 Dec 2020 11:53:36 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id b23sm1534011ooa.13.2020.12.05.11.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:36 -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 v3 10/16] pull: show warning with --ff Date: Sat, 5 Dec 2020 13:53:07 -0600 Message-Id: <20201205195313.1557473-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 da91d78a22..2bd6ee9d19 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1015,7 +1015,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, a rebase, or a fast-forward.\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 Sat Dec 5 19:53:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953493 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 766CCC4361B for ; Sat, 5 Dec 2020 19:54:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B9A3230FA for ; Sat, 5 Dec 2020 19:54:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726897AbgLETyw (ORCPT ); Sat, 5 Dec 2020 14:54:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbgLETyu (ORCPT ); Sat, 5 Dec 2020 14:54:50 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33F20C08E85F for ; Sat, 5 Dec 2020 11:53:39 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id l200so10477494oig.9 for ; Sat, 05 Dec 2020 11:53:39 -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=xZ06cAB5AmKT5HiWVn5FUicxmys+2v/iFY1g1DfVc9k=; b=oci14OW5Z/SPSWU+Ps8vpyoNXWVKrnqRaOS5fUp7MarK6skxe4zHmppA3O3X5wt5r1 D3tZSCM/p8+Xo/pBvM+enkklsyZ8N96cQM7DUktuqhXb0ru/WjwM/XrFY6RWk5fxevJ6 W73NRhGfYcZALqRkK2dMiWMGmn/B442LiTNwLJ0An0PxQm24D459h5esiABD5KJhUEtx O81B6Na38i62rgFIiZtyHBDxdqlZvMPbLSNTIlwyQAlRLDWxMBbQTIGhUDT8M3KAi87k qD6scpPNlR1QnwsAI/JqbYcG+cr32v0AOUPeUg870RA0FUHrGMRbeG03fQAEAkoeOy+s 0mzw== 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=xZ06cAB5AmKT5HiWVn5FUicxmys+2v/iFY1g1DfVc9k=; b=NQyJlweSL0gvzCPcF+sq/rcQ9VAtYZOuqWlQwHD9doFTGmteHtUN4f4IjKrmfart7a AYyjyhuzS95lAoOOgu3Cn9fzGfW7Yy1RFuLfRLpr/E5joPm0Gge1Hl/is5kzTQmJJAzF E1NPfLvBOkf7tHbC9E2zHXvcnjwXI0BlPFcSlJKP2PRhqFgktxf2dF7MzALFdpGqa9Pb iHN4evw/RqOUz7nYORme6GsCxTOIaT64UXzezq0/bBJWUVlulovCDW6UUZod5IvKG4PH 3w9zNI6kS1KHXmZXYE6qrjFPebgnBVAsiP3wjDvas5Fugd7iBwTWV3PLy/kRQie+R7xe fnyQ== X-Gm-Message-State: AOAM533gLs4uDse/NDCzkJCPITeov0mJZAF3fH/j17nkhXM4a+M0lCsp i6urcFFBBZ/aR4h4GP2m1p7Ttk7P8b9BVA== X-Google-Smtp-Source: ABdhPJzqWTKo0fG9r5k3SRAeGYwIaf2RwJ1OjrN/237IoSCC1w8QmUfR21zZSwmoSZB8E1V1NjsULQ== X-Received: by 2002:a05:6808:61a:: with SMTP id y26mr7393841oih.72.1607198018250; Sat, 05 Dec 2020 11:53:38 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id f10sm1174638oti.11.2020.12.05.11.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:37 -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 v3 11/16] rebase: add REBASE_DEFAULT Date: Sat, 5 Dec 2020 13:53:08 -0600 Message-Id: <20201205195313.1557473-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 2bd6ee9d19..347ac89eee 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.")); @@ -938,7 +934,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()) @@ -950,7 +946,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; @@ -1010,12 +1006,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, a rebase, or a fast-forward.\n" "You can squelch this message by running one of the following commands:\n" @@ -1031,7 +1027,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) )); } - if (opt_rebase) { + if (opt_rebase >= REBASE_TRUE) { int ret = 0; if ((recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && 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 Sat Dec 5 19:53:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953487 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 B839AC4361A for ; Sat, 5 Dec 2020 19:54:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89316230FA for ; Sat, 5 Dec 2020 19:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgLETyq (ORCPT ); Sat, 5 Dec 2020 14:54:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgLETyp (ORCPT ); Sat, 5 Dec 2020 14:54:45 -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 7A300C08E860 for ; Sat, 5 Dec 2020 11:53:40 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id t205so10469279oib.12 for ; Sat, 05 Dec 2020 11:53:40 -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=KF/sZs7wabdButTQPfO4KCzOkeZsQTzfYeXG+Uhr3sM=; b=GL1JmF0m6f+JwPbeSmrrAPG05MPqJU/mASjV9JbkXWnqeFy1d6PWkkfERV1MWQvZX3 bk0BfIAWZX9EuhwCllzvIbEi/kAEqSky1Sh2TNm4p9gZRx9y7hh9JjDSFKSxh3yDxsoO MGyQgDEQ3mqEn4iUsd62FW5Wd7CQc7YAWG98U1rKMzkFExUxYtj8f66De8ckbHLGkd2e cIF8QZfJ4pmvEnp0nhyQj6gAkK1P3obDCF6yowT8PtjBsOuP4m+rospm5CW4OjrN7Oxa txi/TmIdB5iTo79RbH1lK5iow0QAYfKlBBjeu5eiTs7fXEl4m9BWgSUx9kDvJ+VCv/jg /Shw== 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=KF/sZs7wabdButTQPfO4KCzOkeZsQTzfYeXG+Uhr3sM=; b=OnGTsrb9o+X3ha9m4uRUGQy9oPcET3Z/eT7W9NKUKCa6aHa3FldY+6EJ+Jvp+A4ZTI icm+Q0jcsIc6Rawnh9ts4C1MCsoUjrjpePReuFgCSD9jtFXO/i+e6LVyYRftTF/qlyTc b/K6oY/Kw0BaeLIYwF7kMB4/Gnv6N3s2rKhn5YY1t1d4IopUeu7ipCXp+OHbydEFzLW7 bV9b62u+T8kX4Kmu/l0ggJLOhvFPdbG8/vVV+SluJo4ExzHgWpUZwDdqq4yd3wv5npda N/aTTo5jhub1oVBYFKDjCpnTyTgOjUJUWYr47Xd3W4pP3OVNRbOHU+GnKoHTC4fCstu1 MqaQ== X-Gm-Message-State: AOAM532G7Spelose3tuBoJPvx3oPPwjL8IT3GjfkR/tca9n2H4Z/Pd4t v/uDXBL+e76i65ytqpR0vtTKHTXoznGGbw== X-Google-Smtp-Source: ABdhPJyHfk4+bhFUKkQ1kHUb7apsFYf+awWhIgNCSlUT+sWkC7tySsBDuyb8t6JErFVCGTFVRNs+Cw== X-Received: by 2002:a54:4012:: with SMTP id x18mr7484945oie.20.1607198019736; Sat, 05 Dec 2020 11:53:39 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id k1sm1520046ood.4.2020.12.05.11.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:39 -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 v3 12/16] pull: move configurations fetches Date: Sat, 5 Dec 2020 13:53:09 -0600 Message-Id: <20201205195313.1557473-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 347ac89eee..e0157d013f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -915,6 +915,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); @@ -931,12 +934,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 Sat Dec 5 19:53:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953485 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 52F8FC433FE for ; Sat, 5 Dec 2020 19:54:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 229C9230FA for ; Sat, 5 Dec 2020 19:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgLETyq (ORCPT ); Sat, 5 Dec 2020 14:54:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgLETyp (ORCPT ); Sat, 5 Dec 2020 14:54:45 -0500 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D689C08E861 for ; Sat, 5 Dec 2020 11:53:42 -0800 (PST) Received: by mail-ot1-x32e.google.com with SMTP id w3so8103189otp.13 for ; Sat, 05 Dec 2020 11:53:42 -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=2F4Y4lHwIoHakhpeYacH5Ikbck/Mt74vDktyEsLDQjM=; b=vFAdfXCETz+p7U6p7IFbfdgzxMbQv81kwn1xopvcf2etqbPgoyemqzKbZzk1jXHDOx ZmoAOcMZmztTb1see17db7AOnmEUEDvh/DE0Putuk7vxMskSfVaVdWajo5dVNE7abDUA 1bl65zCQqbVt4T3DgGbiHhg9gA7+W2JUC6hX30XwNQaTGgcBweMKdDIsn7bdHA32NoqO Wkjfa/u9y4roVZVpQsm+oQgcCzskpGdg2BIQ5kkYF1Dp/gqoMoA98QzfTQ421fs+J73i LCqPqTjC9OCytkyEEehUkPQsckm1fRWx4cVDsWHWDu05abBiAtHAdImeYb3JnCIcMxLY UAEA== 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=2F4Y4lHwIoHakhpeYacH5Ikbck/Mt74vDktyEsLDQjM=; b=Spq4tJp1vU9LboW7lBEH1nWZviKjWr/5uNaMHvANV20hceXSCeCz9refK5N/PzqTWr xt5ajhz3He5QowfTDv3FqzoIEZLqDVFbVcS4kIfGkurgV305VvVv8mOTwz1X2u3pX16H swjFIoqOFlOAbYJ+vGmqjvTQ9HRlW2BHHfvmt1EncipeXucUiklQTNINw7XtP1R3X22R q5CmUufzhehYKubVQhtiNp72POYp+UhMJHr2FiN8rb0926+SJ5b5/IicAMXsUCB02H4a 1W8r32YLmX145l3XEUe6b/TlOKBVGmbw1c/VODjODlRXbPU9pGJrqGTuhZxIOjPtpmXs UH0Q== X-Gm-Message-State: AOAM531aDmd7cVJ9OwHT+yll/3Yl5nMOB28BT5Rw0tY+9Q39z0eHBAPu HY68T/14fytMIaHe4plJYwsJs3sTrgOGLw== X-Google-Smtp-Source: ABdhPJzGdq5IzwXPyMwui+NRntm41mH9/LMub+U18F63fY5dUYA/CvH5BlU0JbStEzegQ6EcD4FXYA== X-Received: by 2002:a9d:5781:: with SMTP id q1mr7988544oth.325.1607198021708; Sat, 05 Dec 2020 11:53:41 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id o6sm1553947oon.7.2020.12.05.11.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:41 -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 v3 13/16] pull: add proper error with --ff-only Date: Sat, 5 Dec 2020 13:53:10 -0600 Message-Id: <20201205195313.1557473-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The current error is not user-friendly: fatal: not possible to fast-forward, aborting. We want something that actually explains what is going on: The pull was not fast-forward, please either merge or rebase. The user can get rid of the warning by doing either --merge or --rebase. Except: doing "git pull --merge" is not actually enough; we would return to the previous behavior: "fatal: not possible to fast-forward, aborting". In order to do the right thing we will have to change the semantics of --ff-only. Signed-off-by: Felipe Contreras --- builtin/pull.c | 60 +++++++++++++++++++++++----------- t/t5520-pull.sh | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 18 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e0157d013f..54c58618e9 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -112,6 +112,24 @@ static int opt_show_forced_updates = -1; static char *set_upstream; static struct strvec opt_fetch = STRVEC_INIT; +static int parse_opt_ff_only(const struct option *opt, const char *arg, int unset) +{ + char **value = opt->value; + opt_rebase = REBASE_DEFAULT; + free(*value); + *value = xstrdup_or_null("--ff-only"); + return 0; +} + +static int parse_opt_merge(const struct option *opt, const char *arg, int unset) +{ + enum rebase_type *value = opt->value; + free(opt_ff); + opt_ff = NULL; + *value = REBASE_FALSE; + return 0; +} + static struct option pull_options[] = { /* Shared options */ OPT__VERBOSITY(&opt_verbosity), @@ -129,8 +147,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), @@ -159,9 +178,9 @@ static struct option pull_options[] = { OPT_PASSTHRU(0, "ff", &opt_ff, NULL, N_("allow fast-forward"), PARSE_OPT_NOARG), - OPT_PASSTHRU(0, "ff-only", &opt_ff, NULL, + OPT_CALLBACK_F(0, "ff-only", &opt_ff, NULL, N_("abort if fast-forward is not possible"), - PARSE_OPT_NOARG | PARSE_OPT_NONEG), + PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_ff_only), OPT_PASSTHRU(0, "verify-signatures", &opt_verify_signatures, NULL, N_("verify that the named commit has a valid GPG signature"), PARSE_OPT_NOARG), @@ -1008,20 +1027,25 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - 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, a rebase, or a fast-forward.\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 --merge\".\n" - "Read \"git pull --help\" for more information." - )); + if (!can_ff && !opt_rebase) { + if (opt_ff && !strcmp(opt_ff, "--ff-only")) + die(_("The pull was not fast-forward, please either merge or rebase.")); + + if (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, a rebase, or a fast-forward.\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 --merge\".\n" + "Read \"git pull --help\" for more information." + )); + } } if (opt_rebase >= REBASE_TRUE) { diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 9fae07cdfa..0cdac4010b 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -819,4 +819,89 @@ 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 (ff-only)' ' + test_config pull.ff only && + setup_ff && + git pull +' + +test_expect_success 'non-fast-forward (ff-only)' ' + test_config pull.ff only && + setup_non_ff && + test_must_fail git pull +' + +test_expect_success 'non-fast-forward with merge (ff-only)' ' + test_config pull.ff only && + setup_non_ff && + git pull --merge +' + +test_expect_success 'non-fast-forward with rebase (ff-only)' ' + test_config pull.ff only && + setup_non_ff && + git pull --rebase +' + +test_expect_success 'non-fast-forward error message (ff-only)' ' + test_config pull.ff only && + setup_non_ff && + test_must_fail git pull 2> error && + cat error && + grep -q "The pull was not fast-forward" error +' + +test_expect_success '--merge overrides --ff-only' ' + setup_non_ff && + git pull --ff-only --merge +' + +test_expect_success '--rebase overrides --ff-only' ' + setup_non_ff && + git pull --ff-only --rebase +' + +test_expect_success '--ff-only overrides --merge' ' + setup_non_ff && + test_must_fail git pull --merge --ff-only +' + +test_expect_success '--ff-only overrides pull.rebase=false' ' + test_config pull.rebase false && + setup_non_ff && + test_must_fail git pull --ff-only +' + +test_expect_success 'pull.rebase=true overrides pull.ff=only' ' + test_config pull.ff only && + test_config pull.rebase true && + setup_non_ff && + git pull +' + +test_expect_success 'pull.rebase=false overrides pull.ff=only' ' + test_config pull.ff only && + test_config pull.rebase false && + setup_non_ff && + test_must_fail git pull +' + test_done From patchwork Sat Dec 5 19:53:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953475 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 A3D1FC4361A for ; Sat, 5 Dec 2020 19:54:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74890230FA for ; Sat, 5 Dec 2020 19:54:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726641AbgLETy0 (ORCPT ); Sat, 5 Dec 2020 14:54:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbgLETyZ (ORCPT ); Sat, 5 Dec 2020 14:54:25 -0500 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46992C08E862 for ; Sat, 5 Dec 2020 11:53:44 -0800 (PST) Received: by mail-oo1-xc32.google.com with SMTP id i7so2259318oot.8 for ; Sat, 05 Dec 2020 11:53:44 -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=ZtoSh/VAeI+x35Np0WYwJsur3g2dZmjdhTHzsjouNBLK4aPh6wIbgl8DcoGHOqgLlV qERo7CREnojosAhRvsPkkpYzW7TFfitKNuVbeTX2fGVNn9gEILMs/7gKmbEwH7QJONBt kGtzOK1uL9ojmCkacEzLkNvu63Z0rqo9hvMVYaEE7KFkaUhM80LP2c9GjznoJCG2zfuX mej+1sFOOTcvT5ewjlUk4xs1Im+XWk1kLYZD7BpXXPiOB9OwiT2+0XNucHXqQcZ0QjA4 hwf4qzIUkFwiZQHpXkM9oKFs/C6exPPOnjh8I1lbe82h3/1v8YdMCbTTWN8aZOtjORan DIaA== 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=J28Bz2hFfuA8ao3epdQqVEz5VC/WyD6lmOsmOZPzZ4I0L3QMAIfQPdP+fDTcndZVYX Lnu/I52DDozvbdE/nn0hH4WEFi9QHeGfpG+eJ/84wU3OV3/k9AK042z4kWOVQS2NbmL7 8fxVzzfjojepwk3XCjEkMpX86Gbwf0WrGujnEEPT7xto58SZRPcCil8Pte9bTBWJpYwL T3DPeeyfM3wr8yqtrYEx6klMS97aUKXvs8nkZ1wLy3qtBfLTktqIceJRTrSx++fDWPdr 9QZNCMHZxA1w57PfaTe3jaSl9Nk/IAZEk9Q0QPIGAdT9FECu+ejEmGj3KyUxh2dy1/8F cBSg== X-Gm-Message-State: AOAM533qiObwcScnyVQ8HxHfETrW/S0Z5ciCHir3OSEfaH2Zi+HTX2PJ wIWwCRxsKBT5UyVY6UcTbHbQUe+VEh7Wnw== X-Google-Smtp-Source: ABdhPJw+nZXQ+0WtA9yBBOD+yjXRp4OQhoDRn0h2yrnvwZEB46lTnd+U5z48rHEVSBhR4OZb3Qzhsw== X-Received: by 2002:a4a:c102:: with SMTP id s2mr7815234oop.60.1607198023475; Sat, 05 Dec 2020 11:53:43 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id a25sm1536760oos.23.2020.12.05.11.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:42 -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 v3 14/16] test: merge-pull-config: trivial cleanup Date: Sat, 5 Dec 2020 13:53:11 -0600 Message-Id: <20201205195313.1557473-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 Sat Dec 5 19:53:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953489 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 E940DC4361A for ; Sat, 5 Dec 2020 19:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCBC3230FA for ; Sat, 5 Dec 2020 19:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbgLETyv (ORCPT ); Sat, 5 Dec 2020 14:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbgLETyu (ORCPT ); Sat, 5 Dec 2020 14:54:50 -0500 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC96DC08E863 for ; Sat, 5 Dec 2020 11:53:45 -0800 (PST) Received: by mail-oi1-x22a.google.com with SMTP id f11so10503024oij.6 for ; Sat, 05 Dec 2020 11:53:45 -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=AIqx8XkmJPwSzi3cCkk+MnlxdV9nnAJbe83qJlnqhecJ1HgxxlGTUvufuA32T0d4dZ COK2LHb/5qYTh14KDA0QSCxs73BpHXnB4YruvJT9YV3oEUSnK0jBle71AEZ5vxt+iN9b aKZP6vIBg1IwEZzpYhRP9y+0JhG1cJGOefvsDF/hWwSuR4uv7AIhoR/ygQEGm6NW6vKk f37q9mgyL4KoXxCFjHAtlrL2zur6DgAg6XbclTKO1W7jIVsUXC8vI7v+z4Ox9bMeUJhb +zeUm4zbtWpLyL37PYPe4zhnhcGwGoyBiicMGu+MM4gYaAwq8PQ3jj8ae1Am1KpsxPpl 2FAQ== 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=nC2/cKvhcmY6tMMRUqnm3f2P9V8/t2DMN8LV2f32QvmsRfhXi7cvTNzdhwr6vwNzuw o++Dqvbe2hQ0gEonI+eqoXrcfIWarFN8b+ZnGdOVUm9KOkATTAAqkcNOGS0qyHO9dkE0 1H/3NDknzc9o58SowZrmP84S1MPZKJeeEJCcc22VoP/J1EI6e7VBEZbESWsYMs21CYed Kv+vkrqRxssUdodEKy+tCYml0gv+Lch5NwgdDtqWhr40JV8S8IfDk7RYViOBvu3GMYLw WbwG/SFOipqnuMG/FeO6pYc0xxDi4p3TdrdAODwkhb9rcfPGZCZLf6l3vFscnYZJfGbr cWUg== X-Gm-Message-State: AOAM533FUWAYLVCmFtwJxWk3oIjIQxPEJaUEKiuzxzJSiwYsglUs+CGG fqGXiH9p6QxsZIOKt483NG9J2uwSK++Ufw== X-Google-Smtp-Source: ABdhPJxZ7OcncUd6DvFMQ78j+lsdcS37lBkeKG7OUhsD5oegnUI6pwqYeoN4U765r9JBT0QhjtSICQ== X-Received: by 2002:aca:afd0:: with SMTP id y199mr811991oie.7.1607198025013; Sat, 05 Dec 2020 11:53:45 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id a21sm1603356otr.36.2020.12.05.11.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:44 -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 v3 15/16] test: pull-options: revert unnecessary changes Date: Sat, 5 Dec 2020 13:53:12 -0600 Message-Id: <20201205195313.1557473-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 Sat Dec 5 19:53:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11953473 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 18B7EC433FE for ; Sat, 5 Dec 2020 19:54:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5F28230FA for ; Sat, 5 Dec 2020 19:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726661AbgLETy0 (ORCPT ); Sat, 5 Dec 2020 14:54:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgLETyZ (ORCPT ); Sat, 5 Dec 2020 14:54:25 -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 5AEA5C08E864 for ; Sat, 5 Dec 2020 11:53:47 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id s75so7435158oih.1 for ; Sat, 05 Dec 2020 11:53:47 -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=bpaJmWqJNQ+6DkuSnN0Ra46VfprtnQPxAvNZfM5xGgY=; b=hDBiTdbyT4bYCd/6C15fIxOdv6kSLfTFxegY04Nm7KcXlR1l9w1r31Jkoe30/AC3cI 78BadRhKdTwR6jn9TbB7V8PcSrYMng+sbd2e06akNgW8l+cxEpP7LwneVRowdRs+/bdH 2NqiaHt30qfq8RwsaeKk2wv5QaR3HfpDRnd2p13onnG7APRejTCuX7O8gPKWmeJF8rjc Tuv+9xVgjxXO6HW9aKXcIonqqTjrJzj0RF03+JjdUj4wg/xUpPWdbJUq9xwQvAHjeiyh GwvoOcuCnECmemrDrcoNjZdqyL1QHvV6FmgxxAYiGUhnf1gTgVk9aSZByYA1XukHhhdj UIVQ== 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=bpaJmWqJNQ+6DkuSnN0Ra46VfprtnQPxAvNZfM5xGgY=; b=LHuE0ZQaSjroVRK8DLvVJrnKFGVmDuZcnauuPe5fWB+ejc7fIqaxK+GTbzs8pOdMKU 6dmvnRjBhyae6yQsSMNQUGx+9ac/JgGeMqejEyz7o+1Z8/omGvAC9tJVVFTxF1HfuTlL 7MWXcrmSO4ISTvxqsALTTmhvPCgbmA94BD9IkDv+ditKh47nK9XC9z+HJYFJ/2yNxTTq RsRgpW+evAxcTVHTBMKk7ucydqoU/lKNilqizIDCbsEnDDxnys7Xi8UuHRvYJuQ5UL6R WL+M2qcOQSrzoI030p3e9dtW0O2tT19xaI+W0479AQeK+BhYh64/rE0D3tHJTJpqF8kW KU+g== X-Gm-Message-State: AOAM533u49Nr17OQssQ9Zh8ADzcXh26qe+iFS9lZim1pQ0gcSwHwNc6R 3ZF9Q0n8S29crJfS1jgdVTZtE0rfOJ47RQ== X-Google-Smtp-Source: ABdhPJzLmCwF87z4J6TbdjrzH3mDyO/beNR6L9qrcepLBCz5UfqWGWO53U7XGS5Arq/j/VgaOj8VWA== X-Received: by 2002:aca:bb43:: with SMTP id l64mr7266470oif.52.1607198026516; Sat, 05 Dec 2020 11:53:46 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id 43sm1506630otf.28.2020.12.05.11.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2020 11:53:46 -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 v3 16/16] pull: trivial memory fix Date: Sat, 5 Dec 2020 13:53:13 -0600 Message-Id: <20201205195313.1557473-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201205195313.1557473-1-felipe.contreras@gmail.com> References: <20201205195313.1557473-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 54c58618e9..0735c77f42 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1057,7 +1057,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(&curr_head, merge_heads.oid, &rebase_fork_point);