From patchwork Thu Jul 15 02:40:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12378317 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 E7297C12002 for ; Thu, 15 Jul 2021 02:40:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF76061377 for ; Thu, 15 Jul 2021 02:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbhGOCnu (ORCPT ); Wed, 14 Jul 2021 22:43:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbhGOCnq (ORCPT ); Wed, 14 Jul 2021 22:43:46 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF5B6C061760 for ; Wed, 14 Jul 2021 19:40:52 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id j34so2731760wms.5 for ; Wed, 14 Jul 2021 19:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=CSIz9YDdUnOe4L/xkt9QMXDMUaeHcEtzG87P17Gd9J4=; b=KRQn7Ip3NRxwGQAMeuFwrhZ4Nm6bHdcSRztS5gkgNGoyUyOBNPtYaiaPGugRGek5Wp quv4IiGt0pFsaPuVz/sYXN6OhZhrbxA38f7ml1n6pTAccFn8oahKiBvJukWLAbPIKcjB bAIGDpUzPqeqWfl2Tkq77xicGdbIEvvyrushDtdiz60CHASTyZoRwaTQ/ZU74KoQWGH2 sCdnutcx2t8iCA7c0Sz5KoZK2fnEcAnEq2PlVxZCzmAozo4CZOUAW8jt+kWS+JvYg0gb 52LykP4OVBFvTG+cVgokzXNQ4aMvBZyWqQei5peTIviZT03pyFYAuZaR3GF71T1hMdQX Ik9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=CSIz9YDdUnOe4L/xkt9QMXDMUaeHcEtzG87P17Gd9J4=; b=hatzQIx4X/IopVeXH4LpbeQWRGQWiMa2YC6g9qESVj3kbW4zESVR2xjvVaU4POMv59 xGo/xiNLcT6ar1pJFoYwSq15F1SHV4/aoDjaE8JnZ6xckNlhv8lpYcUT27WGjlwucCzN WJIpxq/eajujI7FR2zcpz/w+FD17946bjY5aw4HHThEhOY5GHcvtdRIXa7SK7kuHKVOt quyPe8xbNJBu3r4kAlTsaAYUkPPJ7+7wYWplrWxAWkRSbx6UhAH+S1gHaPMPfpHjFnrH caCFi/s+SeYTj5WaVQ3u1qbmd05XRb6hjX82YhBrlAeThRH65zH8GVFzAmFQJnIUf7p1 Hasw== X-Gm-Message-State: AOAM530+MdTm71EEWYVRgf1u8RZaD3YqK62Rmpaz1qxaDdfdvmFdBeti 0G5vItEKZBcf0Ue7rWEk5KmqkmvhIRs= X-Google-Smtp-Source: ABdhPJyLS+ewkHQzku0Y7r3hblH5e+ej8ISN6mrTcz6D3DIEMykR6bIFfMR8xivPCL0w9qgrOxxVhA== X-Received: by 2002:a1c:2985:: with SMTP id p127mr1461225wmp.165.1626316851499; Wed, 14 Jul 2021 19:40:51 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v30sm5053143wrv.85.2021.07.14.19.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 19:40:51 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Thu, 15 Jul 2021 02:40:45 +0000 Subject: [PATCH 1/5] pull: move definitions of parse_config_rebase and parse_opt_rebase Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alex Henrie , Phillip Wood , Son Luong Ngoc , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren No code changes, just moving these so a subsequent change will have access to some variables. Signed-off-by: Elijah Newren --- builtin/pull.c | 72 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 3e13f810843..61c68e4143f 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -27,42 +27,6 @@ #include "commit-reach.h" #include "sequencer.h" -/** - * 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 - * "merges", returns REBASE_MERGES. If value is "preserve", returns - * REBASE_PRESERVE. If value is a invalid value, dies with a fatal error if - * fatal is true, otherwise returns REBASE_INVALID. - */ -static enum rebase_type parse_config_rebase(const char *key, const char *value, - int fatal) -{ - enum rebase_type v = rebase_parse_value(value); - if (v != REBASE_INVALID) - return v; - - if (fatal) - die(_("Invalid value for %s: %s"), key, value); - else - error(_("Invalid value for %s: %s"), key, value); - - return REBASE_INVALID; -} - -/** - * Callback for --rebase, which parses arg with parse_config_rebase(). - */ -static int parse_opt_rebase(const struct option *opt, const char *arg, int unset) -{ - enum rebase_type *value = opt->value; - - if (arg) - *value = parse_config_rebase("--rebase", arg, 0); - else - *value = unset ? REBASE_FALSE : REBASE_TRUE; - return *value == REBASE_INVALID ? -1 : 0; -} - static const char * const pull_usage[] = { N_("git pull [] [ [...]]"), NULL @@ -112,6 +76,42 @@ static int opt_show_forced_updates = -1; static char *set_upstream; static struct strvec opt_fetch = STRVEC_INIT; +/** + * 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 + * "merges", returns REBASE_MERGES. If value is "preserve", returns + * REBASE_PRESERVE. If value is a invalid value, dies with a fatal error if + * fatal is true, otherwise returns REBASE_INVALID. + */ +static enum rebase_type parse_config_rebase(const char *key, const char *value, + int fatal) +{ + enum rebase_type v = rebase_parse_value(value); + if (v != REBASE_INVALID) + return v; + + if (fatal) + die(_("Invalid value for %s: %s"), key, value); + else + error(_("Invalid value for %s: %s"), key, value); + + return REBASE_INVALID; +} + +/** + * Callback for --rebase, which parses arg with parse_config_rebase(). + */ +static int parse_opt_rebase(const struct option *opt, const char *arg, int unset) +{ + enum rebase_type *value = opt->value; + + if (arg) + *value = parse_config_rebase("--rebase", arg, 0); + else + *value = unset ? REBASE_FALSE : REBASE_TRUE; + return *value == REBASE_INVALID ? -1 : 0; +} + static struct option pull_options[] = { /* Shared options */ OPT__VERBOSITY(&opt_verbosity), From patchwork Thu Jul 15 02:40:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12378321 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 B07C5C47E48 for ; Thu, 15 Jul 2021 02:41:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9346C61396 for ; Thu, 15 Jul 2021 02:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231736AbhGOCnw (ORCPT ); Wed, 14 Jul 2021 22:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230256AbhGOCnr (ORCPT ); Wed, 14 Jul 2021 22:43:47 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F2CC061762 for ; Wed, 14 Jul 2021 19:40:53 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id f17so5655667wrt.6 for ; Wed, 14 Jul 2021 19:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=fjqjbHaovHy3/vGHLL5OMWi8ZWpUM+5EZGbRH1StEtE=; b=AioK5e6InOXm5yGG7R/MlS8EdqvrPK9FpBm5Dj++gnJNccEn25vhDAk9XkJ4CMDL5a 8d1N+8S8izIbR61s6/EvCD99nx093u0lD1S9NnV2xqWlDAuQtMh8miAHBgudzOY/700r bjcbvy0n1RLfCmPG1BEUO/ZwMnj2NCAQSqqRm6kv3Cc1aTqkDuR4D/itR/2IzY33IZjR TpPcIEo9rRf20SlLJ4YCXuDGBfdhFgYmlEpgXnF8U8w8PVLqZphJ+zy144NmCAjivuA2 qdZ7429XHXEmp4mmCSW7P71bZNNDggY+0qpf9Je1FaY3CyGGWttF0BMU56AhrNSEQdtz a1TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=fjqjbHaovHy3/vGHLL5OMWi8ZWpUM+5EZGbRH1StEtE=; b=ECusBN1vGOI3h39RT5LMYNiHCd0wrs7ipdTZQax5af7JpA2GGqrRSY7aMX+yuOX78B Nv5yN5/2tPO2zDUwnfirNNEjUInq4Uy7iN6hQp3WkWJQOaPTlbI4d/PxG78Q2mijnSix 9i85JdW4FG0AZQoZsfS0vp4JHorRVykaWqhEuRrSjU6rMJ8SKEgUwA1ajtGdxhO6+ZuI PMG6D8iWCb9yjW0leWvZCIX7iYjeS5+6PROQ7hqbhb08a8VCsiAMx8Wwsr+hLuWG9nNg yrN3nG1vBa4lno2Id0HTknehqLSr60WdNczLfqkxH+2BYZQuYibDhOHYNn9q1WdU6+LZ iH6g== X-Gm-Message-State: AOAM533Q5f5Ub7JwOVmK62MoijKlpprKmhmA5I5VeXUHvuEm2JD7PgU7 9imYqwuLtJfPqyZ3pMG04f+XTYrfL3c= X-Google-Smtp-Source: ABdhPJxmtIw6xf78AfUPiDgQE+lbmk2g5UIZT5/zsIfG/W4iu88Kqn/CIES+e1ns71+mNyec98uqHQ== X-Received: by 2002:a5d:4402:: with SMTP id z2mr1769069wrq.44.1626316852159; Wed, 14 Jul 2021 19:40:52 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o18sm4598593wrx.21.2021.07.14.19.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 19:40:51 -0700 (PDT) Message-Id: <2fc7344863103dc8f94499e60a16d0a8b47bda22.1626316849.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 15 Jul 2021 02:40:46 +0000 Subject: [PATCH 2/5] pull: convert OPT_PASSTHRU for fast-forward options to OPT_CALLBACK Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alex Henrie , Phillip Wood , Son Luong Ngoc , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren This results in no functional changes, but allows us to add logic to the callback in a subsequent commit. Signed-off-by: Elijah Newren --- builtin/pull.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 61c68e4143f..d99719403d0 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -112,6 +112,16 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset return *value == REBASE_INVALID ? -1 : 0; } +static int parse_opt_ff(const struct option *opt, const char *arg, int unset) +{ + if (unset) + opt_ff = "--no-ff"; + else + opt_ff = xstrfmt("--%s", opt->long_name); + + return 0; +} + static struct option pull_options[] = { /* Shared options */ OPT__VERBOSITY(&opt_verbosity), @@ -154,12 +164,14 @@ static struct option pull_options[] = { N_("edit message before committing"), PARSE_OPT_NOARG), OPT_CLEANUP(&cleanup_arg), - OPT_PASSTHRU(0, "ff", &opt_ff, NULL, - N_("allow fast-forward"), - PARSE_OPT_NOARG), - OPT_PASSTHRU(0, "ff-only", &opt_ff, NULL, - N_("abort if fast-forward is not possible"), - PARSE_OPT_NOARG | PARSE_OPT_NONEG), + OPT_CALLBACK_F(0, "ff", &opt_ff, NULL, + N_("allow fast-forward"), + PARSE_OPT_NOARG, + parse_opt_ff), + 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_ff), OPT_PASSTHRU(0, "verify-signatures", &opt_verify_signatures, NULL, N_("verify that the named commit has a valid GPG signature"), PARSE_OPT_NOARG), From patchwork Thu Jul 15 02:40:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12378319 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 6DDCFC1B08C for ; Thu, 15 Jul 2021 02:41:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 562E661377 for ; Thu, 15 Jul 2021 02:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbhGOCnv (ORCPT ); Wed, 14 Jul 2021 22:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbhGOCnr (ORCPT ); Wed, 14 Jul 2021 22:43:47 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E771C06175F for ; Wed, 14 Jul 2021 19:40:54 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id a23-20020a05600c2257b0290236ec98bebaso173978wmm.1 for ; Wed, 14 Jul 2021 19:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=x8SokSttIk6+HafxFnJ724fdoX4MYCuNU3p2AIgHh/A=; b=T2EMKlRK6sE3cRnGOJVXUQ2xFOAvdJ9yr5Qs45xqKjThplX+SMb20kJfObqRpeYJRU g6MwnIKRsYtX9BZABTk2sR+f1QPerl7K9pcLCIPLfGQPqsEa09+5rGD8l0SLKncX8c/0 m4w8Vog43Hj0e+5dESjEYNqzQsprJ7p177Y7rsuH2K9vO/HefBU7mUe8HI3iAtLEsKRp D+ls+7WfZEp/4zwXLaeuEDgAgFm1XMppRIxPZ3P1QMftHOIVlvv7l7zIW3XGLlnEezbB VtQ8ItBIWzr5oxGqW2ohYahBzMgFSeeTmxe8e1T99+S3I0fKBakJmsohfKT0+6a94NMV texw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=x8SokSttIk6+HafxFnJ724fdoX4MYCuNU3p2AIgHh/A=; b=clNTDGTJn8h5W2bklV9ZlYa5/fl6XjU0fddN8TCCefFIV76FI3ha8SThfpsPLh+Y7w YeW2sUFp0QTq7nZlwMWBxTcOaliMh+TJV1mIFobmVwvZ7CUSavBne9ACocd02if/u5ma n9bYQL80C0H7jsxD3nclwYGFak8qGldzWBZ6rNMFQCXTl2NvXrdKx/c1MshJAzEOInfL T2f5v/l4xWTnjzIS8c3/cznmaLY8wIOq021TJx76S1BJx8iLgL+KhmQ4vCzxJSeR5ozr Q2SNNIzNom8n+nnjOxERM4KH9YVF5ih4upAagl+mHwBx+YmhvEC6hueC5uWoitjeyUa1 zARg== X-Gm-Message-State: AOAM532A4xjDQZZ9BTTQAB8KgRh28nf1avD43jvTb1WPaCdd6YqRmgla 02BYpzbP2nggKZ6BurC3AAUkq+hBM9c= X-Google-Smtp-Source: ABdhPJxvWtamoPvCcTA6GUD24mPG4iLFz/x3KCyXttiIQkqlQ2ssAYgQa5g0l6RLkxWUSpLQ2KRGNA== X-Received: by 2002:a1c:c90f:: with SMTP id f15mr7499660wmb.142.1626316852714; Wed, 14 Jul 2021 19:40:52 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id k20sm5044390wrd.70.2021.07.14.19.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 19:40:52 -0700 (PDT) Message-Id: <3c07ce978caa832b08c6bef1c48c061e41a6fd0b.1626316849.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 15 Jul 2021 02:40:47 +0000 Subject: [PATCH 3/5] pull: handle conflicting rebase/merge options via last option wins Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alex Henrie , Phillip Wood , Son Luong Ngoc , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren The --rebase[=...] flags and the various ff flags are incompatible, except that --no-rebase (or --rebase=false) work with any of the ff flags, and --ff works with any of the rebase flags. Both sets of these flags could also be passed via configuration options, namely pull.rebase and pull.ff. As with elsewhere in git: * Make the last flag specified win * Treat command line flags as coming after any configuration options * Do not imply an order between different configuration options; if they conflict, just report an error. Signed-off-by: Elijah Newren --- Documentation/config/pull.txt | 3 +- Documentation/git-pull.txt | 3 ++ builtin/pull.c | 12 +++++++ t/t7601-merge-pull-config.sh | 67 +++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index 54048306095..e70ed99e408 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -7,12 +7,13 @@ pull.ff:: line). When set to `only`, only such fast-forward merges are allowed (equivalent to giving the `--ff-only` option from the command line). This setting overrides `merge.ff` when pulling. + Incompatible with pull.rebase. pull.rebase:: When true, rebase branches on top of the fetched branch, instead of merging the default branch from the default remote when "git pull" is run. See "branch..rebase" for setting this on a - per-branch basis. + per-branch basis. Incompatible with pull.ff. + When `merges` (or just 'm'), pass the `--rebase-merges` option to 'git rebase' so that the local merge commits are included in the rebase (see diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 5c3fb67c014..03e8694e146 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -121,6 +121,9 @@ When false, merge the current branch into the upstream branch. + When `interactive`, enable the interactive mode of rebase. + +Note that these flags are incompatible with --no-ff and --ff-only; if +such incompatible flags are given, the last one will take precedence. ++ See `pull.rebase`, `branch..rebase` and `branch.autoSetupRebase` in linkgit:git-config[1] if you want to make `git pull` always use `--rebase` instead of merging. diff --git a/builtin/pull.c b/builtin/pull.c index d99719403d0..b355fd38794 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -109,6 +109,11 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset *value = parse_config_rebase("--rebase", arg, 0); else *value = unset ? REBASE_FALSE : REBASE_TRUE; + + /* --rebase overrides earlier --ff-only and --no-ff */ + if (*value != REBASE_FALSE) + opt_ff = "--ff"; + return *value == REBASE_INVALID ? -1 : 0; } @@ -119,6 +124,10 @@ static int parse_opt_ff(const struct option *opt, const char *arg, int unset) else opt_ff = xstrfmt("--%s", opt->long_name); + /* --ff-only and --no-ff override earlier --rebase */ + if (strcmp(opt_ff, "--ff")) + opt_rebase = REBASE_FALSE; + return 0; } @@ -984,6 +993,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_rebase < 0) opt_rebase = config_get_rebase(&rebase_unspecified); + if (opt_rebase != REBASE_FALSE && opt_ff && strcmp(opt_ff, "--ff")) + die(_("pull.rebase and pull.ff are incompatible; please unset one")); + if (read_cache_unmerged()) die_resolve_conflict("pull"); diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 52e8ccc933a..73a0dbdf25a 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -143,6 +143,73 @@ test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' +test_does_rebase() { + git reset --hard c2 && + git "$@" . c1 && + # Check that we actually did a rebase + git rev-list --count HEAD >actual && + git rev-list --merges --count HEAD >>actual && + test_write_lines 3 0 >expect && + test_cmp expect actual && + rm actual expect +} + +test_does_merge() { + git reset --hard c2 && + git "$@" . c1 && + # Check that we actually did a merge + git rev-list --count HEAD >actual && + git rev-list --merges --count HEAD >>actual && + test_write_lines 4 1 >expect && + test_cmp expect actual && + rm actual expect +} + +test_attempts_fast_forward() { + git reset --hard c2 && + test_must_fail git "$@" . c1 2>err && + test_i18ngrep "Not possible to fast-forward, aborting" err +} + +test_expect_success 'conflicting options: --ff-only --rebase' ' + test_does_rebase pull --ff-only --rebase +' + +test_expect_success 'conflicting options: --no-ff --rebase' ' + test_does_rebase pull --no-ff --rebase +' + +test_expect_success 'conflicting options: -c pull.ff=false --rebase' ' + test_does_rebase -c pull.ff=false pull --rebase +' + +test_expect_success 'conflicting options: -c pull.ff=only --rebase' ' + test_does_rebase -c pull.ff=only pull --rebase +' + +test_expect_success 'conflicting options: --rebase --ff-only' ' + test_attempts_fast_forward pull --rebase --ff-only +' + +test_expect_success 'conflicting options: --rebase --no-ff' ' + test_does_merge pull --rebase --no-ff +' + +test_expect_success 'conflicting options: -c pull.rebase=true --no-ff' ' + test_does_merge -c pull.rebase=true pull --no-ff +' + +test_expect_success 'conflicting options: -c pull.rebase=true --ff-only' ' + test_attempts_fast_forward -c pull.rebase=true pull --ff-only +' + +test_expect_success 'report conflicting configuration' ' + git reset --hard c2 && + test_must_fail git -c pull.ff=false -c pull.rebase=true pull . c1 2>err && + test_i18ngrep "pull.rebase and pull.ff are incompatible; please unset one" err + +' + test_expect_success 'merge c1 with c2' ' git reset --hard c1 && test -f c0.c && From patchwork Thu Jul 15 02:40:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12378323 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 32CA2C47E4B for ; Thu, 15 Jul 2021 02:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B29961377 for ; Thu, 15 Jul 2021 02:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231702AbhGOCnx (ORCPT ); Wed, 14 Jul 2021 22:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231393AbhGOCns (ORCPT ); Wed, 14 Jul 2021 22:43:48 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA654C061760 for ; Wed, 14 Jul 2021 19:40:54 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id t5so5626971wrw.12 for ; Wed, 14 Jul 2021 19:40:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=9NN/a+OZh2ph5WZuVmOe5wEspO3B2Q+Szi6mpwZt1Uc=; b=p/eCc9kOolmZ9wpCBa6YnNMT0szPFIf1abB5WQAgDoqHALpXl1G/1xoJLwHXxpiZK1 8A8KDv1wZk/xVQuihQpwaJFu4NM7RyMauOckiJMffOsBeZ2hgAGSNqacvttJnoMB5iJ7 xMTmjd2Ruqxbafuf2ZWK6rUMOs+rTqAj+rLbVJEbUoOj+kqGYwjq/QgLDEuBlcVWA945 b7ez36Da1/bj9KwgRh5fibI37dX/YHDfJeHTVtqXFGu6feJhLTn+ucVT0C6UDWjUFail cGq9VMO2kCMaVb+Ck3oHwjTNemf0feLAVOQ1BW9sVuk/P2+aGv5fr2xutTgoVywMQ4xU JUpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=9NN/a+OZh2ph5WZuVmOe5wEspO3B2Q+Szi6mpwZt1Uc=; b=MojC3EW1AZoVMXBvpILRRvQ3SYQpltm/kZAerGpRXoTD14zmDynBzik+lg4xQvgBgB OcUx7MFo4h20kRHG/lTVdNk2XxRXNqHYFu4DFm4yeWX96K2bXptBfUNLcLvGhMsv/haC syeNqxDKBni6MkFJc6s1gUtjL1YWCwDdYtd4Zx5GS7u/SVXvU5KqyL2dqTS0xzMJ6tUz Y/uCxrA+KNWq9tMgLwB+K85VyzyEVzfBXbjHCGqgybJUpR/wcIvf0UcP7aAKJ+sJxtv1 YY8Tr94d6l/Dc8e3Bto3zj8k/1IWEml1WSX2ggi1kU8kjQ8b9lAgbr2utoLrPcCDlKRG TiVw== X-Gm-Message-State: AOAM533SamZSOyRdMg8qC5JyZXS93PoLn72wnoR2H/skjUHIzBprQHUG r/RD4Q77W6PZdZ6fn6RBsesB5DQcJV4= X-Google-Smtp-Source: ABdhPJzT3qzT2hiiyvgHNTqymaDNG8pTldHTfEG7Dq/TjBQwZfq2WIQO/OyD3jJCPdijOFvH+8+xtQ== X-Received: by 2002:a05:6000:1048:: with SMTP id c8mr1760021wrx.202.1626316853454; Wed, 14 Jul 2021 19:40:53 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z13sm4581770wro.79.2021.07.14.19.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 19:40:53 -0700 (PDT) Message-Id: <12ee3b140b4e1170bc725753cda56a4426823bdc.1626316849.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 15 Jul 2021 02:40:48 +0000 Subject: [PATCH 4/5] pull: abort if --ff-only is given and fast-forwarding is impossible Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alex Henrie , Phillip Wood , Son Luong Ngoc , Elijah Newren , Alex Henrie Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Alex Henrie From: Alex Henrie The warning about pulling without specifying how to reconcile divergent branches says that after setting pull.rebase to true, --ff-only can still be passed on the command line to require a fast-forward. Make that actually work. Signed-off-by: Alex Henrie --- advice.c | 5 +++++ advice.h | 1 + builtin/merge.c | 2 +- builtin/pull.c | 11 ++++++++--- t/t7601-merge-pull-config.sh | 24 ++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/advice.c b/advice.c index 0b9c89c48ab..337e8f342bc 100644 --- a/advice.c +++ b/advice.c @@ -286,6 +286,11 @@ void NORETURN die_conclude_merge(void) die(_("Exiting because of unfinished merge.")); } +void NORETURN die_ff_impossible(void) +{ + die(_("Not possible to fast-forward, aborting.")); +} + void advise_on_updating_sparse_paths(struct string_list *pathspec_list) { struct string_list_item *item; diff --git a/advice.h b/advice.h index bd26c385d00..16240438387 100644 --- a/advice.h +++ b/advice.h @@ -95,6 +95,7 @@ void advise_if_enabled(enum advice_type type, const char *advice, ...); int error_resolve_conflict(const char *me); void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void); +void NORETURN die_ff_impossible(void); void advise_on_updating_sparse_paths(struct string_list *pathspec_list); void detach_advice(const char *new_name); diff --git a/builtin/merge.c b/builtin/merge.c index a8a843b1f54..aa920ac524f 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1620,7 +1620,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) } if (fast_forward == FF_ONLY) - die(_("Not possible to fast-forward, aborting.")); + die_ff_impossible(); if (autostash) create_autostash(the_repository, diff --git a/builtin/pull.c b/builtin/pull.c index b355fd38794..2c90bbb1588 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1070,9 +1070,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (rebase_unspecified && !opt_ff && !can_ff) { - if (opt_verbosity >= 0) - show_advice_pull_non_ff(); + if (!can_ff) { + if (opt_ff) { + if (!strcmp(opt_ff, "--ff-only")) + die_ff_impossible(); + } else { + if (rebase_unspecified && opt_verbosity >= 0) + show_advice_pull_non_ff(); + } } if (opt_rebase) { diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 73a0dbdf25a..6b9e80db97b 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -250,6 +250,30 @@ test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' ' test_must_fail git pull . c3 ' +test_expect_success 'pull prevents non-fast-forward with pull.ff=only and pull.rebase=true' ' + git reset --hard c1 && + test_config pull.ff only && + test_config pull.rebase true && + test_must_fail git pull . c3 +' + +test_expect_success 'pull prevents non-fast-forward with pull.ff=only and pull.rebase=false' ' + git reset --hard c1 && + test_config pull.ff only && + test_config pull.rebase false && + test_must_fail git pull . c3 +' + +test_expect_success 'pull prevents non-fast-forward with --rebase --ff-only' ' + git reset --hard c1 && + test_must_fail git pull --rebase --ff-only . c3 +' + +test_expect_success 'pull prevents non-fast-forward with --no-rebase --ff-only' ' + git reset --hard c1 && + test_must_fail git pull --no-rebase --ff-only . c3 +' + test_expect_success 'merge c1 with c2 (ours in pull.twohead)' ' git reset --hard c1 && git config pull.twohead ours && From patchwork Thu Jul 15 02:40:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elijah Newren X-Patchwork-Id: 12378325 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 2314EC12002 for ; Thu, 15 Jul 2021 02:41:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F03E61377 for ; Thu, 15 Jul 2021 02:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbhGOCny (ORCPT ); Wed, 14 Jul 2021 22:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231549AbhGOCnt (ORCPT ); Wed, 14 Jul 2021 22:43:49 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 081C9C06175F for ; Wed, 14 Jul 2021 19:40:56 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id u5-20020a7bc0450000b02901480e40338bso4377626wmc.1 for ; Wed, 14 Jul 2021 19:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=u4w4lM9mW6Glpd0K1hgqO40zuUz+Y5Fvm5kuzrNVeog=; b=f/Qopt8rp2ocWWrn6sC+PIrbiSlMPB5ibjj1mthpu0KZqHQuKebpjcS4/NdDYO07Q/ 9hJVlFOZLJUTWA3TIP7A/UFJkalUA0EjDP+HWnYBFkEA4TrOOHF603gY29ql1liuGLgK SN4f/58Pyecd3fyLGigXTuGmDhmh+x+pdcr+8dG6V/mDUzUb2fqEbP+Hxl8YGRiHULXj GgeZ+rSt251UOyhB/qrS8SdgIp4EPT1Tkp0PLhSqUQwZHRCwjR0+ZzqTGnTFBb6FJjIe au6tubSXQ026PfIMhhj7lTXARAsiB1PrH/u8j9nMd4ZXfi9X/aY87o6rXSqCxrKMPlGI GHkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=u4w4lM9mW6Glpd0K1hgqO40zuUz+Y5Fvm5kuzrNVeog=; b=LIKx2bhWuMRvUUbh7hXkzKPtLq8+NBOTWnO7V+Z/xC0b2Zu8t/oBahThO3ArtULnjg S+BJaIg+EGPXo1FjXgVel0V2JLNyq+HZKHBHYLZJVQ1o5MaEclmmSwikF/D528h3CVSR il0uV1cDIr77b6RAWvGxTR/haAe2wM/5VXXX9B7Uoyk0xCx6Skv0WdLDzrEcLL9gUAKD 6u3NSSAtgx2PHZVe8LmtBnYNqNSSFerbXJ3c3wmg6oW+uJUSaJJFmSVlWJnzTLInluhS 2Cla9PUSe3elZGeE3qtI+4c5jZp6d6Bl55o4e/a6/nUcXm1j6Y4DmEIcG+a5EauZH+1p KUhg== X-Gm-Message-State: AOAM530UarSLY07WzjU1u7zV4kV6jNB4PCV3mB+gS47aFe4nhfSjzw0L kfDoHPwcO8YahE/moTZvArs+ndEGD3c= X-Google-Smtp-Source: ABdhPJynvgz6zdtkWDiYYHfC4uwnpJ14WtXsM1q3isqR929JTGt9/W2GqixkynO7Srs3alJrEhSIxw== X-Received: by 2002:a7b:c844:: with SMTP id c4mr7501047wml.107.1626316854252; Wed, 14 Jul 2021 19:40:54 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p9sm4428046wrx.59.2021.07.14.19.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 19:40:53 -0700 (PDT) Message-Id: <7e12c45fc9a94e7b56a6efdc085ebe081dd40afc.1626316849.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 15 Jul 2021 02:40:49 +0000 Subject: [PATCH 5/5] pull: abort by default when fast-forwarding is not possible Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Alex Henrie , Phillip Wood , Son Luong Ngoc , Elijah Newren , Elijah Newren Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Elijah Newren From: Elijah Newren We have for some time shown a long warning when the user does not specify how to reconcile divergent branches with git pull. Make it an error now. Initial-patch-by: Alex Henrie Signed-off-by: Elijah Newren --- Documentation/git-pull.txt | 18 ++++++++++-------- builtin/pull.c | 31 +++++++++++++++---------------- t/t4013-diff-various.sh | 2 +- t/t5520-pull.sh | 20 ++++++++++---------- t/t5521-pull-options.sh | 4 ++-- t/t5524-pull-msg.sh | 4 ++-- t/t5553-set-upstream.sh | 14 +++++++------- t/t5604-clone-reference.sh | 4 ++-- t/t6402-merge-rename.sh | 18 +++++++++--------- t/t6409-merge-subtree.sh | 6 +++--- t/t6417-merge-ours-theirs.sh | 10 +++++----- t/t7601-merge-pull-config.sh | 6 ++---- t/t7603-merge-reduce-heads.sh | 2 +- 13 files changed, 69 insertions(+), 70 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 03e8694e146..cb65d33e15e 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -15,14 +15,16 @@ SYNOPSIS DESCRIPTION ----------- -Incorporates changes from a remote repository into the current -branch. In its default mode, `git pull` is shorthand for -`git fetch` followed by `git merge FETCH_HEAD`. - -More precisely, 'git pull' runs 'git fetch' with the given -parameters and calls 'git merge' to merge the retrieved branch -heads into the current branch. -With `--rebase`, it runs 'git rebase' instead of 'git merge'. +Incorporates changes from a remote repository into the current branch. +If the current branch is behind the remote, then by default it will +fast-forward the current branch to match the remote. If the current +branch and the remote have diverged, the user needs to specify how to +reconcile the divergent branches with --no-ff or --rebase (or the +corresponding configuration options in pull.ff or pull.rebase). + +More precisely, 'git pull' runs 'git fetch' with the given parameters +and then depending on config options or command line flags, will call +either 'git merge' or 'git rebase' to reconcile diverging branches. should be the name of a remote repository as passed to linkgit:git-fetch[1]. can name an diff --git a/builtin/pull.c b/builtin/pull.c index 2c90bbb1588..0f8fdb7d42b 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -946,20 +946,20 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_ return ret; } -static void show_advice_pull_non_ff(void) +static void NORETURN die_pull_non_ff(void) { - advise(_("Pulling without specifying how to reconcile divergent branches is\n" - "discouraged. You can squelch this message by running one of the following\n" - "commands sometime before your next pull:\n" - "\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")); + die(_("You have divergent branches and need to specify how to reconcile them.\n" + "You can do so by running one of the following commands sometime before\n" + "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")); } int cmd_pull(int argc, const char **argv, const char *prefix) @@ -1074,9 +1074,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_ff) { if (!strcmp(opt_ff, "--ff-only")) die_ff_impossible(); - } else { - if (rebase_unspecified && opt_verbosity >= 0) - show_advice_pull_non_ff(); + } else if (rebase_unspecified) { + die_pull_non_ff(); } } diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 7fadc985ccc..eb989f7f191 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -65,7 +65,7 @@ test_expect_success setup ' export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && git checkout master && - git pull -s ours . side && + git pull -s ours --no-rebase . side && GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" && GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" && diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index e2c0c510222..672001a18bd 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -136,12 +136,12 @@ test_expect_success 'the default remote . should not break explicit pull' ' git reset --hard HEAD^ && echo file >expect && test_cmp expect file && - git pull . second && + git pull --no-rebase . second && echo modified >expect && test_cmp expect file && git reflog -1 >reflog.actual && sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy && - echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected && + echo "OBJID HEAD@{0}: pull --no-rebase . second: Fast-forward" >reflog.expected && test_cmp reflog.expected reflog.fuzzy ' @@ -226,7 +226,7 @@ test_expect_success 'fail if the index has unresolved entries' ' test_commit modified2 file && git ls-files -u >unmerged && test_must_be_empty unmerged && - test_must_fail git pull . second && + test_must_fail git pull --no-rebase . second && git ls-files -u >unmerged && test_file_not_empty unmerged && cp file expected && @@ -409,37 +409,37 @@ test_expect_success 'pull --rebase --no-autostash & rebase.autostash unset' ' test_expect_success 'pull succeeds with dirty working directory and merge.autostash set' ' test_config merge.autostash true && - test_pull_autostash 2 + test_pull_autostash 2 --no-rebase ' test_expect_success 'pull --autostash & merge.autostash=true' ' test_config merge.autostash true && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --autostash --no-rebase ' test_expect_success 'pull --autostash & merge.autostash=false' ' test_config merge.autostash false && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --autostash --no-rebase ' test_expect_success 'pull --autostash & merge.autostash unset' ' test_unconfig merge.autostash && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --autostash --no-rebase ' test_expect_success 'pull --no-autostash & merge.autostash=true' ' test_config merge.autostash true && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --no-autostash --no-rebase ' test_expect_success 'pull --no-autostash & merge.autostash=false' ' test_config merge.autostash false && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --no-autostash --no-rebase ' test_expect_success 'pull --no-autostash & merge.autostash unset' ' test_unconfig merge.autostash && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --no-autostash --no-rebase ' test_expect_success 'pull.rebase' ' diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh index 63a688bdbf5..7601c919fdc 100755 --- a/t/t5521-pull-options.sh +++ b/t/t5521-pull-options.sh @@ -113,7 +113,7 @@ test_expect_success 'git pull --force' ' git pull two && test_commit A && git branch -f origin && - git pull --all --force + git pull --no-rebase --all --force ) ' @@ -179,7 +179,7 @@ test_expect_success 'git pull --allow-unrelated-histories' ' ( cd dst && test_must_fail git pull ../src side && - git pull --allow-unrelated-histories ../src side + git pull --no-rebase --allow-unrelated-histories ../src side ) ' diff --git a/t/t5524-pull-msg.sh b/t/t5524-pull-msg.sh index c278adaa5a2..b2be3605f5a 100755 --- a/t/t5524-pull-msg.sh +++ b/t/t5524-pull-msg.sh @@ -28,7 +28,7 @@ test_expect_success setup ' test_expect_success pull ' ( cd cloned && - git pull --log && + git pull --no-rebase --log && git log -2 && git cat-file commit HEAD >result && grep Dollar result @@ -41,7 +41,7 @@ test_expect_success '--log=1 limits shortlog length' ' git reset --hard HEAD^ && test "$(cat afile)" = original && test "$(cat bfile)" = added && - git pull --log=1 && + git pull --no-rebase --log=1 && git log -3 && git cat-file commit HEAD >result && grep Dollar result && diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh index b1d614ce18c..9c12c0f8c32 100755 --- a/t/t5553-set-upstream.sh +++ b/t/t5553-set-upstream.sh @@ -108,27 +108,27 @@ test_expect_success 'setup commit on main and other pull' ' test_expect_success 'pull --set-upstream upstream main sets branch main but not other' ' clear_config main other && - git pull --set-upstream upstream main && + git pull --no-rebase --set-upstream upstream main && check_config main upstream refs/heads/main && check_config_missing other ' test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' ' clear_config other2 && - git pull --set-upstream upstream main:other2 && + git pull --no-rebase --set-upstream upstream main:other2 && check_config_missing other2 ' test_expect_success 'pull --set-upstream upstream other sets branch main' ' clear_config main other && - git pull --set-upstream upstream other && + git pull --no-rebase --set-upstream upstream other && check_config main upstream refs/heads/other && check_config_missing other ' test_expect_success 'pull --set-upstream upstream tag does not set the tag' ' clear_config three && - git pull --tags --set-upstream upstream three && + git pull --no-rebase --tags --set-upstream upstream three && check_config_missing three ' @@ -144,16 +144,16 @@ test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails w test_expect_success 'pull --set-upstream upstream HEAD sets branch HEAD' ' clear_config main other && - git pull --set-upstream upstream HEAD && + git pull --no-rebase --set-upstream upstream HEAD && check_config main upstream HEAD && git checkout other && - git pull --set-upstream upstream HEAD && + git pull --no-rebase --set-upstream upstream HEAD && check_config other upstream HEAD ' test_expect_success 'pull --set-upstream upstream with more than one branch does nothing' ' clear_config main three && - git pull --set-upstream upstream main three && + git pull --no-rebase --set-upstream upstream main three && check_config_missing main && check_config_missing three ' diff --git a/t/t5604-clone-reference.sh b/t/t5604-clone-reference.sh index e845d621f61..24340e6d56e 100755 --- a/t/t5604-clone-reference.sh +++ b/t/t5604-clone-reference.sh @@ -87,7 +87,7 @@ test_expect_success 'updating origin' ' ' test_expect_success 'pulling changes from origin' ' - git -C C pull origin + git -C C pull --no-rebase origin ' # the 2 local objects are commit and tree from the merge @@ -96,7 +96,7 @@ test_expect_success 'that alternate to origin gets used' ' ' test_expect_success 'pulling changes from origin' ' - git -C D pull origin + git -C D pull --no-rebase origin ' # the 5 local objects are expected; file3 blob, commit in A to add it diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh index 425dad97d54..02a842697b8 100755 --- a/t/t6402-merge-rename.sh +++ b/t/t6402-merge-rename.sh @@ -103,7 +103,7 @@ test_expect_success 'setup' ' test_expect_success 'pull renaming branch into unrenaming one' \ ' git show-branch && - test_expect_code 1 git pull . white && + test_expect_code 1 git pull --no-rebase . white && git ls-files -s && git ls-files -u B >b.stages && test_line_count = 3 b.stages && @@ -121,7 +121,7 @@ test_expect_success 'pull renaming branch into another renaming one' \ rm -f B && git reset --hard && git checkout red && - test_expect_code 1 git pull . white && + test_expect_code 1 git pull --no-rebase . white && git ls-files -u B >b.stages && test_line_count = 3 b.stages && git ls-files -s N >n.stages && @@ -137,7 +137,7 @@ test_expect_success 'pull unrenaming branch into renaming one' \ ' git reset --hard && git show-branch && - test_expect_code 1 git pull . main && + test_expect_code 1 git pull --no-rebase . main && git ls-files -u B >b.stages && test_line_count = 3 b.stages && git ls-files -s N >n.stages && @@ -153,7 +153,7 @@ test_expect_success 'pull conflicting renames' \ ' git reset --hard && git show-branch && - test_expect_code 1 git pull . blue && + test_expect_code 1 git pull --no-rebase . blue && git ls-files -u A >a.stages && test_line_count = 1 a.stages && git ls-files -u B >b.stages && @@ -173,7 +173,7 @@ test_expect_success 'interference with untracked working tree file' ' git reset --hard && git show-branch && echo >A this file should not matter && - test_expect_code 1 git pull . white && + test_expect_code 1 git pull --no-rebase . white && test_path_is_file A ' @@ -183,7 +183,7 @@ test_expect_success 'interference with untracked working tree file' ' git show-branch && rm -f A && echo >A this file should not matter && - test_expect_code 1 git pull . red && + test_expect_code 1 git pull --no-rebase . red && test_path_is_file A ' @@ -193,7 +193,7 @@ test_expect_success 'interference with untracked working tree file' ' git checkout -f main && git tag -f anchor && git show-branch && - git pull . yellow && + git pull --no-rebase . yellow && test_path_is_missing M && git reset --hard anchor ' @@ -220,7 +220,7 @@ test_expect_success 'updated working tree file should prevent the merge' ' echo >>M one line addition && cat M >M.saved && git update-index M && - test_expect_code 128 git pull . yellow && + test_expect_code 128 git pull --no-rebase . yellow && test_cmp M M.saved && rm -f M.saved ' @@ -232,7 +232,7 @@ test_expect_success 'interference with untracked working tree file' ' git tag -f anchor && git show-branch && echo >M this file should not matter && - git pull . main && + git pull --no-rebase . main && test_path_is_file M && ! { git ls-files -s | diff --git a/t/t6409-merge-subtree.sh b/t/t6409-merge-subtree.sh index d406b2343cb..ba7890ec521 100755 --- a/t/t6409-merge-subtree.sh +++ b/t/t6409-merge-subtree.sh @@ -100,7 +100,7 @@ test_expect_success 'merge update' ' git checkout -b topic_2 && git commit -m "update git-gui" && cd ../git && - git pull -s subtree gui topic_2 && + git pull --no-rebase -s subtree gui topic_2 && git ls-files -s >actual && ( echo "100644 $o3 0 git-gui/git-gui.sh" && @@ -129,7 +129,7 @@ test_expect_success 'initial ambiguous subtree' ' test_expect_success 'merge using explicit' ' cd ../git && git reset --hard topic_2 && - git pull -Xsubtree=git-gui gui topic_2 && + git pull --no-rebase -Xsubtree=git-gui gui topic_2 && git ls-files -s >actual && ( echo "100644 $o3 0 git-gui/git-gui.sh" && @@ -142,7 +142,7 @@ test_expect_success 'merge using explicit' ' test_expect_success 'merge2 using explicit' ' cd ../git && git reset --hard topic_2 && - git pull -Xsubtree=git-gui2 gui topic_2 && + git pull --no-rebase -Xsubtree=git-gui2 gui topic_2 && git ls-files -s >actual && ( echo "100644 $o1 0 git-gui/git-gui.sh" && diff --git a/t/t6417-merge-ours-theirs.sh b/t/t6417-merge-ours-theirs.sh index ac9aee9a662..ec065d6a658 100755 --- a/t/t6417-merge-ours-theirs.sh +++ b/t/t6417-merge-ours-theirs.sh @@ -69,11 +69,11 @@ test_expect_success 'binary file with -Xours/-Xtheirs' ' ' test_expect_success 'pull passes -X to underlying merge' ' - git reset --hard main && git pull -s recursive -Xours . side && - git reset --hard main && git pull -s recursive -X ours . side && - git reset --hard main && git pull -s recursive -Xtheirs . side && - git reset --hard main && git pull -s recursive -X theirs . side && - git reset --hard main && test_must_fail git pull -s recursive -X bork . side + git reset --hard main && git pull --no-rebase -s recursive -Xours . side && + git reset --hard main && git pull --no-rebase -s recursive -X ours . side && + git reset --hard main && git pull --no-rebase -s recursive -Xtheirs . side && + git reset --hard main && git pull --no-rebase -s recursive -X theirs . side && + git reset --hard main && test_must_fail git pull --no-rebase -s recursive -X bork . side ' test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' ' diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6b9e80db97b..84404f4f0c3 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -86,10 +86,8 @@ test_expect_success 'pull.rebase not set and --ff-only given' ' test_expect_success 'pull.rebase not set (not-fast-forward)' ' git reset --hard c2 && - git -c color.advice=always pull . c1 2>err && - test_decode_color decoded && - test_i18ngrep "hint: " decoded && - test_i18ngrep "Pulling without specifying how to reconcile" decoded + test_must_fail git pull . c1 2>err && + test_i18ngrep "You have divergent branches" err ' test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' diff --git a/t/t7603-merge-reduce-heads.sh b/t/t7603-merge-reduce-heads.sh index 98948955ae5..27cd94ad6f7 100755 --- a/t/t7603-merge-reduce-heads.sh +++ b/t/t7603-merge-reduce-heads.sh @@ -68,7 +68,7 @@ test_expect_success 'merge c1 with c2, c3, c4, c5' ' test_expect_success 'pull c2, c3, c4, c5 into c1' ' git reset --hard c1 && - git pull . c2 c3 c4 c5 && + git pull --no-rebase . c2 c3 c4 c5 && test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" && test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" && test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&