From patchwork Mon Jul 5 12:31:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C539C07E9B for ; Mon, 5 Jul 2021 12:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16873613AE for ; Mon, 5 Jul 2021 12:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbhGEMew (ORCPT ); Mon, 5 Jul 2021 08:34:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbhGEMeu (ORCPT ); Mon, 5 Jul 2021 08:34:50 -0400 Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7BDAC061574 for ; Mon, 5 Jul 2021 05:32:13 -0700 (PDT) Received: by mail-oo1-xc33.google.com with SMTP id 128-20020a4a11860000b029024b19a4d98eso4424386ooc.5 for ; Mon, 05 Jul 2021 05:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/cJPEeERMgmIEQBlUZqAse60BHilUUWsxDNjbCAk9sg=; b=hyzQOONzxMDx4+wrGajms/pF3CISDFLIFO8hwShMS98VG2bcHKo7QnaM4cERxPO3uY 2btrxCr10or8QX7DMGqYOTqGW6ZgPMkLuUDGG4vP4AeRzbmuiljir9zOGmcww2udhGHW BRlEtTBwFroCVkV4/DiZAoWCsv0YqG/X7fQ3qmEvc9WICBDQybtk24XNU5OJRa3mgMxW 13EXGVwIK/iNb7Qaja7N4VCplr9vonqkJbj12d1N4f121rx8VFgKGxDmQYXT/cwH6KRB g97Gp3ad++0a4OqIQgMe+VYFqb+4CyuNqWyV6B7Ojqbn0rzXXPAKbYd0dHi+08FJTK5Q tLLQ== 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=/cJPEeERMgmIEQBlUZqAse60BHilUUWsxDNjbCAk9sg=; b=H2Xf5HC9WJGiluLhBQRWWJdIBJgMBBDJX5+5JE9IOFWfUlc99iwzpX73CvmhxJEyiW tPkO1AuJMg1BWE6GOW9a4NJhoPXnWBKw/gVXKAN5HvBNbzgkgzCMqkGYI2kjyJrfrlPW AQrZLVY49aHazOaIcIDHiVg6/jxIkKqfQAfwptEVMEJnHTQk4RUAhnNmfHtpoQ+zbF68 j/JBTpFQbvUwuBNv38tsJZ9zKB0HyC5XzpvvwoAV6Kr8Hd36RdRZAV9uVe5qIjRTGE5r 56FNM443H9K/ZyigJGDPubN0LaGzJ4Z8pnOJTTnEniKF9UjumH+mrpXc6ecriGLQ7Lo8 z8Yg== X-Gm-Message-State: AOAM531ZP38aRKYRmIvT/Jww98gAZvkKTAbneEQK8pQa+CISJYfOf34C HMPLpkg/Vf+8KTGRew3kFRKuvk6If+WLVQ== X-Google-Smtp-Source: ABdhPJynnudK+/pHb8BA8ln13O+/DSVm9JfjFQAX9QFk34R2Rg4/BiPIy94Zm9zhDoPXpE3/zjmLww== X-Received: by 2002:a4a:98ce:: with SMTP id b14mr9859228ooj.69.1625488333001; Mon, 05 Jul 2021 05:32:13 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id d7sm2529381otb.66.2021.07.05.05.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:12 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 01/35] merge: improve fatal fast-forward message Date: Mon, 5 Jul 2021 07:31:35 -0500 Message-Id: <20210705123209.1808663-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/merge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/merge.c b/builtin/merge.c index a8a843b1f5..05e631229d 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(_("unable to fast-forward")); if (autostash) create_autostash(the_repository, From patchwork Mon Jul 5 12:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59E4DC07E9C for ; Mon, 5 Jul 2021 12:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D45C613B6 for ; Mon, 5 Jul 2021 12:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbhGEMex (ORCPT ); Mon, 5 Jul 2021 08:34:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbhGEMew (ORCPT ); Mon, 5 Jul 2021 08:34:52 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B709C061574 for ; Mon, 5 Jul 2021 05:32:15 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id t24-20020a9d7f980000b029046f4a1a5ec4so18195808otp.1 for ; Mon, 05 Jul 2021 05:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ijwD+gT8iEgp1bswAK/Dmr6YWV3KhscvxuZVFSHlW9g=; b=XhAQmUY6kcCWGDrh6UWhHUrKhEIlXoY2+yTcmID9y0ZU6t4szfDIlkVgDK1pj6IaJT 3uxHnBhXzPKfLHoeVNst12YengQWPM7J6FJDiF3VgaQNSf5ajpcsaHIRysin212yHWO+ UwSWu/BD7bLBIReMpFq3rY9iPtZUiCZ1ytVFpnxDu2JIO1N9U0Ip4gsxL+s6sxOTrHzh tpqFZzELcKrjOWky+Bo/QrTP+ruJJLE0D7Gm7tzIg4Hk3Jd9u79VNSDRlqb222/cRd37 7VcuYfosFIcUB9UuMibmoQWwgJOfAYL4G5Bs4+OZc/rqI5x7FJSuv1bWiv2MfHo25ZxO rz2Q== 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=ijwD+gT8iEgp1bswAK/Dmr6YWV3KhscvxuZVFSHlW9g=; b=MAtyR742SoZCjhERTcunDtJ+wGhPfdRArsE923dobr47xPBudX+Hy7crdn4T1FYqfX 5OlJqqwzaA8c0DRQndPW7J1HoM+5okI/Kq8fzDFkpF+gY2ooJIb4C/+L3DTN9MgjPahN U9dgKGfK/+D0HkzYvwST5QLqfC1jOAXLFBmhuM+xTxoLqKKmchWU/nc7J6o0S+1+XuEq MKZB2wNn6lfbYszVUu5IjtCc8zLxqzS3tnp/6e6gZCT7inpZLD+0t4evETNAjR2PvmSx fJB8b4nls+Hlgm0wv8UpyWPBkwxpNbCVYm3WXkRScBH/BODh6gX8sf3cSghKceZ9v6/w P8hQ== X-Gm-Message-State: AOAM531SMdGhGLIuVR/rK1UaBpIYjNThioj9Qu84MSQ5dEpX7UiHNbXF dWEh73WdZho9QsQ0U8pIHN+MbwPdpjF5pA== X-Google-Smtp-Source: ABdhPJyAwWlLHKg+3Idw95/tWy3ZQ663uWdCg9GEvy5oVMRNebV/cApf78OwnQv+o8YRJISR/0stUQ== X-Received: by 2002:a9d:4783:: with SMTP id b3mr10741955otf.78.1625488334781; Mon, 05 Jul 2021 05:32:14 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 5sm2225715oot.29.2021.07.05.05.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:14 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 02/35] merge: split cmd_merge() Date: Mon, 5 Jul 2021 07:31:36 -0500 Message-Id: <20210705123209.1808663-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We want to re-use most of cmd_merge() for a new command. Signed-off-by: Felipe Contreras --- builtin/merge.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 05e631229d..9c944f5f0f 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1259,7 +1259,8 @@ static int merging_a_throwaway_tag(struct commit *commit) return is_throwaway_tag; } -int cmd_merge(int argc, const char **argv, const char *prefix) +static int merge_common(int argc, const char **argv, const char *prefix, + const struct option *options, const char * const usage[]) { struct object_id result_tree, stash, head_oid; struct commit *head_commit; @@ -1273,7 +1274,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) int orig_argc = argc; if (argc == 2 && !strcmp(argv[1], "-h")) - usage_with_options(builtin_merge_usage, builtin_merge_options); + usage_with_options(usage, options); /* * Check if we are _not_ on a detached HEAD, i.e. if there is a @@ -1299,8 +1300,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (branch_mergeoptions) parse_branch_merge_options(branch_mergeoptions); - argc = parse_options(argc, argv, prefix, builtin_merge_options, - builtin_merge_usage, 0); + argc = parse_options(argc, argv, prefix, options, usage, 0); if (shortlog_len < 0) shortlog_len = (merge_log_config > 0) ? merge_log_config : 0; @@ -1314,7 +1314,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (orig_argc != 2) usage_msg_opt(_("--abort expects no arguments"), - builtin_merge_usage, builtin_merge_options); + usage, options); if (!file_exists(git_path_merge_head(the_repository))) die(_("There is no merge to abort (MERGE_HEAD missing).")); @@ -1336,8 +1336,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (quit_current_merge) { if (orig_argc != 2) usage_msg_opt(_("--quit expects no arguments"), - builtin_merge_usage, - builtin_merge_options); + usage, options); remove_merge_branch_state(the_repository); goto done; @@ -1349,7 +1348,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) if (orig_argc != 2) usage_msg_opt(_("--continue expects no arguments"), - builtin_merge_usage, builtin_merge_options); + usage, options); if (!file_exists(git_path_merge_head(the_repository))) die(_("There is no merge in progress (MERGE_HEAD missing).")); @@ -1416,8 +1415,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) } if (!argc) - usage_with_options(builtin_merge_usage, - builtin_merge_options); + usage_with_options(usage, options); if (!head_commit) { /* @@ -1458,8 +1456,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix) argc, argv, &merge_msg); if (!head_commit || !argc) - usage_with_options(builtin_merge_usage, - builtin_merge_options); + usage_with_options(usage, options); if (verify_signatures) { for (p = remoteheads; p; p = p->next) { @@ -1738,3 +1735,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix) free(branch_to_free); return ret; } + +int cmd_merge(int argc, const char **argv, const char *prefix) +{ + return merge_common(argc, argv, prefix, builtin_merge_options, builtin_merge_usage); +} From patchwork Mon Jul 5 12:31:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0F86C07E9B for ; Mon, 5 Jul 2021 12:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A683613F7 for ; Mon, 5 Jul 2021 12:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbhGEMey (ORCPT ); Mon, 5 Jul 2021 08:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbhGEMey (ORCPT ); Mon, 5 Jul 2021 08:34:54 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52739C061574 for ; Mon, 5 Jul 2021 05:32:17 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id 10so5848211oiq.9 for ; Mon, 05 Jul 2021 05:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ShncCEzb904+ld7csdG90aCPqjvRvNsnnj5DwuWPp2E=; b=YZAltohmcXKIuVS5BGECvfvk5rlseh6f0yRHll8TNGjhfoDPsEG/MIvW1j0v1zFppW HygnIlVfW+4GLdcOFvaXRfj7kWdlgFJjTLmvDOsMomxCpUkyOBbXeqRytBiDe7E/P5oB LRcyj77oJWqshd7NiBAQoxLDRGfhTySvVt7dZbpKB9avO4efqf6BcYSuxNN7mAztT45W Av7Y/0W4qKf9Q55uh6B0N/qIG2P7ZQxhoyU/gKFd34+D0phpL+5o9RZ1+2Uu4ZaDj9SY TTxjTqFKgs7OhJw55tYxo0MZG2bQJAkhbWkEyceaAIHJPqOc4Jj2fbQzISQ8q689Gzb0 0ngQ== 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=ShncCEzb904+ld7csdG90aCPqjvRvNsnnj5DwuWPp2E=; b=h7ljHzVxBwA58jvd4Yj4Sce7e8gAy5vTzd18APf8YaMB7ZKWGTx838eSSWc71HgqJ8 1a4uyRmxXuJmHEmetnGF0SJJ7M2zIECV603f3fQwh4d9JZ0deHO0xcecGoPWoy/9KMUo s854DPxIlsnTPpV8vdMdJxI7ePNVUCIqyVyR/ioteUnJTj64Gw3B8/hpg/wkePTNLEbV qsdwitReV3wG83fKZuHtYfDb6wtYpQ/M4aAGgw5cK+SmYIEF1b+HcNhXolyrDS12A2+3 L5GzPv2HnGi2TvqHMQjyCvwGhsAaEqLWanhbhEVP20aUBmpQEqw0Nw05Wxdv8tq624Ye GSug== X-Gm-Message-State: AOAM532HTo9lO9KZDD5j+FJx12+3VzY3yPUR0ccQxcjy6vshJ76C+jrp gYefn3kB8XId59l3eonN9sDZPCa/9/62ew== X-Google-Smtp-Source: ABdhPJzaCpXM/u7WqH0duJ8bgYrIte35u+1TJ/2i0LKiyMH/Dq1K74XeacvaXV0FRf2sZXuCznrFGA== X-Received: by 2002:a05:6808:1309:: with SMTP id y9mr9677800oiv.112.1625488336461; Mon, 05 Jul 2021 05:32:16 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id p26sm811596otp.59.2021.07.05.05.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:16 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 03/35] fast-forward: add new builtin Date: Mon, 5 Jul 2021 07:31:37 -0500 Message-Id: <20210705123209.1808663-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This is one of the most common git operations, it makes sense it has its own built-in. This is basically the same as `git merge --ff-only` (for now). Signed-off-by: Felipe Contreras --- .gitignore | 1 + Documentation/git-fast-forward.txt | 26 ++++++++++++++++++++++++++ Makefile | 1 + builtin.h | 1 + builtin/merge.c | 15 +++++++++++++++ contrib/completion/git-completion.bash | 10 ++++++++++ git.c | 1 + t/t7600-merge.sh | 21 +++++++++++++++++++++ 8 files changed, 76 insertions(+) create mode 100644 Documentation/git-fast-forward.txt diff --git a/.gitignore b/.gitignore index 311841f9be..45703399b0 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ /git-describe /git-env--helper /git-fast-export +/git-fast-forward /git-fast-import /git-fetch /git-fetch-pack diff --git a/Documentation/git-fast-forward.txt b/Documentation/git-fast-forward.txt new file mode 100644 index 0000000000..d457022629 --- /dev/null +++ b/Documentation/git-fast-forward.txt @@ -0,0 +1,26 @@ +git-fast-forward(1) +=================== + +NAME +---- +git-fast-forward - Advance the branch pointer + +SYNOPSIS +-------- +[verse] +'git fast-forward' [] + +DESCRIPTION +----------- +Incorporates changes into the current branch. By default the upstream branch is +used, but a different commit can be specified in the arguments. + +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. + +SEE ALSO +-------- +linkgit:git-merge[1] + +GIT +--- +Part of the linkgit:git[1] suite diff --git a/Makefile b/Makefile index c3565fc0f8..cf42162a07 100644 --- a/Makefile +++ b/Makefile @@ -772,6 +772,7 @@ BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS)) BUILT_INS += git-cherry$X BUILT_INS += git-cherry-pick$X +BUILT_INS += git-fast-forward$X BUILT_INS += git-format-patch$X BUILT_INS += git-fsck-objects$X BUILT_INS += git-init$X diff --git a/builtin.h b/builtin.h index 16ecd5586f..601e438c9b 100644 --- a/builtin.h +++ b/builtin.h @@ -151,6 +151,7 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix); int cmd_difftool(int argc, const char **argv, const char *prefix); int cmd_env__helper(int argc, const char **argv, const char *prefix); int cmd_fast_export(int argc, const char **argv, const char *prefix); +int cmd_fast_forward(int argc, const char **argv, const char *prefix); int cmd_fast_import(int argc, const char **argv, const char *prefix); int cmd_fetch(int argc, const char **argv, const char *prefix); int cmd_fetch_pack(int argc, const char **argv, const char *prefix); diff --git a/builtin/merge.c b/builtin/merge.c index 9c944f5f0f..e396943d37 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -61,6 +61,11 @@ static const char * const builtin_merge_usage[] = { NULL }; +static const char * const builtin_ff_usage[] = { + N_("git fast-forward []"), + NULL +}; + static int show_diffstat = 1, shortlog_len = -1, squash; static int option_commit = -1; static int option_edit = -1; @@ -304,6 +309,10 @@ static struct option builtin_merge_options[] = { OPT_END() }; +static struct option builtin_ff_options[] = { + OPT_END() +}; + static int save_state(struct object_id *stash) { int len; @@ -1740,3 +1749,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix) { return merge_common(argc, argv, prefix, builtin_merge_options, builtin_merge_usage); } + +int cmd_fast_forward(int argc, const char **argv, const char *prefix) +{ + fast_forward = FF_ONLY; + return merge_common(argc, argv, prefix, builtin_ff_options, builtin_ff_usage); +} diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b50c5d0ea3..cfaee3aaeb 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1786,6 +1786,16 @@ _git_difftool () __git_complete_revlist_file } +_git_fast_forward () +{ + case "$cur" in + --*) + __gitcomp_builtin fast-forward + return + esac + __git_complete_refs +} + __git_fetch_recurse_submodules="yes on-demand no" _git_fetch () diff --git a/git.c b/git.c index 18bed9a996..6ab1fb9251 100644 --- a/git.c +++ b/git.c @@ -524,6 +524,7 @@ static struct cmd_struct commands[] = { { "difftool", cmd_difftool, RUN_SETUP_GENTLY }, { "env--helper", cmd_env__helper }, { "fast-export", cmd_fast_export, RUN_SETUP }, + { "fast-forward", cmd_fast_forward, RUN_SETUP | NEED_WORK_TREE }, { "fast-import", cmd_fast_import, RUN_SETUP | NO_PARSEOPT }, { "fetch", cmd_fetch, RUN_SETUP }, { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT }, diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 1cbc9715a8..10f8956665 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -205,6 +205,16 @@ test_expect_success 'merge c0 with c1 with --ff-only' ' test_debug 'git log --graph --decorate --oneline --all' +test_expect_success 'fast-forward c0 with c1' ' + git reset --hard c0 && + git fast-forward c1 && + git fast-forward HEAD c0 c1 && + verify_merge file result.1 && + verify_head "$c1" +' + +test_debug 'git log --graph --decorate --oneline --all' + test_expect_success 'merge from unborn branch' ' git checkout -f main && test_might_fail git branch -D kid && @@ -322,6 +332,17 @@ test_expect_success 'merges with --ff-only' ' verify_head $c3 ' +test_expect_success 'fast-forward' ' + git reset --hard c1 && + test_tick && + test_must_fail git fast-forward c2 && + test_must_fail git fast-forward c3 && + test_must_fail git fast-forward c2 c3 && + git reset --hard c0 && + git merge c3 && + verify_head $c3 +' + test_expect_success 'merges with merge.ff=only' ' git reset --hard c1 && test_tick && From patchwork Mon Jul 5 12:31:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0CB5C07E99 for ; Mon, 5 Jul 2021 12:32:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2520613AE for ; Mon, 5 Jul 2021 12:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbhGEMe4 (ORCPT ); Mon, 5 Jul 2021 08:34:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbhGEMe4 (ORCPT ); Mon, 5 Jul 2021 08:34:56 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB06AC061574 for ; Mon, 5 Jul 2021 05:32:18 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id t24-20020a9d7f980000b029046f4a1a5ec4so18195940otp.1 for ; Mon, 05 Jul 2021 05:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SRcvqel+3yC5OJOh9fWMay2wHUWwhrsVkld23PgM71g=; b=ckP3TAzm6EbGuRJF4XRHFKDEOKfyqPVw1VpsUpKiQLQapQ7wMkYjTssd/ATBE2NDev qFdPopAU/xgk7gDF3swuqeL/MWu2KkL0++KHZtqDWxh0+USyWnbQGgLJmu8fpBzSV/xo AnjgP1e9PE4Ahs4IKyGwyd66LWjMDIXjIxPxpMriWR4Pj8iVvKZBNXdqQooVG1WHPIey 6915t1dEHMcQPf75TEl+eAojBNbpDMsomXyz6Btanydh9Oj0+ET9KCQfj1udzrVdvH6n NEuxG3nFZiWPhX5taJKcjx2tpxGnpsBodk0P3/tLQ61F/NcuP1EBW0IaT7htyihMaWAd 0slg== 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=SRcvqel+3yC5OJOh9fWMay2wHUWwhrsVkld23PgM71g=; b=bV2lYWGXBTMlqyfKC0eqweqBJLP/XJYm7kf0sew9YM7rF4FA3cZ2EeDCuVs50cOixh lhzhwqMW4eHCGo8J4vA9TdZgyb2fid4GFH8oXMzv60oNDyPss2X1ZIzFEQoI4Bh5GhlE zmvz669jdYogOocVaHr/4Z/znJcbfW2QMHjI/5YEX+gANuuJXUtzjUC+fMS3hoNnZNmk imim4Jr1F3blHNr36jJ3axYu2M7y7J+u4XfFBlWAWDDGTYNFbiNvpO7/rOtEEaK7ww50 wPBaLhVf8QsUkqqeAhAxOTNFCSB/RPJInnh8Rkj0Jg5gUoJFkX+NHx2IPGeI//3u9/hZ zmfQ== X-Gm-Message-State: AOAM533BAMvb0JJMj0697nNxie3Z/ZKnOeVWZU61cYtbu/izmbdMqO2k q5PUFxA+do2IrXnBA+lWST/WS/Aomnn9jw== X-Google-Smtp-Source: ABdhPJycpynoPVLpK9dsZVoMrfEO4ORJEXQQ6KJfvM1ogmVpj/U6XVLQwHM9eRUKKiy0UDyc/k/0Gw== X-Received: by 2002:a05:6830:119:: with SMTP id i25mr4821815otp.28.1625488338068; Mon, 05 Jul 2021 05:32:18 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 59sm2547314otp.68.2021.07.05.05.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:17 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 04/35] doc: fast-forward: explain what it is Date: Mon, 5 Jul 2021 07:31:38 -0500 Message-Id: <20210705123209.1808663-5-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/git-fast-forward.txt | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/git-fast-forward.txt b/Documentation/git-fast-forward.txt index d457022629..b7322c437e 100644 --- a/Documentation/git-fast-forward.txt +++ b/Documentation/git-fast-forward.txt @@ -15,11 +15,41 @@ DESCRIPTION Incorporates changes into the current branch. By default the upstream branch is used, but a different commit can be specified in the arguments. +Assume the following history exists and the current branch is +`master`: + +------------ + D---C---B---A origin/master + ^ + | + master +------------ + +Then `git fast-forward` will advance the local `master` to `origin/master`: + +------------ + D---C---B---A master, origin/master +------------ + +This operation is not always possible; if you made changes and the branches +have diverged: + +------------ + D---C---B---A origin/master + \ + X---Y master +------------ + +then the fast-forward command will fail. + +In those cases you need to either `git merge`, or `git rebase` in order to +synchronize the two branches. + THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. SEE ALSO -------- -linkgit:git-merge[1] +linkgit:git-merge[1], linkgit:git-rebase[1] GIT --- From patchwork Mon Jul 5 12:31:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F422BC07E9C for ; Mon, 5 Jul 2021 12:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D58F5613AA for ; Mon, 5 Jul 2021 12:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230492AbhGEMe6 (ORCPT ); Mon, 5 Jul 2021 08:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230440AbhGEMe5 (ORCPT ); Mon, 5 Jul 2021 08:34:57 -0400 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9C6FC061574 for ; Mon, 5 Jul 2021 05:32:20 -0700 (PDT) Received: by mail-oi1-x232.google.com with SMTP id r29so4176015oiw.13 for ; Mon, 05 Jul 2021 05:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zUFu2zuIjC4xz1tJv3wiAI3LhueGdoPq4NGJJM+hK+U=; b=JjU6Ry8xAJUJ3w31f5P6jziDw2rdVVyByBQ3iz2spjCW3k8HlBTqzPK3q0L3NpvdNb o2VgBHhgJuNKvvxjiaOWPu24nEh/x5wvcqu/aQ/4/91aiMe6u8w8yerOoV+qSfH2/MQv m9WOIukrCU5cC3PFJ8QWgdzIfF5/FNBFfS5ksXkiInHXWbufGgYco9ShYoTYA2MgLs81 PtHlaz3s/mzAQK2sWEestiPhsV+f9IQUkGWzkiYhhbTtV8C7QyUbXquDv1799vOetRvX ReNdGIVBu7Bm+MZPkzz6gUw07lO/BJ/BXdAU3kTCDiiV3QjC5zi33rNCgxQiYiwPDx5w Q2jg== 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=zUFu2zuIjC4xz1tJv3wiAI3LhueGdoPq4NGJJM+hK+U=; b=ZFD9in4aFsup63upXgwLPISEtYonVA3kFONhlsZzyLF6MebidggXibgihNo/lcC5QK mShZXLBjsLfajTyjcOcPYC/S2Pp9y+jxpEjd8bLa2g3b+Tcj1j+fuqwOHZaHV6TEu02j UM7di6XHIvAATNXNtAFe9S8dvqKHGqJ7teoqmqTj+oJVL/RVVnn9HPRrfWIoAT3kVNBO swcka+FSyItdRY6fAEFFYJnMUyEePRugsrYfNJKEky1CIuCUjfQGuL7/ANLSWpzD4SUq clEnMvTuKmJuEGIgRoEjUA0fXEnCxoxDeUNPCPddFFJ/IDYueBIPJotclkv/XTH+vfCs dJcg== X-Gm-Message-State: AOAM532EjM+9qzwBx3zIAoLccLtj1y6c3WRsv00gqTGcxRnjRY6s5HZI +VEquC1U2Qbsnxpw7/RH+Dul9gJKdomdHw== X-Google-Smtp-Source: ABdhPJwjJ91824XHAZEthsbKgP77RtllSe4R0TlnsKwxagnRXpcAqCQDX1Srv2u/AkOGYzAVSfWSgg== X-Received: by 2002:a05:6808:2115:: with SMTP id r21mr5508716oiw.10.1625488339919; Mon, 05 Jul 2021 05:32:19 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id e18sm2631729oiw.27.2021.07.05.05.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:19 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 05/35] fast-forward: add advice for novices Date: Mon, 5 Jul 2021 07:31:39 -0500 Message-Id: <20210705123209.1808663-6-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It doesn't hurt showing it on `git merge --ff-only` too. Signed-off-by: Felipe Contreras --- advice.c | 11 +++++++++++ advice.h | 1 + builtin/merge.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/advice.c b/advice.c index 0b9c89c48a..8f068c8be9 100644 --- a/advice.c +++ b/advice.c @@ -326,3 +326,14 @@ void detach_advice(const char *new_name) fprintf(stderr, fmt, new_name); } + +void diverging_advice(void) +{ + advise(_("Diverging branches can't be fast-forwarded, you need to either:\n" + "\n" + "\tgit merge\n" + "\n" + "or:\n" + "\n" + "\tgit rebase\n")); +} diff --git a/advice.h b/advice.h index bd26c385d0..6ce967c962 100644 --- a/advice.h +++ b/advice.h @@ -97,5 +97,6 @@ void NORETURN die_resolve_conflict(const char *me); void NORETURN die_conclude_merge(void); void advise_on_updating_sparse_paths(struct string_list *pathspec_list); void detach_advice(const char *new_name); +void diverging_advice(void); #endif /* ADVICE_H */ diff --git a/builtin/merge.c b/builtin/merge.c index e396943d37..1836f98f82 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1625,8 +1625,10 @@ static int merge_common(int argc, const char **argv, const char *prefix, } } - if (fast_forward == FF_ONLY) + if (fast_forward == FF_ONLY) { + diverging_advice(); die(_("unable to fast-forward")); + } if (autostash) create_autostash(the_repository, From patchwork Mon Jul 5 12:31:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA062C07E9B for ; Mon, 5 Jul 2021 12:32:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9C86613AE for ; Mon, 5 Jul 2021 12:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbhGEMe7 (ORCPT ); Mon, 5 Jul 2021 08:34:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbhGEMe7 (ORCPT ); Mon, 5 Jul 2021 08:34:59 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C74C06175F for ; Mon, 5 Jul 2021 05:32:22 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id s17so20656702oij.0 for ; Mon, 05 Jul 2021 05:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1E5rqjXig626tmXGeF5NX3O3EHxKT4Bio0ij+D3RcF0=; b=XvFVdRqEEVlXLGCFLrPjWz9umyPLJHk3iLwtr+AHsUpyiIujSehuV3lGXgKXYTlV7a lVO6d2szIW96Nsp54fdg+60Bq0EnRGaQosxgBW/4uxGOFAG+CA5g1JUz+1YPTkisapVF Tnj/iiLLMs5YUZ14hcgCiJ92l919f0KxtO80ufcE6F5NcUla7pwmtT9koUNU3DNhppsK nfCw5QoKt1uO35//sWaAEhJZXFB+XxHNnwP7n4W4wTCyJTDzcBoT4r1rccbCDjNDCGzZ kS1bcg/cF1r6Tsz0Lqe4/15wKzOtsXPJy+YzkyqFCTP84InmKg+NFScRDiSQv44hFZAq hs2A== 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=1E5rqjXig626tmXGeF5NX3O3EHxKT4Bio0ij+D3RcF0=; b=qvhVeat7nCt/1neV4bSVFcN/SOHg5N5XHGERcXANdUxvId+Z/76WAmjLj07nHAkFbQ dwJzYspXK0lUtnwvjZ4wovtaT681ePHiuRNIPFBZN9UyFXpNnUA05MHXIj/JbK3S5JV6 IFAv26JX+LXLa6+As8F/8V11crd/4xtwGrrmrTANhigYRHewP6qIDoQEyZv6O9nDaQK9 Gg5NbEVjWtw/v5BBeNRlDxL6V2tANTImMtd/rRXrI0w6uSs/0qOJEaBeO3WM+o/BCEI3 uC4563BWa4q1JK3fNBnQzagSn5MwghscpJbGf7Wc/jmZOJHUf/a+Gi4e/bTgrENekdYJ +wiw== X-Gm-Message-State: AOAM531j9PRzcz6/AuQP+zXsC5OsN29+7oc64HGWJs8RvSTe9RDCpRIZ igRjdFYQVQ2FDkjK8mB1UIdwe9PfhIhxGA== X-Google-Smtp-Source: ABdhPJw2/ay9Sz62jExdfUDIf5+5q2iA0VYsDyZyhXlCVG+HC49MNS7lttkEmNqCpGVawN0bQ043pQ== X-Received: by 2002:aca:da86:: with SMTP id r128mr10454019oig.150.1625488341563; Mon, 05 Jul 2021 05:32:21 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 104sm576634otm.55.2021.07.05.05.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:21 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 06/35] fast-forward: make the advise configurable Date: Mon, 5 Jul 2021 07:31:40 -0500 Message-Id: <20210705123209.1808663-7-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org With advice.diverging. Signed-off-by: Felipe Contreras --- Documentation/config/advice.txt | 2 ++ advice.c | 4 +++- advice.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt index 8b2849ff7b..dae85310dc 100644 --- a/Documentation/config/advice.txt +++ b/Documentation/config/advice.txt @@ -123,4 +123,6 @@ advice.*:: Advice shown when either linkgit:git-add[1] or linkgit:git-rm[1] is asked to update index entries outside the current sparse checkout. + diverging:: + Advice shown when a fast-forward is not possible. -- diff --git a/advice.c b/advice.c index 8f068c8be9..60de7fbc4e 100644 --- a/advice.c +++ b/advice.c @@ -110,6 +110,7 @@ static struct { [ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] = { "checkoutAmbiguousRemoteBranchName", 1 }, [ADVICE_COMMIT_BEFORE_MERGE] = { "commitBeforeMerge", 1 }, [ADVICE_DETACHED_HEAD] = { "detachedHead", 1 }, + [ADVICE_DIVERGING] = { "diverging", 1 }, [ADVICE_FETCH_SHOW_FORCED_UPDATES] = { "fetchShowForcedUpdates", 1 }, [ADVICE_GRAFT_FILE_DEPRECATED] = { "graftFileDeprecated", 1 }, [ADVICE_IGNORED_HOOK] = { "ignoredHook", 1 }, @@ -329,7 +330,8 @@ void detach_advice(const char *new_name) void diverging_advice(void) { - advise(_("Diverging branches can't be fast-forwarded, you need to either:\n" + advise_if_enabled(ADVICE_DIVERGING, + _("Diverging branches can't be fast-forwarded, you need to either:\n" "\n" "\tgit merge\n" "\n" diff --git a/advice.h b/advice.h index 6ce967c962..695f5a62bb 100644 --- a/advice.h +++ b/advice.h @@ -49,6 +49,7 @@ extern int advice_add_empty_pathspec; ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME, ADVICE_COMMIT_BEFORE_MERGE, ADVICE_DETACHED_HEAD, + ADVICE_DIVERGING, ADVICE_FETCH_SHOW_FORCED_UPDATES, ADVICE_GRAFT_FILE_DEPRECATED, ADVICE_IGNORED_HOOK, From patchwork Mon Jul 5 12:31:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7F4AC07E99 for ; Mon, 5 Jul 2021 12:32:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEAF3613AE for ; Mon, 5 Jul 2021 12:32:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbhGEMfC (ORCPT ); Mon, 5 Jul 2021 08:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbhGEMfB (ORCPT ); Mon, 5 Jul 2021 08:35:01 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17069C061574 for ; Mon, 5 Jul 2021 05:32:24 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id l17-20020a9d6a910000b029048a51f0bc3cso6382707otq.13 for ; Mon, 05 Jul 2021 05:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u9rZxuGcpANLu5SXyZ7fh9Ix7OzVFixoHZdlj8FpJAw=; b=taMEJwIJn1ggudMRObk4/UqnP1kNp5K5u0qkNmN2yJRaZX/5RhYDALSTYfAtddbQ2a ZYKGwfaXxGZtjem2qjTcLbOO8JSxqiE3tF0lT4joBsYJCPHRMfQx3oTtI6VKYiVdmvku KTVD9VmkR1U8BkZnT7XOIukCSR4Mot7MWFCF+VIKxEFvOem7ZnGVM5CQxJcG1dObwrd1 6JqElo0FofgrCZr6yPBO3bv6upgrbdPJM7Y8QlKvq79pGncZOQrABsthShJNIj3elTwg PNnMkHRIETlLfUnW2QJ1nNcPgnEv7nL4YbjZxkUSvElwIrnNGh7zzuDM7CdH2AuPy3QM KZmQ== 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=u9rZxuGcpANLu5SXyZ7fh9Ix7OzVFixoHZdlj8FpJAw=; b=HyA1Z00k3orn/7F5/rjeul1smjfcNIXovjAuPrwmUICcovd+333/aabKgpsYt9QZvX +cqcGerOe10eDwTi1M2rx0dknntrq+WUVGX8AE3FYVkVYGpApDEDcH1We5PB5QKcKQQZ dVl64MY6QzxE8lU5yHNTB1AWPjJv+5Lr9hyUL66LeXAcxAXCIj5H//+bXT/02VFLBAHi sO8CLoc1K5IDtcNkx6YmHEnR+UC4sYa3uOevJRIRZupqOUVdhyFim5foPDEj4y2POUD9 /U4rEOWAH0U0euKlBDZMOnEF4iu5thg0FFqbcY+YHjztnlz+yx1oeLT8Gv6P7UHvZm9g Hgiw== X-Gm-Message-State: AOAM531E/gZiHASbDbw8SrSx3vbzHEzzxLnKuSbaXwyWj23BgENzTKpf SVSz0r85EILvRoaMliivn2oJoHmOq6A3bQ== X-Google-Smtp-Source: ABdhPJwdEF3TaVJfGXmdVzH7hd6WuIZcUEg6L1rSTxeDfIP2uIymGnKPNq8JnWgW2WvBr7yzPECa4g== X-Received: by 2002:a9d:5c7:: with SMTP id 65mr10721871otd.360.1625488343214; Mon, 05 Jul 2021 05:32:23 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id x5sm2586418oto.63.2021.07.05.05.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:22 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 07/35] fast-forward: add help about merge vs. rebase Date: Mon, 5 Jul 2021 07:31:41 -0500 Message-Id: <20210705123209.1808663-8-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/git-fast-forward.txt | 48 ++++++++++++++++++++++++++++++ advice.c | 4 ++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Documentation/git-fast-forward.txt b/Documentation/git-fast-forward.txt index b7322c437e..a73834e0f9 100644 --- a/Documentation/git-fast-forward.txt +++ b/Documentation/git-fast-forward.txt @@ -47,6 +47,54 @@ synchronize the two branches. THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. +MERGE OR REBASE +--------------- + +The decision to whether merge or rebase depends on the situation, and the +project. Traditionally git has prefered merge over rebase, but that creates a +new commit, and that's frowned up on some projects, so you can't just simply +choose to merge blindly. + +------------ + D---C---B---A origin/master + \ + X---Y master +------------ + +The nature of distributed version control systems make this divergence +unavoidable. You must decide how to synchronize this divergence. + +If you choose to merge, the two heads (master and origin/master) will be joined +together in a new commit: + +------------ + origin/master + | + v + D---C---B---A---M master + \ / + X---Y---+ +------------ + +This new commit is called a merge commit and has two parents (A and Y). + +Rebasing on the other hand rewrites the history: + +------------ + origin/master + | + v + D---C---B---A---X'---Y' master +------------ + +The commits that diverged (X and Y) are rewritten as if they were created on top +of the new base (A). This creates a linear history, which is cleaner, but some +people prefer to preserve the original hsitory. + +In both cases it's likely you would have to resolve conflicts, the difference is +that in a merge you would have to do it all at once in one commit, while with a +rebase you would have to do it on every rewritten commit. + SEE ALSO -------- linkgit:git-merge[1], linkgit:git-rebase[1] diff --git a/advice.c b/advice.c index 60de7fbc4e..7f422b05d3 100644 --- a/advice.c +++ b/advice.c @@ -337,5 +337,7 @@ void diverging_advice(void) "\n" "or:\n" "\n" - "\tgit rebase\n")); + "\tgit rebase\n" + "\n" + "For more information check \"git help fast-forward\".\n")); } From patchwork Mon Jul 5 12:31:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C203EC07E9B for ; Mon, 5 Jul 2021 12:32:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A22EC613AE for ; Mon, 5 Jul 2021 12:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231234AbhGEMfD (ORCPT ); Mon, 5 Jul 2021 08:35:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhGEMfD (ORCPT ); Mon, 5 Jul 2021 08:35:03 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC329C06175F for ; Mon, 5 Jul 2021 05:32:25 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id l17-20020a9d6a910000b029048a51f0bc3cso6382766otq.13 for ; Mon, 05 Jul 2021 05:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wjUg5qrCey4k1agU9PzN1PdkiiwmL6fLsr5SxRKwgWo=; b=FS6TTKA/SdlCyeuQM6NJ3XTYb8WWQvhSEi6WtGO4AzRBHDKOGY66a6DnJ8GpnyAP/P vPn4CaRsMkPtTX1lt9+r+Io3X2WqdnsFgNpzin14gfJ+4pQPz67o+S9BCWbd8C2cYM5D N30T/7W3mpMAH2Yh6aj+8Sz5ey7v3Vy7DzfCgBk+EeXyoYgmwEFsX1+srWB72c509Kbf FE3omwIjyoQ5uzbbR3H6bK275ML7eOairZszfxcgOMwcx9eK05ZjOmb1n7Hq9GE3GGZG nEllR2Te/MdGJn7QySbsqoIVblak9B+WaJ9tXx0ydlK3ZDCJYrNsNpmq/lCtKG/YGH6o AWtg== 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=wjUg5qrCey4k1agU9PzN1PdkiiwmL6fLsr5SxRKwgWo=; b=a1RMMrlCzoY/z/Wybnb/O4K3lI2YlpUF0N1OS8y++wv40B1fdXNyKXu8C6Ki8hBaoP ++wdtMBMijQRIncWievFX9siz6+VGwga0w0KOYQ3x3dto7LiG6b5e6+GtvoHm5VzEL3E iKfkCDnK9sK3c5PkU4eqG3WsKbCUqqr4nwSJVU+Pex1Igdr0QNFO5vgDbhXcHx6YTl98 m/Ew6UbmWguh/iGlFXRg4yZpf2uVLPMutmqCiqzIz1NGGW8mbUkAJkAlTHh67KRcQQ5H lc1L/TLeVYRsXF+p/ZLwNjg9xxMgXBeyys2CNutCNObosuCy5sxVwDfdDM4+OQ9vM955 GTGg== X-Gm-Message-State: AOAM533CV6595fdh0llqEbOM3kOvyLtMK7oXAimGiZag7OIZ2eJ87xaV bTEfgC7Yzyp+HfstSgxuPCTRMQ+MbFh93g== X-Google-Smtp-Source: ABdhPJxMWGXbFtU/bFMmEpf3jRtIzNhE4g9PPjM+NaIKD1vG5fuOJT3hiyn8lH+UdLLHOIk0ktSqXA== X-Received: by 2002:a05:6830:25cb:: with SMTP id d11mr5378642otu.56.1625488345002; Mon, 05 Jul 2021 05:32:25 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 59sm2600403oto.3.2021.07.05.05.32.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:24 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 08/35] update: new built-in Date: Mon, 5 Jul 2021 07:31:42 -0500 Message-Id: <20210705123209.1808663-9-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This is basically `git fetch` + `git fast-forward`. Signed-off-by: Felipe Contreras --- .gitignore | 1 + Documentation/config.txt | 2 ++ Documentation/git-update.txt | 32 +++++++++++++++++ Makefile | 1 + builtin.h | 1 + builtin/update.c | 48 ++++++++++++++++++++++++++ contrib/completion/git-completion.bash | 12 +++++++ git.c | 1 + t/t5563-update.sh | 45 ++++++++++++++++++++++++ 9 files changed, 143 insertions(+) create mode 100644 Documentation/git-update.txt create mode 100644 builtin/update.c create mode 100755 t/t5563-update.sh diff --git a/.gitignore b/.gitignore index 45703399b0..2a3bc43ef2 100644 --- a/.gitignore +++ b/.gitignore @@ -171,6 +171,7 @@ /git-tag /git-unpack-file /git-unpack-objects +/git-update /git-update-index /git-update-ref /git-update-server-info diff --git a/Documentation/config.txt b/Documentation/config.txt index bf82766a6a..fc4b49c0d4 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -440,6 +440,8 @@ include::config/rerere.txt[] include::config/reset.txt[] +include::config/update.txt[] + include::config/sendemail.txt[] include::config/sequencer.txt[] diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt new file mode 100644 index 0000000000..54c49c5d12 --- /dev/null +++ b/Documentation/git-update.txt @@ -0,0 +1,32 @@ +git-update(1) +============= + +NAME +---- +git-update - Update the current branch to the latest remote + +SYNOPSIS +-------- +[verse] +'git update' + +DESCRIPTION +----------- + +Incorporates changes from a remote repository into the current branch. + +`git update` runs `git fetch` and then tries to advance the current branch to +the remote branch with `git fast-forward`. If you don't have any extra changes +the update operation is straight-forward, but if you do a further `git merge` or +`git rebase` will be needed. + +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. + +SEE ALSO +-------- +linkgit:git-fetch[1], linkgit:git-fast-forward[1], +linkgit:git-merge[1], linkgit:git-rebase[1] + +GIT +--- +Part of the linkgit:git[1] suite diff --git a/Makefile b/Makefile index cf42162a07..6450574feb 100644 --- a/Makefile +++ b/Makefile @@ -1161,6 +1161,7 @@ BUILTIN_OBJS += builtin/symbolic-ref.o BUILTIN_OBJS += builtin/tag.o BUILTIN_OBJS += builtin/unpack-file.o BUILTIN_OBJS += builtin/unpack-objects.o +BUILTIN_OBJS += builtin/update.o BUILTIN_OBJS += builtin/update-index.o BUILTIN_OBJS += builtin/update-ref.o BUILTIN_OBJS += builtin/update-server-info.o diff --git a/builtin.h b/builtin.h index 601e438c9b..7d18897682 100644 --- a/builtin.h +++ b/builtin.h @@ -229,6 +229,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix); int cmd_tar_tree(int argc, const char **argv, const char *prefix); int cmd_unpack_file(int argc, const char **argv, const char *prefix); int cmd_unpack_objects(int argc, const char **argv, const char *prefix); +int cmd_update(int argc, const char **argv, const char *prefix); int cmd_update_index(int argc, const char **argv, const char *prefix); int cmd_update_ref(int argc, const char **argv, const char *prefix); int cmd_update_server_info(int argc, const char **argv, const char *prefix); diff --git a/builtin/update.c b/builtin/update.c new file mode 100644 index 0000000000..51e45b453d --- /dev/null +++ b/builtin/update.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2021 Felipe Contreras + */ + +#include "builtin.h" +#include "run-command.h" +#include "dir.h" + +static int run_fetch(void) +{ + struct strvec args = STRVEC_INIT; + int ret; + + strvec_pushl(&args, "fetch", "--update-head-ok", NULL); + + ret = run_command_v_opt(args.v, RUN_GIT_CMD); + strvec_clear(&args); + return ret; +} + +static int run_fast_forward(void) +{ + struct strvec args = STRVEC_INIT; + int ret; + + strvec_pushl(&args, "fast-forward", "FETCH_HEAD", NULL); + + ret = run_command_v_opt(args.v, RUN_GIT_CMD); + strvec_clear(&args); + return ret; +} + +int cmd_update(int argc, const char **argv, const char *prefix) +{ + if (!getenv("GIT_REFLOG_ACTION")) + setenv("GIT_REFLOG_ACTION", "update", 0); + + if (repo_read_index_unmerged(the_repository)) + die_resolve_conflict("update"); + + if (file_exists(git_path_merge_head(the_repository))) + die_conclude_merge(); + + if (run_fetch()) + return 1; + + return run_fast_forward(); +} diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index cfaee3aaeb..c5214d9856 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -3257,6 +3257,18 @@ _git_tag () esac } +_git_update () +{ + case "$cur" in + --*) + __gitcomp_builtin update + + return + ;; + esac + __git_complete_remote_or_refspec +} + _git_whatchanged () { _git_log diff --git a/git.c b/git.c index 6ab1fb9251..0156ea81a4 100644 --- a/git.c +++ b/git.c @@ -610,6 +610,7 @@ static struct cmd_struct commands[] = { { "tag", cmd_tag, RUN_SETUP | DELAY_PAGER_CONFIG }, { "unpack-file", cmd_unpack_file, RUN_SETUP | NO_PARSEOPT }, { "unpack-objects", cmd_unpack_objects, RUN_SETUP | NO_PARSEOPT }, + { "update", cmd_update, RUN_SETUP | NEED_WORK_TREE }, { "update-index", cmd_update_index, RUN_SETUP }, { "update-ref", cmd_update_ref, RUN_SETUP }, { "update-server-info", cmd_update_server_info, RUN_SETUP }, diff --git a/t/t5563-update.sh b/t/t5563-update.sh new file mode 100755 index 0000000000..951df41ac4 --- /dev/null +++ b/t/t5563-update.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +test_description='update' + +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo one > file && + git add file && + git commit -a -m one && + echo two > file && + git commit -a -m two +' + +test_expect_success 'basic update' ' + test_when_finished "rm -rf test" && + ( + git clone . test && + cd test && + git reset --hard @^ && + git update && + test_cmp_rev master origin/master + ) +' + +test_expect_success 'non-fast-forward update' ' + test_when_finished "rm -rf test" && + ( + git clone . test && + cd test && + git checkout -b other master^ && + >new && + git add new && + git commit -m new && + git checkout -b test -t other && + git reset --hard master && + test_must_fail git update && + test_cmp_rev @ master + ) +' + +test_done From patchwork Mon Jul 5 12:31:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCD36C07E99 for ; Mon, 5 Jul 2021 12:32:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA823613AE for ; Mon, 5 Jul 2021 12:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbhGEMfE (ORCPT ); Mon, 5 Jul 2021 08:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbhGEMfE (ORCPT ); Mon, 5 Jul 2021 08:35:04 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98312C06175F for ; Mon, 5 Jul 2021 05:32:27 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id h24-20020a9d64180000b029036edcf8f9a6so18169500otl.3 for ; Mon, 05 Jul 2021 05:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DErwTfA+HDamFAy7JChjjTuHGkzO9O5t8TkvqSJIb+4=; b=GlmhX8gJY7WGbkSxFifkyPSWF0ogv5iRv2r5ukqdBqG2FrvUev9LLCRpWHdYGLjrPj CcLuSu7sQLPBG/di8UYD7F6HGJ7HpyjNg71uwxG3xlwNt0z7MvfWeGhGlMvdqQ2IOp6P 0KaqVbw4LC+ygyOXDzAYT1lGC8m9/NpLKAbtMKGgJ0P1Xps5vS5IXowhDGhZempsQBpV haC26h+pzufQhkU10pwta+xWNtfDO7Xd4Xk2qFz7bTrx4TJtisYqN4PbH5q+jnuDBZQL penjuegSfnHUQFi7Z4vJddCeLx51KyV0rCBgg8+lc5gO01xKE8kzRe1GMiPRP2EZ/OJ5 m/EQ== 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=DErwTfA+HDamFAy7JChjjTuHGkzO9O5t8TkvqSJIb+4=; b=MA8dR4oJ7+oyvmgoJkvsIJTzsqq1GnMxhH3EZgXY5Q3MiVb3LOytkzPgTCXmLn3Y6+ EYzwKmxN93G43RcObXR+OIxieJjBP4XgpV44jXCZxbelz39y7a8Vi+fAc1Be691XGSmK kXW07vAhppmvMc4/wJFttHR7IrxM1pn0hETq81FADRcXMmhYB0UF93Dvv1HevtKusKm3 maZK5CwD5SMjQSI8okmhrv09rbbfC4M44fRkikfutttTb4IIyj01QyK2xhvVw/2gJyTx EZvgSwfrPTVfEir29UNKPgUdnkL9hluHgIZhBJ+Ga8ucmlw8Gf8uO1B9kAeHgIK7RCmZ 39dA== X-Gm-Message-State: AOAM5303/oR+Tsx0mx9BstQDFuqP4T4bx9HfwwFe4Kqj3o2y7M2mlohI yNBQV1dGweQN5BV45dnee5GaCA3Hm1pXCQ== X-Google-Smtp-Source: ABdhPJy+th7dFJR8VheCpmDCaxDPmW2q0x7/WJY7rNAmF2lMKTRZBRM3jDg/O6TW60yqaduWLkgcUQ== X-Received: by 2002:a05:6830:3089:: with SMTP id f9mr10229434ots.160.1625488346792; Mon, 05 Jul 2021 05:32:26 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id e24sm576071oou.23.2021.07.05.05.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:26 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 09/35] update: add options and usage skeleton Date: Mon, 5 Jul 2021 07:31:43 -0500 Message-Id: <20210705123209.1808663-10-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/update.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/builtin/update.c b/builtin/update.c index 51e45b453d..1a69896aa8 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -3,9 +3,19 @@ */ #include "builtin.h" +#include "parse-options.h" #include "run-command.h" #include "dir.h" +static const char * const update_usage[] = { + N_("git update"), + NULL +}; + +static struct option update_options[] = { + OPT_END() +}; + static int run_fetch(void) { struct strvec args = STRVEC_INIT; @@ -35,6 +45,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) if (!getenv("GIT_REFLOG_ACTION")) setenv("GIT_REFLOG_ACTION", "update", 0); + argc = parse_options(argc, argv, prefix, update_options, update_usage, 0); + if (repo_read_index_unmerged(the_repository)) die_resolve_conflict("update"); From patchwork Mon Jul 5 12:31:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B136C07E99 for ; Mon, 5 Jul 2021 12:32:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 840FD613AE for ; Mon, 5 Jul 2021 12:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231282AbhGEMfH (ORCPT ); Mon, 5 Jul 2021 08:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbhGEMfG (ORCPT ); Mon, 5 Jul 2021 08:35:06 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C121C06175F for ; Mon, 5 Jul 2021 05:32:29 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 10so5848845oiq.9 for ; Mon, 05 Jul 2021 05:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8zYK1vo8yAGJAYsE54/EftO3GuwM2BwPMDk5g0aNvWI=; b=LX+Au4PbUaiH3ZHzmwaHVGZyBeBS6zvPT3nV0bvpCPFGIc2KeK8Qn2l64TPk3otZhc Q0FpviLNlOcy2Po/TdliIgcbRus4jF/tnl+ipUADI1oZFku0Z9++ZMUDHDt5DYSQk6GT 8+Qb7tucpCMxw/V1140cmdp2DAexQZ2SLVTexuOppNFRAiMBYVemY/cz4mzL+xWPx4Cp mdSuasnXpP3o6TwChz4nDcg245i1yFbpnJpBVTvrLImLok1eeFqVKqNohDpIOyznP9b4 4jn70AtzRQgfVWDE+QsMoy6OwTB3BOJZ6F++uE0TsMJfdz+vytZ/dIevrO6MUXASGZAs b1HQ== 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=8zYK1vo8yAGJAYsE54/EftO3GuwM2BwPMDk5g0aNvWI=; b=fe/oTOGEF60+MWKFHuOuy6UdK7kprJwRR3F1LTSJBwgVHplgBxCx4a2XyIbOLb5oDS 0vSsF/FXTkKm1H/YJ+Qw/zjvqM1UpoKiYfIL9xvj77RCoZpttmXSQ8+ilIIt8uolSgdR 8eAroxEPsc7TYlydgudtx6Y9Dv3Z7Iq1h4p0RdtMhOjtxP38sJOPz1LpwZUabQP+3qqS dWn68P9gWTrx/qTQjYChPl56oVsS2aJ6Fu2E5Fn8aUIWd6p0IqYTrdu5ZtK7+Mfc9RQs 8uAWGzp39cyClrfLv9nXHd8z/Pp/wFFViFU95HNiMs+9ifmyzP9SkQYCLbpNUh0ItFw1 DjdA== X-Gm-Message-State: AOAM530UmBJLXa2weGONlKx1gy55s2rdsE0lnn6vNtPz9QaJHarNATZx 6hP1QkCtWO8hut7Ir9TUuCjV8UK1BaUFDA== X-Google-Smtp-Source: ABdhPJxPziNpJyyxntup7t/Br3rKoP3Yct42ZQuwmpGuLEGE45C9nMDDSVbiYK1EhmFRSPn7ue953Q== X-Received: by 2002:aca:e107:: with SMTP id y7mr10151939oig.11.1625488348535; Mon, 05 Jul 2021 05:32:28 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id l7sm2619150otn.80.2021.07.05.05.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:28 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 10/35] update: add --ff option Date: Mon, 5 Jul 2021 07:31:44 -0500 Message-Id: <20210705123209.1808663-11-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This is the default, it doesn't change anything. Signed-off-by: Felipe Contreras --- Documentation/git-update.txt | 9 ++++++++- builtin/update.c | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt index 54c49c5d12..df778b7ef4 100644 --- a/Documentation/git-update.txt +++ b/Documentation/git-update.txt @@ -8,7 +8,7 @@ git-update - Update the current branch to the latest remote SYNOPSIS -------- [verse] -'git update' +'git update' [] DESCRIPTION ----------- @@ -22,6 +22,13 @@ the update operation is straight-forward, but if you do a further `git merge` or THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOUR MAY CHANGE. +OPTIONS +------- + +-f:: +--ff:: + Forces a fast-forward. + SEE ALSO -------- linkgit:git-fetch[1], linkgit:git-fast-forward[1], diff --git a/builtin/update.c b/builtin/update.c index 1a69896aa8..34681fe21a 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -7,12 +7,22 @@ #include "run-command.h" #include "dir.h" +enum update_mode_type { + UPDATE_MODE_FAST_FORWARD = 0 +}; + +static enum update_mode_type mode = UPDATE_MODE_FAST_FORWARD; + static const char * const update_usage[] = { - N_("git update"), + N_("git update []"), NULL }; static struct option update_options[] = { + OPT_SET_INT_F('f', "ff", &mode, + N_("incorporate changes by fast-forwarding"), + UPDATE_MODE_FAST_FORWARD, PARSE_OPT_NONEG), + OPT_END() }; @@ -56,5 +66,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) if (run_fetch()) return 1; - return run_fast_forward(); + if (mode == UPDATE_MODE_FAST_FORWARD) + return run_fast_forward(); + + return 1; } From patchwork Mon Jul 5 12:31:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6845C07E99 for ; Mon, 5 Jul 2021 12:32:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D6E5613AA for ; Mon, 5 Jul 2021 12:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbhGEMfK (ORCPT ); Mon, 5 Jul 2021 08:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbhGEMfI (ORCPT ); Mon, 5 Jul 2021 08:35:08 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90587C061760 for ; Mon, 5 Jul 2021 05:32:31 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id t3so20599542oic.5 for ; Mon, 05 Jul 2021 05:32:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cI4CQbjfeh+xCuoXPHJxuDfMmH/tcw6xDyctCs528Qk=; b=Z0Fs5yXyUNJ5/CKbIK3v7HlmBaJxdp+vL1HVMMf0CyzsfT3Aq13efg7o138Ufr21xx 8SSgqkmABsGTgXnzRQX589pcMCCYl/RHQkcgtoDu+iU6AU+O2YrdCJcNbq8lDd7p6hGx tKWPQA8fNt7UW0UA71FCQjcCwuVehUF0tf0SBALlXCX7U5S4XL8+qIX+DLcMxJzXCeyv QzZ1Gw1iUUCaSwjdxMuE8JlBoe7hhN+ibmivTW4Tl13m2+S2o8TtXZzNb6G9jXoQv3AP 7PIEky5Rdi1HXXDbiE2VQMpib3qazwVSUo97EeqUlpF8hk1ExY2XNr50bcbO9xQ4hFso TfEg== 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=cI4CQbjfeh+xCuoXPHJxuDfMmH/tcw6xDyctCs528Qk=; b=pvvVo6ytMPIZQnpAQzYHP/sIGPzb6UFVtTpYpHTK1w32EV3E8PSBD6b8rqXG3r4chw SoFlBVadSinA96cqbPVhu7x8ykH2aIGzTkzveS8k5ZWvp/f4h5MgVzrrcVCrcNcRm5r+ aQ20KJ9eWefP66srQaItCPhBvgZtrS1Py+TZ8FIkk2JnecnRQHpxGEc6Ih+98gy4347F DmY7QfiOh1JvI6YOJvYMMYCwvwJltdQtQLf2MaWnhN6pJIFOSkvsfEVPlwcV2G+tG5FS 9aBQAoqU5xt0gpo6NEx/GldKoZ6eI0OoFhW2zXuzGzd3rVst54v5d/29xpN5VFWJrkVM UQqg== X-Gm-Message-State: AOAM533Ld4fUiFAYi6940V6vltlsqQ/OX0W148dzyjAqU82dq68egLN8 2T9VVOW2hMzSY/eMIeZbwwfsa8GsvMzDcg== X-Google-Smtp-Source: ABdhPJyb2C6KQyMLJZ5AvbjPInTsTTkPdJ+hs/D5rr3OOQ+uSNL/NTR0G5Kl7QqRg+4/yHv8vi5RJg== X-Received: by 2002:a05:6808:113:: with SMTP id b19mr9715412oie.48.1625488350412; Mon, 05 Jul 2021 05:32:30 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 59sm2600441oto.3.2021.07.05.05.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:29 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 11/35] update: add --merge mode Date: Mon, 5 Jul 2021 07:31:45 -0500 Message-Id: <20210705123209.1808663-12-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/git-update.txt | 4 ++++ builtin/update.c | 20 +++++++++++++++++++- t/t5563-update.sh | 15 +++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt index df778b7ef4..075653c6fd 100644 --- a/Documentation/git-update.txt +++ b/Documentation/git-update.txt @@ -29,6 +29,10 @@ OPTIONS --ff:: Forces a fast-forward. +-m:: +--merge:: + Forces a merge. + SEE ALSO -------- linkgit:git-fetch[1], linkgit:git-fast-forward[1], diff --git a/builtin/update.c b/builtin/update.c index 34681fe21a..5946b383f5 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -8,7 +8,8 @@ #include "dir.h" enum update_mode_type { - UPDATE_MODE_FAST_FORWARD = 0 + UPDATE_MODE_FAST_FORWARD = 0, + UPDATE_MODE_MERGE }; static enum update_mode_type mode = UPDATE_MODE_FAST_FORWARD; @@ -22,6 +23,9 @@ static struct option update_options[] = { OPT_SET_INT_F('f', "ff", &mode, N_("incorporate changes by fast-forwarding"), UPDATE_MODE_FAST_FORWARD, PARSE_OPT_NONEG), + OPT_SET_INT_F('m', "merge", &mode, + N_("incorporate changes by merging"), + UPDATE_MODE_MERGE, PARSE_OPT_NONEG), OPT_END() }; @@ -50,6 +54,18 @@ static int run_fast_forward(void) return ret; } +static int run_merge(void) +{ + int ret; + struct strvec args = STRVEC_INIT; + + strvec_pushl(&args, "merge", "FETCH_HEAD", NULL); + + ret = run_command_v_opt(args.v, RUN_GIT_CMD); + strvec_clear(&args); + return ret; +} + int cmd_update(int argc, const char **argv, const char *prefix) { if (!getenv("GIT_REFLOG_ACTION")) @@ -68,6 +84,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) if (mode == UPDATE_MODE_FAST_FORWARD) return run_fast_forward(); + if (mode == UPDATE_MODE_MERGE) + return run_merge(); return 1; } diff --git a/t/t5563-update.sh b/t/t5563-update.sh index 951df41ac4..833a5285da 100755 --- a/t/t5563-update.sh +++ b/t/t5563-update.sh @@ -42,4 +42,19 @@ test_expect_success 'non-fast-forward update' ' ) ' +test_expect_success 'git update non-fast-forward with merge' ' + test_when_finished "rm -rf test" && + ( + git clone . test && + cd test && + git checkout -b other master^ && + >new && + git add new && + git commit -m new && + git checkout -b test -t other && + git reset --hard master && + git update --merge + ) +' + test_done From patchwork Mon Jul 5 12:31:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 204F4C07E9C for ; Mon, 5 Jul 2021 12:32:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03922613AA for ; Mon, 5 Jul 2021 12:32:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbhGEMfL (ORCPT ); Mon, 5 Jul 2021 08:35:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbhGEMfJ (ORCPT ); Mon, 5 Jul 2021 08:35:09 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0970C061760 for ; Mon, 5 Jul 2021 05:32:32 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id t3so20599609oic.5 for ; Mon, 05 Jul 2021 05:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HpdmJ6Nb6dvGNnEadDSOORYSjPZB6Unx6UEHCofzXiI=; b=n0cGZchn1zBnXJbxekBHhaLIfOOAsNZPxK72s3LuDWDkc2tekUmVxejKWWjEF1J/zq wRvYhZbQFrTBBveEXTBPQhOzc9oj5UqaQy1+cEfLOPJZtGwpQTKx92eIJ3SHByON2QA9 DATiUAjA8NFn3wEQuY0y+8NANQeYmVjsTYdZkkpOOR5IrhC/6JBL0Q2zrBpYksilulRD PG2Z0Us5cWE85tB2tofL2/6nX/estOWOyAy1ji6a8yIDn4kPcyiRFtQgpMmwi4opLtsQ fmZXX1yY2ovBgIMC4fI08yMdBLqx3o71WxAqA+GimDCquBQrdiHXBrD6c64VNKA2HXrD wKcQ== 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=HpdmJ6Nb6dvGNnEadDSOORYSjPZB6Unx6UEHCofzXiI=; b=bwApNz5Kkb1lH1C0JG2DE3+N2WnHD0LN0DMH3rWmjv59/ld3c2FFJi9hMdA3P2i0x9 ShlvLyzhHToFhbfTGCk9VngpWN0GXseszAFUMkGA3obQofXu+FgkWhissFpxtyD2MwEb 4GxpXqzuxVODRMagkASeWFhFkPIax9QscLwo/ZMcwALvXZ+W/TvgEtGBbTKSddIwpTZB B+byX52J2/tKO4YqZCw2/aRVUwLDqEm6OMuz67nbufCJB00smASC2rGZYdNCDHx7XJ7B DwQj1FOGioESpzNasN65g0Ygvvxe9l/ZfXXf2EU+vriRZaltcSuHwCxnMlVybtjGXISp DTFA== X-Gm-Message-State: AOAM530HlW5lCddBK+nMMXBYeATvZLGWj+nHxJ/jHONO6P3cBZZtMgHy /WAqckRqdLhdghKPgddYi+X0ztUvnjlXGQ== X-Google-Smtp-Source: ABdhPJzoamCN6MVby6NydifI/K7cey5+Hi+kRD2zC6kJFNbhz6KZ21b3R+y2Ds4hLUvP2R13RmyTcw== X-Received: by 2002:a05:6808:48:: with SMTP id v8mr9158807oic.69.1625488352073; Mon, 05 Jul 2021 05:32:32 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 59sm2547428otp.68.2021.07.05.05.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:31 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 12/35] commit: support for multiple MERGE_MODE Date: Mon, 5 Jul 2021 07:31:46 -0500 Message-Id: <20210705123209.1808663-13-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/commit.c b/builtin/commit.c index 190d215d43..f9dd155566 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1742,7 +1742,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) if (!stat(git_path_merge_mode(the_repository), &statbuf)) { if (strbuf_read_file(&sb, git_path_merge_mode(the_repository), 0) < 0) die_errno(_("could not read MERGE_MODE")); - if (!strcmp(sb.buf, "no-ff")) + if (strstr(sb.buf, "no-ff")) allow_fast_forward = 0; } if (allow_fast_forward) From patchwork Mon Jul 5 12:31:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 005A6C07E9B for ; Mon, 5 Jul 2021 12:32:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8F2D613B6 for ; Mon, 5 Jul 2021 12:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbhGEMfM (ORCPT ); Mon, 5 Jul 2021 08:35:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbhGEMfL (ORCPT ); Mon, 5 Jul 2021 08:35:11 -0400 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938B8C06175F for ; Mon, 5 Jul 2021 05:32:34 -0700 (PDT) Received: by mail-ot1-x332.google.com with SMTP id l17-20020a9d6a910000b029048a51f0bc3cso6383150otq.13 for ; Mon, 05 Jul 2021 05:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aT/aKVr0A+qx3cbs8aVxtNJBCLEI2a9eKTwOZx+Nn9Y=; b=ijLkFKAnjFYhElFvdPzMkYYKehITgK96fnGdngbS+PQgEpJeAa4+aA3S9RqugtXEC+ BgwkSLFEVZcYuf2uOn3GYJKsqUzw0eN8JotoBRGq0zjQsDvFM+p4eO6/tDcA10Ehx/o3 WWo5s2AFq2pKMHM44htLN7a0IePoeH7mURNOi5EaWde7lP3BHhZfoGE4g7cbchVAOf/n i5PeKS8/8d3ByxMzV2IhMTQaUyDDTZc+G/kzSN0oWWpLviMcuZrQXvrH4zK4rMYPUrbV QxNEOIQhZYm1Qb65t5K/md1od+0pPEglJzhmLbKX5jKwLsd4XyiR+ggdfV+8HxuRPI1F sZAw== 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=aT/aKVr0A+qx3cbs8aVxtNJBCLEI2a9eKTwOZx+Nn9Y=; b=TOgW+n5gq0CGbmUp2wLH2gkFt5XeCPKEzMsTXwHQ3NrKLNTpOP40P4b/2qt8Im+Wot uMYetEvGS/sa0+1xC4oRoJhkKa/Wc5cCgUKZ7ISWRePPA33t+vSVBRRk5gn9Lo21baLi sl5laseBNqyYckrSG4uSS/TANltoWK98CKGO1TxYud9w/unZ3R+1h4NpMtIKricL9OBK FdC69d5RjcpKlDwyhvEBVAx1/6kMIgfOe6w4whvEOfc8vmnHWBK6NAEnbzefYk5fCS6X fg1Nn/aSyYeqKrgCLNIFTzenFyHw6xxxrJMhScGP/2BYWDvCFoLksiN6XtV+oHROTQfb +4Vw== X-Gm-Message-State: AOAM5321finzZoCjHRoZF5zae2F37TSt0LTc+UtEr/I4rU/1of+QhoIh 1yfU7VISTsgKwZMhKCCJiZByOH9hyQk0Xw== X-Google-Smtp-Source: ABdhPJx5EfR/x/fLUnxQnKqQSIaonr1P3j2h30p7FiFSB5QLXlrWM32nPsYOcLe0sScVwnbf6btVVg== X-Received: by 2002:a05:6830:18da:: with SMTP id v26mr10273299ote.144.1625488353789; Mon, 05 Jul 2021 05:32:33 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id l10sm2571331oti.9.2021.07.05.05.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:33 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 13/35] merge: add --reverse-parents option Date: Mon, 5 Jul 2021 07:31:47 -0500 Message-Id: <20210705123209.1808663-14-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It would be useful to make `git update` reverse parents as desired. Signed-off-by: Felipe Contreras --- Documentation/merge-options.txt | 4 ++++ builtin/commit.c | 5 +++++ builtin/merge.c | 11 ++++++++++- t/t7600-merge.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Documentation/merge-options.txt b/Documentation/merge-options.txt index eb0aabd396..8917ed97b2 100644 --- a/Documentation/merge-options.txt +++ b/Documentation/merge-options.txt @@ -149,6 +149,10 @@ ifndef::git-pull[] Note that not all merge strategies may support progress reporting. +--reverse-parents:: +--no-reverse-parents:: + Reverse the order of parents in the merge commit. + endif::git-pull[] --autostash:: diff --git a/builtin/commit.c b/builtin/commit.c index f9dd155566..931738eeaf 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1724,6 +1724,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) FILE *fp; int allow_fast_forward = 1; struct commit_list **pptr = &parents; + int reverse_parents = 0; if (!reflog_msg) reflog_msg = "commit (merge)"; @@ -1744,9 +1745,13 @@ int cmd_commit(int argc, const char **argv, const char *prefix) die_errno(_("could not read MERGE_MODE")); if (strstr(sb.buf, "no-ff")) allow_fast_forward = 0; + if (strstr(sb.buf, "reverse")) + reverse_parents = 1; } if (allow_fast_forward) reduce_heads_replace(&parents); + if (reverse_parents) + parents = reverse_commit_list(parents); } else { if (!reflog_msg) reflog_msg = is_from_cherry_pick(whence) diff --git a/builtin/merge.c b/builtin/merge.c index 1836f98f82..b9c6c43d8f 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -91,6 +91,7 @@ static int signoff; static const char *sign_commit; static int autostash; static int no_verify; +static int reverse_parents; static struct strategy all_strategy[] = { { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL }, @@ -306,6 +307,8 @@ static struct option builtin_merge_options[] = { OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")), OPT_BOOL(0, "signoff", &signoff, N_("add a Signed-off-by trailer")), OPT_BOOL(0, "no-verify", &no_verify, N_("bypass pre-merge-commit and commit-msg hooks")), + OPT_BOOL(0, "reverse-parents", &reverse_parents, + N_("reverse the order of parents")), OPT_END() }; @@ -913,6 +916,8 @@ static int merge_trivial(struct commit *head, struct commit_list *remoteheads) pptr = commit_list_append(head, pptr); pptr = commit_list_append(remoteheads->item, pptr); prepare_to_commit(remoteheads); + if (reverse_parents) + parents = reverse_commit_list(parents); if (commit_tree(merge_msg.buf, merge_msg.len, &result_tree, parents, &result_commit, NULL, sign_commit)) die(_("failed to write commit object")); @@ -937,6 +942,8 @@ static int finish_automerge(struct commit *head, parents = remoteheads; if (!head_subsumed || fast_forward == FF_NO) commit_list_insert(head, &parents); + if (reverse_parents) + parents = reverse_commit_list(parents); prepare_to_commit(remoteheads); if (commit_tree(merge_msg.buf, merge_msg.len, result_tree, parents, &result_commit, NULL, sign_commit)) @@ -1049,7 +1056,9 @@ static void write_merge_heads(struct commit_list *remoteheads) strbuf_reset(&buf); if (fast_forward == FF_NO) - strbuf_addstr(&buf, "no-ff"); + strbuf_addstr(&buf, "no-ff "); + if (reverse_parents) + strbuf_addstr(&buf, "reverse "); write_file_buf(git_path_merge_mode(the_repository), buf.buf, buf.len); strbuf_release(&buf); } diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 10f8956665..660d13dd51 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -563,6 +563,16 @@ test_expect_success 'merge c0 with c1 (no-ff)' ' test_debug 'git log --graph --decorate --oneline --all' +test_expect_success 'merge c0 with c1 (--reverse-parents)' ' + git reset --hard c0 && + test_tick && + git merge --no-ff --reverse-parents c1 && + verify_merge file result.1 && + verify_parents $c1 $c0 +' + +test_debug 'git log --graph --decorate --oneline --all' + test_expect_success 'merge c0 with c1 (merge.ff=false)' ' git reset --hard c0 && test_config merge.ff "false" && @@ -940,6 +950,22 @@ test_expect_success 'merge annotated/signed tag w/ tracking' ' ) ' +test_expect_success 'merge --reverse-parents --no-commit && commit' ' + git reset --hard c0 && + git merge --no-ff --reverse-parents --no-commit c1 && + EDITOR=: git commit && + verify_parents $c1 $c0 +' + +test_debug 'git log --graph --decorate --oneline --all' + +test_expect_success 'amending reverse merge commit' ' + EDITOR=: git commit --amend && + verify_parents $c1 $c0 +' + +test_debug 'git log --graph --decorate --oneline --all' + test_expect_success GPG 'merge --ff-only tag' ' git reset --hard c0 && git commit --allow-empty -m "A newer commit" && From patchwork Mon Jul 5 12:31:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD408C07E99 for ; Mon, 5 Jul 2021 12:32:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7578613AE for ; Mon, 5 Jul 2021 12:32:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231365AbhGEMfR (ORCPT ); Mon, 5 Jul 2021 08:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbhGEMfN (ORCPT ); Mon, 5 Jul 2021 08:35:13 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F2EEC061574 for ; Mon, 5 Jul 2021 05:32:36 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id x22-20020a9d6d960000b0290474a76f8bd4so16553451otp.5 for ; Mon, 05 Jul 2021 05:32:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CS0EQ9MfPPVqM6Y/VLVqs7hHXSZ6SLu2Z2ulk8QOCYs=; b=V5+sbKNqhxd/f+GvjRwn00sxdEFoz3PsGRFTT/OJUqtn1MtLba4ZtSnE8Mmyf9eNKn 0gIbFwlVlKe4Jo5jEaYnhnF9nqOFbh9mtW6Ed4HwVxGsBCyBc1eu7D8Rk1BNn4+6P1MB ebfAEVvyMWVgr6q0+CS35RRjbix3vovzZ67Lj/tpvb1CDemrhM97XarucpMNggTLhMxH u933CeamoOfN9S0vw6CSUOjKWCXkbq1pdMVXjpQa2L5a3puhmLSd8mc3eUosAW+djBOD LTSU6KC7iMp5y7OooEs9QgqN92eSBvdUj/SSigzT4EnXaVU7rKuLprtosKueNA+BMtS8 6J4A== 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=CS0EQ9MfPPVqM6Y/VLVqs7hHXSZ6SLu2Z2ulk8QOCYs=; b=gG3JH1XgNwjNgh+/DS5fzRXOSoQmMy2FOX6/vnp1S9VPoKm0tslXIk1ypEImCCHeFm FDbfwYOcgJBF/wt/FvP/b0dU9D3l5ByPqzg/dRMUJ1jnjAbxB8T074eGLFAis6oGc/2T +v+RmWBo2jK4boLcjtCOVNkjfhQNLYKJzO+e1PHTitnH0MTurdyxZMBD/7ik0ERWHrpn qWqtqcKzvjXHRHjEbdbUI7pqynv64J5eAIcN9/c6M8vDjVv/QbTKKZh66ysalnvOWCzV dxZPAtTE5G8eRgrbvlD8l3o/SxAA6eHDcFGTIGWcv0eB//gsjFGT0wIvOmDjQ6GC5Nyi CKWA== X-Gm-Message-State: AOAM532TXuC3Ai4DqsL01exn+mBDSMqebCXJPfbBpznMVenk/p56PB0Q Uy2Opu3RKDfrsBKcDR7ygGhCEkVooAeZeQ== X-Google-Smtp-Source: ABdhPJxFBpq9D06mnABHJvlq7M2jjDmzL+e5ZwvqJ0kxEP+ukVwO0fvQyD0jf0kVqMi3Qe9GKKfcZA== X-Received: by 2002:a9d:4104:: with SMTP id o4mr11129727ote.139.1625488355398; Mon, 05 Jul 2021 05:32:35 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 186sm2215229ooe.28.2021.07.05.05.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:35 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 14/35] update: reverse the order of parents Date: Mon, 5 Jul 2021 07:31:48 -0500 Message-Id: <20210705123209.1808663-15-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The order of the parents in git pull is wrong, many big threads [1] [2] have been started because of that. There's no need for git update to repeat that mistake. [1] https://lore.kernel.org/git/20130522115042.GA20649@inner.h.apk.li/ [2] https://lore.kernel.org/git/4ay6w9i74cygt6ii1b0db7wg.1398433713382@email.android.com/ Signed-off-by: Felipe Contreras --- builtin/update.c | 2 +- t/t5563-update.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/update.c b/builtin/update.c index 5946b383f5..94e83532a8 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -59,7 +59,7 @@ static int run_merge(void) int ret; struct strvec args = STRVEC_INIT; - strvec_pushl(&args, "merge", "FETCH_HEAD", NULL); + strvec_pushl(&args, "merge", "--reverse-parents", "FETCH_HEAD", NULL); ret = run_command_v_opt(args.v, RUN_GIT_CMD); strvec_clear(&args); diff --git a/t/t5563-update.sh b/t/t5563-update.sh index 833a5285da..72d6a357a1 100755 --- a/t/t5563-update.sh +++ b/t/t5563-update.sh @@ -53,7 +53,9 @@ test_expect_success 'git update non-fast-forward with merge' ' git commit -m new && git checkout -b test -t other && git reset --hard master && - git update --merge + git update --merge && + test_cmp_rev @^2 master && + test_cmp_rev @^1 other ) ' From patchwork Mon Jul 5 12:31:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B337BC07E9C for ; Mon, 5 Jul 2021 12:32:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA65613AE for ; Mon, 5 Jul 2021 12:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbhGEMfR (ORCPT ); Mon, 5 Jul 2021 08:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbhGEMfO (ORCPT ); Mon, 5 Jul 2021 08:35:14 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E932FC061762 for ; Mon, 5 Jul 2021 05:32:37 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id f12-20020a056830204cb029048bcf4c6bd9so6086714otp.8 for ; Mon, 05 Jul 2021 05:32:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+1UrZI1rrT1ek2lTooJMYLa96X2vgVPv+T6snNJbHyU=; b=G8vLUGIIcBv6aLPueZug1psrw04ZKgBLu5s2zpsTB2zotcKmI5Jv63f1Lfb4us84bR 5rBFg80pWUxwYknv7pnwnBuKLjWSxkdcGvlcsRA8ms3czD0ZOK/qbm0A1jgvK79fg94d ij/44qs8Zdyr0Lz62PJbSNUD/w+5sQQzM75Y5GPE8Iqnv+MpaPuZ/vOCGQIERee+6nxD 2yfeq+ifMJ6TdeQLHDxDJLJavTHZZ0hMsFudtGn7aGygxJhQgb3Zcz3TkRyJYTdQE7KS sCgGfMQ7zGzviFb3DS9NpZ3ahrQACQgI83qmNRrGalD+n1q1A3c/eESY7Q3/3Dxm7qbn 7K2A== 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=+1UrZI1rrT1ek2lTooJMYLa96X2vgVPv+T6snNJbHyU=; b=UqMmAK0IpgSJrpZ4PvPo6TMQYykLZDN3SmiUq275kFV992ttmUr9oMOjLCXcGZ8eqj tA8tbyTYIo37hTenRtz5ed67/wPP4hAd9470iLcnU9nkWRDXSDmB6uyrdYb8L6yb1CmW +Q3R+Zvyp4EU8vhIopU5Kqtn/5J20JcTqRfjyDCIR5sH2snSa2Qh3bhAjLf7do3cRASh HLKBOG59X6HefyEkk+nbs3hfdfs1W2zChqCf1Re2ja17l5C9IEer0N/d4N/jW8d5BpD2 LpmwwUEItT+K8fzzGT4z9hGTpSob5uUjsH512mVDb0pdYO9mPn8iOMwCqYWZqYRam2Ad 2pwg== X-Gm-Message-State: AOAM530gjZq1heDwSZBw/twgQIIRqDCWtkhy7KEcgLJpeOUqvlzFK36p 0vET+mr6acnOMwCjRaamtY1gOor6lh9o0A== X-Google-Smtp-Source: ABdhPJxfWFb4aW5PERFGCYcSyYmIq+YgtxMjreNyqqa5qNVUx5DrUXC694eHHqgltd5ROa86ryySjA== X-Received: by 2002:a9d:609e:: with SMTP id m30mr10693562otj.168.1625488357134; Mon, 05 Jul 2021 05:32:37 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id w15sm736662oie.21.2021.07.05.05.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:36 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 15/35] update: fake a reverse order of parents in message Date: Mon, 5 Jul 2021 07:31:49 -0500 Message-Id: <20210705123209.1808663-16-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/merge.c | 1 + fmt-merge-msg.c | 21 +++++++++++++++++++-- fmt-merge-msg.h | 3 ++- t/t5563-update.sh | 10 +++++++++- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index b9c6c43d8f..cb476958ad 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -1136,6 +1136,7 @@ static void prepare_merge_message(struct strbuf *merge_names, struct strbuf *mer opts.add_title = !have_message; opts.shortlog_len = shortlog_len; opts.credit_people = (0 < option_edit); + opts.reverse_parents = reverse_parents; fmt_merge_msg(merge_names, merge_msg, &opts); if (merge_msg->len) diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index 0f66818e0f..1f840711cc 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -432,6 +432,19 @@ static int dest_suppressed(const char *dest_branch) return 0; } +static void fmt_update_msg_title(struct strbuf *out, const char *current_branch) +{ + struct src_data *src_data; + strbuf_addf(out, "Merge branch '%s'", current_branch); + src_data = srcs.items[0].util; + if (src_data->branch.nr) { + const char *branch_name = src_data->branch.items[0].string; + if (!dest_suppressed(branch_name)) + strbuf_addf(out, " into %s", branch_name); + } + strbuf_addch(out, '\n'); +} + static void fmt_merge_msg_title(struct strbuf *out, const char *current_branch) { @@ -665,8 +678,12 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out, die("error in line %d: %.*s", i, len, p); } - if (opts->add_title && srcs.nr) - fmt_merge_msg_title(out, current_branch); + if (opts->add_title && srcs.nr) { + if (opts->reverse_parents) + fmt_update_msg_title(out, current_branch); + else + fmt_merge_msg_title(out, current_branch); + } if (origins.nr) fmt_merge_msg_sigs(out); diff --git a/fmt-merge-msg.h b/fmt-merge-msg.h index f2ab0e0085..fbdb1c905e 100644 --- a/fmt-merge-msg.h +++ b/fmt-merge-msg.h @@ -7,7 +7,8 @@ struct fmt_merge_msg_opts { unsigned add_title:1, - credit_people:1; + credit_people:1, + reverse_parents:1; int shortlog_len; }; diff --git a/t/t5563-update.sh b/t/t5563-update.sh index 72d6a357a1..aabbf5a965 100755 --- a/t/t5563-update.sh +++ b/t/t5563-update.sh @@ -7,6 +7,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +check_msg () { + test "$2" != "master" && into=" into '$2'" + echo "Merge branch '$1'${into}" > expected + git log -1 --format=%s > actual && + test_cmp expected actual +} + test_expect_success 'setup' ' echo one > file && git add file && @@ -55,7 +62,8 @@ test_expect_success 'git update non-fast-forward with merge' ' git reset --hard master && git update --merge && test_cmp_rev @^2 master && - test_cmp_rev @^1 other + test_cmp_rev @^1 other && + check_msg test other ) ' From patchwork Mon Jul 5 12:31:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66D07C07E9E for ; Mon, 5 Jul 2021 12:32:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51EBE613AE for ; Mon, 5 Jul 2021 12:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231371AbhGEMfS (ORCPT ); Mon, 5 Jul 2021 08:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbhGEMfR (ORCPT ); Mon, 5 Jul 2021 08:35:17 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF887C061574 for ; Mon, 5 Jul 2021 05:32:39 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id x22-20020a9d6d960000b0290474a76f8bd4so16553586otp.5 for ; Mon, 05 Jul 2021 05:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/jLPQTiouBn4MiqDgOJYbo1kG+VTEVWMoGGivQV086o=; b=UpC3US6elWXvkCE6TyQGZcqE1GjrcLPi8KyRzJAvEMUoQluSzVzxTUhHgMi+5v3Rg2 iE+28KYnGfS1/5QH8PVi+bQ8p7BNP7lueNAEPk5PFxUuC/WhaTnjJ0kIP7xeGgisv8pQ 3pQjcGIvXhqYEMd5wjv+ARH8SyrIqFAYf38SRje1VXaXOf9eLYXHLT7SJOPalioNxPjK p6s2DNj6HjGT7rLSrX1fehYHqsYSwq7aUA2t+pnLxuUVAFvJS9I6xNMLmSKQ5StXHlWy gdkrGOeKfUzew9Bn+yXtOnXb1VIiqXQLXsTS46Un/VXja6Hquk5B8+0PY2IHrS0Nhasw SaUg== 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=/jLPQTiouBn4MiqDgOJYbo1kG+VTEVWMoGGivQV086o=; b=rNdM/NkRDisM0cQrH8J836/BIgs0zw4jwmlsG/0tuSg0Mq99FxUjswFo8htNH0RBmt m0RfbKzTtAiU3rvzGRO40uxrSoHqxipPFqcbuuOq1k1J8alMBfQ8WdO/9IiF/8aUbUXc +cxOtr5NQ9abWftdsoBAQsgCLM7XQqweIwktBUS8ux6rDeOFAqgedxqejhzXUUqTlsSe ncplDfGZWTxJFGU3QXXrRd74jh71Ub55gedPbs2iiw+qJd3oQV2u5/nsdBrg8dVOA6YX OAo+FXAirogr6eWSkVYh7xrlqN0LzimNaWQioK2nGH9ZAEzhHae57mHS8A+SPn/cydE4 yXOg== X-Gm-Message-State: AOAM530M0luDJ7dmYh5f3ZpuoRfvMl5RCE400Jjt38TMWlpCqHRXGK/s 89p+f4Wsy6iR+XxfD9upqxSQ4L6dMNSrTA== X-Google-Smtp-Source: ABdhPJwUT8fiHPh44niN+wxaQ315QFBkcIt4AqG1Ha9Npbs0r/LEk5EGIcqTMjGbU65nfAJ5TXF8qw== X-Received: by 2002:a9d:7dcb:: with SMTP id k11mr10522052otn.107.1625488358976; Mon, 05 Jul 2021 05:32:38 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id g1sm2639893otq.22.2021.07.05.05.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:38 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 16/35] update: add --rebase mode Date: Mon, 5 Jul 2021 07:31:50 -0500 Message-Id: <20210705123209.1808663-17-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/git-update.txt | 4 ++++ builtin/update.c | 20 +++++++++++++++++++- t/t5563-update.sh | 17 +++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Documentation/git-update.txt b/Documentation/git-update.txt index 075653c6fd..0fefda1379 100644 --- a/Documentation/git-update.txt +++ b/Documentation/git-update.txt @@ -33,6 +33,10 @@ OPTIONS --merge:: Forces a merge. +-r:: +--rebase:: + Forces a rebase. + SEE ALSO -------- linkgit:git-fetch[1], linkgit:git-fast-forward[1], diff --git a/builtin/update.c b/builtin/update.c index 94e83532a8..989104421e 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -9,7 +9,8 @@ enum update_mode_type { UPDATE_MODE_FAST_FORWARD = 0, - UPDATE_MODE_MERGE + UPDATE_MODE_MERGE, + UPDATE_MODE_REBASE }; static enum update_mode_type mode = UPDATE_MODE_FAST_FORWARD; @@ -26,6 +27,9 @@ static struct option update_options[] = { OPT_SET_INT_F('m', "merge", &mode, N_("incorporate changes by merging"), UPDATE_MODE_MERGE, PARSE_OPT_NONEG), + OPT_SET_INT_F('r', "rebase", &mode, + N_("incorporate changes by rebasing"), + UPDATE_MODE_REBASE, PARSE_OPT_NONEG), OPT_END() }; @@ -66,6 +70,18 @@ static int run_merge(void) return ret; } +static int run_rebase(void) +{ + int ret; + struct strvec args = STRVEC_INIT; + + strvec_pushl(&args, "rebase", "FETCH_HEAD", NULL); + + ret = run_command_v_opt(args.v, RUN_GIT_CMD); + strvec_clear(&args); + return ret; +} + int cmd_update(int argc, const char **argv, const char *prefix) { if (!getenv("GIT_REFLOG_ACTION")) @@ -86,6 +102,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) return run_fast_forward(); if (mode == UPDATE_MODE_MERGE) return run_merge(); + if (mode == UPDATE_MODE_REBASE) + return run_rebase(); return 1; } diff --git a/t/t5563-update.sh b/t/t5563-update.sh index aabbf5a965..73e67f9783 100755 --- a/t/t5563-update.sh +++ b/t/t5563-update.sh @@ -67,4 +67,21 @@ test_expect_success 'git update non-fast-forward with merge' ' ) ' +test_expect_success 'git update non-fast-forward with rebase' ' + test_when_finished "rm -rf test" && + ( + git clone . test && + cd test && + git checkout -b other master^ && + >new && + git add new && + git commit -m new && + git checkout -b test -t other && + git reset --hard master && + git update --rebase && + test_cmp_rev @^ other && + test_must_fail git rev-parse --verify -q @^2 + ) +' + test_done From patchwork Mon Jul 5 12:31:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358983 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.9 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,UNWANTED_LANGUAGE_BODY, 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 6585FC07E99 for ; Mon, 5 Jul 2021 12:32:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50862613AB for ; Mon, 5 Jul 2021 12:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231376AbhGEMfS (ORCPT ); Mon, 5 Jul 2021 08:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbhGEMfS (ORCPT ); Mon, 5 Jul 2021 08:35:18 -0400 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 553D3C06175F for ; Mon, 5 Jul 2021 05:32:41 -0700 (PDT) Received: by mail-oi1-x235.google.com with SMTP id q23so20534728oiw.11 for ; Mon, 05 Jul 2021 05:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ayC9wq9/e6ZjI7NP5sAlNgcHa3z34mOfxvtAayujs/M=; b=D3BldIVnA8GjeEUMYLD3mn/Rlog3oxpctQCLEHsBNzuXcTgDREdVBFG3/qk+lZMltd zHIAERjTriYX7EfI753PeTcW2zh8mrnJaQx3qszLrZjyKQb5rdZ8PNIERpUaV1kJsPGz FxTUQ34VQ6hldQDvTtMQmpypxwoSmmyoIW+Bt/I19Hkpnvd6yy3nn5eiBlYgdUNyQThF BnSSYZWomOnyZOqJUD4f1MlVjWbHswj+PTCTRzXlEMOasbYroLJCI7+wPt5k52/KDn7i eLhDWTWpXrzWXUvA+x44c5NPVW3GQrW9gGl40qG6D/CBMdEomMWBM/6rGOEUDNbFjeGx GPMQ== 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=ayC9wq9/e6ZjI7NP5sAlNgcHa3z34mOfxvtAayujs/M=; b=FuvQnHfwCneqo/U4FcR8d2+XIUAaz1XC458HHzZgD0C+CGdU0HhEyDnelB7QjYHVFn B//1Ubd7dbPBTUEoiCoYviTg31Bi/+64DOaSs0EKJYxqpwi5rwkv4Oad6ktLQR4Wxs8Q HKbjQi4TiJw6d6TfpYVAdrQ0kZ5N0nXMH1AMvMe/EBYZNmYhcT7q0Ktby0+P67LnArPK Ru7Fs5Tx1pRKxm/8mkiiQ7q5LEEZ5G8u66+knm0jAKSl6h+ou+daWFz7lsYgpmKTWEng jxq0qQjRIqxtgc9ksLt0SbTmVaqvz7z9H8sg3ZXPrINwQznXY9bvHBJ9IW+Wnrzfd3tw Vnhw== X-Gm-Message-State: AOAM532sBlvrlfB3+knv2ftSpGy3RJSj5su+pNTQwEhSEgV5DTbOF6SO o+PThGBb6kBRNBC4JNxToN3QB/hUTHUM8w== X-Google-Smtp-Source: ABdhPJyIT1P+B99JWsCcjqIyYafZNycYw8y7wcu+dLRlcE88ohhnuPVc0Ruz39PoNn5M0uLsHn8UQA== X-Received: by 2002:aca:4482:: with SMTP id r124mr9714611oia.153.1625488360531; Mon, 05 Jul 2021 05:32:40 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id v203sm2674588oib.37.2021.07.05.05.32.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:40 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 17/35] update: add mode configuation Date: Mon, 5 Jul 2021 07:31:51 -0500 Message-Id: <20210705123209.1808663-18-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/config.txt | 2 ++ Documentation/config/update.txt | 4 ++++ builtin/update.c | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 Documentation/config/update.txt diff --git a/Documentation/config.txt b/Documentation/config.txt index fc4b49c0d4..998339e6fd 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -466,6 +466,8 @@ include::config/trace2.txt[] include::config/transfer.txt[] +include::config/update.txt[] + include::config/uploadarchive.txt[] include::config/uploadpack.txt[] diff --git a/Documentation/config/update.txt b/Documentation/config/update.txt new file mode 100644 index 0000000000..42a7fe1614 --- /dev/null +++ b/Documentation/config/update.txt @@ -0,0 +1,4 @@ +update.mode:: + When `git update` is run, this determines the mode of operation, + possible values are 'fast-forward', 'merge', and 'rebase'. The default + is 'fast-forward'. diff --git a/builtin/update.c b/builtin/update.c index 989104421e..4a1b82a41d 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -5,9 +5,11 @@ #include "builtin.h" #include "parse-options.h" #include "run-command.h" +#include "config.h" #include "dir.h" enum update_mode_type { + UPDATE_MODE_INVALID = -1, UPDATE_MODE_FAST_FORWARD = 0, UPDATE_MODE_MERGE, UPDATE_MODE_REBASE @@ -34,6 +36,28 @@ static struct option update_options[] = { OPT_END() }; +static enum update_mode_type update_mode_parse_value(const char *value) +{ + if (!strcmp(value, "fast-forward")) + return UPDATE_MODE_FAST_FORWARD; + if (!strcmp(value, "merge")) + return UPDATE_MODE_MERGE; + if (!strcmp(value, "rebase")) + return UPDATE_MODE_REBASE; + + return UPDATE_MODE_INVALID; +} + +static int git_update_config(const char *var, const char *value, void *cb) +{ + if (!strcmp(var, "update.mode")) { + mode = update_mode_parse_value(value); + return 0; + } + + return git_default_config(var, value, cb); +} + static int run_fetch(void) { struct strvec args = STRVEC_INIT; @@ -87,6 +111,8 @@ int cmd_update(int argc, const char **argv, const char *prefix) if (!getenv("GIT_REFLOG_ACTION")) setenv("GIT_REFLOG_ACTION", "update", 0); + git_config(git_update_config, NULL); + argc = parse_options(argc, argv, prefix, update_options, update_usage, 0); if (repo_read_index_unmerged(the_repository)) From patchwork Mon Jul 5 12:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC3EEC07E9B for ; Mon, 5 Jul 2021 12:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6B50613AB for ; Mon, 5 Jul 2021 12:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbhGEMfU (ORCPT ); Mon, 5 Jul 2021 08:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbhGEMfT (ORCPT ); Mon, 5 Jul 2021 08:35:19 -0400 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 130A1C061764 for ; Mon, 5 Jul 2021 05:32:43 -0700 (PDT) Received: by mail-ot1-x32d.google.com with SMTP id l17-20020a9d6a910000b029048a51f0bc3cso6383570otq.13 for ; Mon, 05 Jul 2021 05:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zxlnXlmf6ztfJzYZzdLZDHPR1dy55OG9f/FuBrGPtdI=; b=g3+K7AfhMPAElFD+1h1y78usK5J9MzLOutcYB2Tx8KA0DwBCl6JfTwxH3e0mOonZFg +yxtzci+F7Jf95q8r4POMmkCrJVKo1Y78IBEqVqEG20pT1CSlg2R2AMVJeH89LfW2wi8 amJwo+4fMHOl4bIcuxFzdR/c3dot2MJqGymk7q/vcukmq2DuccEZyDHU3hiz5Glz4Omt VwZUaA2c/HYgr7QxtPgji3178NiXNsy4I4IYqrdFpB2Otylu892qfNmR4AOzhJqdJCjU qiISyxniZ4ngvhS24dImwTOoOyM2YnW3fzzHrql/xQ66pcas8QAOJnDsIVNQwpq2FlkO yRVQ== 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=zxlnXlmf6ztfJzYZzdLZDHPR1dy55OG9f/FuBrGPtdI=; b=cifc0Cic8R9gn6Y/Ni4cOivoIrOOkGMQv0tV57RYNa4Ry0noQ3vB/GGBSP58CbneMj L0Qy2txfXiWq2f4m0xuMHYqHE3agLySWH11YLlUO0vmmcYcfJQvaO4HvfCjwOkQPPzON WgKJIH7WbfCIgEs+gL53aE0fDfpkk2FyODxm481OexNx52CjU8p8dQ7TMo71SY5jPIMj 4eUGwUckI7cF+AXYD8N/UBeGSosKIo9KZVRpo7b3zInOF/lq44+BlhspYuVIc5cyleTz mM0HErdhvG1tvGuJNz1toz9A2cpVJjtidBEp/BTbigbBv1F1tjH8s89ia/aJ+QTAjrqV fdRg== X-Gm-Message-State: AOAM531bWal1PIP07mOuTxNyn6y0zHv/HtJw9Djof+MAdNUat9baU/3K bYccMatM3O+fyDct3sXQuZ3QQXu66+uQoA== X-Google-Smtp-Source: ABdhPJxewuasYOFz4vp0IvTrBfgbg9GMF2X3QS0hXDpdwko1lH04tR8Hh11olpj0vcpNR+t9CGT/ZQ== X-Received: by 2002:a9d:4c97:: with SMTP id m23mr10348706otf.354.1625488362265; Mon, 05 Jul 2021 05:32:42 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id f19sm2186451oou.22.2021.07.05.05.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:41 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 18/35] update: add per-branch mode configuration Date: Mon, 5 Jul 2021 07:31:52 -0500 Message-Id: <20210705123209.1808663-19-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- Documentation/config/branch.txt | 5 +++++ Documentation/config/update.txt | 3 ++- builtin/update.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index cc5f3249fc..ba355f23e0 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -96,6 +96,11 @@ mode. it unless you understand the implications (see linkgit:git-rebase[1] for details). +branch..updateMode:: + When `git update` is run, this determines the mode of operation, + possible values are 'fast-forward', 'merge', and 'rebase'. + See `update.mode` for doing this in a non branch-specific manner. + branch..description:: Branch description, can be edited with `git branch --edit-description`. Branch description is diff --git a/Documentation/config/update.txt b/Documentation/config/update.txt index 42a7fe1614..e6db45b6c3 100644 --- a/Documentation/config/update.txt +++ b/Documentation/config/update.txt @@ -1,4 +1,5 @@ update.mode:: When `git update` is run, this determines the mode of operation, possible values are 'fast-forward', 'merge', and 'rebase'. The default - is 'fast-forward'. + is 'fast-forward'. See "branch..updateMode" for setting this on a + per-branch basis. diff --git a/builtin/update.c b/builtin/update.c index 4a1b82a41d..50905f5806 100644 --- a/builtin/update.c +++ b/builtin/update.c @@ -7,6 +7,7 @@ #include "run-command.h" #include "config.h" #include "dir.h" +#include "remote.h" enum update_mode_type { UPDATE_MODE_INVALID = -1, @@ -58,6 +59,22 @@ static int git_update_config(const char *var, const char *value, void *cb) return git_default_config(var, value, cb); } +static void get_branch_config(void) +{ + struct branch *cur_branch = branch_get("HEAD"); + char *key; + const char *value; + + if (!cur_branch) + return; + + key = xstrfmt("branch.%s.updatemode", cur_branch->name); + if (!git_config_get_value(key, &value)) + mode = update_mode_parse_value(value); + + free(key); +} + static int run_fetch(void) { struct strvec args = STRVEC_INIT; @@ -112,6 +129,7 @@ int cmd_update(int argc, const char **argv, const char *prefix) setenv("GIT_REFLOG_ACTION", "update", 0); git_config(git_update_config, NULL); + get_branch_config(); argc = parse_options(argc, argv, prefix, update_options, update_usage, 0); From patchwork Mon Jul 5 12:31:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2C06C07E99 for ; Mon, 5 Jul 2021 12:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA8C2613AB for ; Mon, 5 Jul 2021 12:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231388AbhGEMfV (ORCPT ); Mon, 5 Jul 2021 08:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231317AbhGEMfV (ORCPT ); Mon, 5 Jul 2021 08:35:21 -0400 Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9411C06175F for ; Mon, 5 Jul 2021 05:32:44 -0700 (PDT) Received: by mail-oo1-xc2f.google.com with SMTP id s10-20020a4aeaca0000b029024c2acf6eecso4426306ooh.9 for ; Mon, 05 Jul 2021 05:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n3nDhOz0tRDLaE4sAr6KDfIcnW3qkms9yGWANOVj9k0=; b=k8nNRStoi02YkrauAdhl48YiDUGORzkAOeRAoffIZtnXdFJx9SWm5LdaCV99OC5AG1 CJb48JGDScVkUJdkny80HuQE44aw5F0aLCvv+VVbVprPlBwxWoXeHav3xLZP3B8Lk+s3 oexaXufCm37483nwDg471LUJ44DRVYkwhUFW+mv0VE36uFpnOJIYVysq70++i4NBp6ky Z7aNBuu56aZss4j7wcs4YP7kP8FIx0Y/rijeOq0urx3xqqOI36LXUBzr4SYmC0jwpUWj ZLzzA1+PDkOOlC5g7DOCc3EusPhQp9k/jbFUToSMmfZ3C8LX2ga5mz0bGpg6Goupx3fY 5+ww== 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=n3nDhOz0tRDLaE4sAr6KDfIcnW3qkms9yGWANOVj9k0=; b=OyqOtfaZYFJ/X8pGPg3o/sHyTY29tmmx0YeWke/CzOzlr1hBU8IOVrKNUCBRphew2H 1L83q4YNLN0a18sWbwDobPDRrMqzEi7mfx3Ryvn8OvIE1V0o8C+oeq6I3x4ZZGet0mEi p/VH5P8YtPywZRpS7v+y+Q1szcTrjmE8cN4TdG3K3HwTFR9Fp441JHM7wWtFEtR5/wct uS5WpX2E7ZAmMkgFpCTMY5vfjTPwcMMu6FX3XlBSVUwtFUcdvFPnHE6iUT16GEj72TRE D8mdtvEaziOgYuFfzJYlLBYWyzzGU1THaA+bxIVZhumN9+JhWGoyHz4qNORz7oXc23aw xqBQ== X-Gm-Message-State: AOAM532S4aecTWbDkSrzvYsx3Ne9AS2HQEsfVpdSCH+c9zZLxsdTGKGq Gt7mjjD9YRCRxdfAiyIaDFHAdNi7yrxIyg== X-Google-Smtp-Source: ABdhPJySQUg6rOSpZXNflHTDbhPvIG/VvHJwn/9d9vcihnQSKcHkXrilXpLRrcaDPC5IKjfnDXnHQA== X-Received: by 2002:a4a:9fc1:: with SMTP id b1mr9839882oom.51.1625488364030; Mon, 05 Jul 2021 05:32:44 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id y193sm2694840oia.48.2021.07.05.05.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:43 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 19/35] pull: cleanup autostash check Date: Mon, 5 Jul 2021 07:31:53 -0500 Message-Id: <20210705123209.1808663-20-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-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. Signed-off-by: Felipe Contreras --- builtin/pull.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e8927fc2ff..a22293b7db 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -947,7 +947,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) struct oid_array merge_heads = OID_ARRAY_INIT; struct object_id orig_head, curr_head; struct object_id rebase_fork_point; - int autostash; int rebase_unspecified = 0; int can_ff; @@ -982,8 +981,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (get_oid("HEAD", &orig_head)) oidclr(&orig_head); - autostash = config_autostash; if (opt_rebase) { + int autostash = config_autostash; if (opt_autostash != -1) autostash = opt_autostash; @@ -1065,13 +1064,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) && submodule_touches_in_range(the_repository, &upstream, &curr_head)) die(_("cannot rebase with locally recorded submodule modifications")); - if (!autostash) { - if (can_ff) { - /* we can fast-forward this without invoking rebase */ - opt_ff = "--ff-only"; - ran_ff = 1; - ret = run_merge(); - } + + if (can_ff) { + /* we can fast-forward this without invoking rebase */ + opt_ff = "--ff-only"; + ran_ff = 1; + ret = run_merge(); } if (!ran_ff) ret = run_rebase(&newbase, &upstream); From patchwork Mon Jul 5 12:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B05C4C07E99 for ; Mon, 5 Jul 2021 12:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99C5D613AB for ; Mon, 5 Jul 2021 12:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbhGEMfX (ORCPT ); Mon, 5 Jul 2021 08:35:23 -0400 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 S231359AbhGEMfX (ORCPT ); Mon, 5 Jul 2021 08:35:23 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63184C061760 for ; Mon, 5 Jul 2021 05:32:46 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id r29so4177374oiw.13 for ; Mon, 05 Jul 2021 05:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f/XjHp84gR4nhhd/wr7xj9B256dmgyCzuJvw0eFg7QM=; b=AauQqA6JbMkgUT9c2O22ffCIsgGdge1uHCANK7fIW/u2YpQwRtTT5/BZptjdAox/FK gFDRlbEepngJsI2A9fDbp3lsbftBn0pIb+7xQER3LhwFHJ5yxwiQ/YEj6z4Ntpc36TtP K51w5f6sW8b98cEp16JE/2tmfH3J6XtTxQOvx5FhMB1npyuxlLEGQqNmquV6ImaxK4IN sITMQqko/522xobw6qeOs1QM8jr9K4WYNEzeGHsfq+LvAg2u6dFl9+j9pnsCeXoe/EFv 4s/K/7T59NRCea5y93xS6dEGByW7pl05PnlpIXS7a24eL71tkst+nvG8My2/JwBXl188 JFkg== 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=f/XjHp84gR4nhhd/wr7xj9B256dmgyCzuJvw0eFg7QM=; b=GeDwtCOsRxSgjA/Y1nvq1ICONaCeN9IiDVCaA/lP87cmSrVNS6bIQlVMPAf2hbr65Y Vhv3h4qAsNelolUzZzR0t36lMFiLZdZ45E0iXaMj5aK7Zeh6mwqZwC4oN0xeaIubXQ26 X7qBcHQFVL+WXM0ZNRL+tb4Gjt5Vrg6yU1s3gb+WnGyYfMlbxm57XUnv6CsuLyHQU19G JJHgosQBTBWN5ohqCeElU04X6RGVQ8YyyZB7A2Ws+RrlziOzUOjgR9oSKML269DSSpcQ aVoiS1m22T0OSVmQHQJxXyYkE21sKr9lulFZN9q7hv+u7VpBb8UNFMYfIWdOrCBxdZQT xDIA== X-Gm-Message-State: AOAM5316/YXQCZCqYswO8tOY9BnoYscnOfg4GfUBiys6ey5s0jvYD9hQ dXInPmckwRx/w6yhy1IopCXX8RIJ0lalIQ== X-Google-Smtp-Source: ABdhPJzYI86GeMxxu+E9EDoo/eP+PzfvseLyaBkIrAbdHed1NyXmfjrNlzf84MrNR5gDBauAz94quA== X-Received: by 2002:a05:6808:15a6:: with SMTP id t38mr10326275oiw.157.1625488365631; Mon, 05 Jul 2021 05:32:45 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id n20sm2609036otj.11.2021.07.05.05.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:45 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 20/35] pull: trivial cleanup Date: Mon, 5 Jul 2021 07:31:54 -0500 Message-Id: <20210705123209.1808663-21-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no need to store ran_ff. Now it's obvious from the conditionals. Signed-off-by: Felipe Contreras --- builtin/pull.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index a22293b7db..80e2f55cbc 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1053,7 +1053,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (opt_rebase) { int ret = 0; - int ran_ff = 0; struct object_id newbase; struct object_id upstream; @@ -1068,11 +1067,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (can_ff) { /* we can fast-forward this without invoking rebase */ opt_ff = "--ff-only"; - ran_ff = 1; ret = run_merge(); - } - if (!ran_ff) + } else { ret = run_rebase(&newbase, &upstream); + } if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON || recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)) From patchwork Mon Jul 5 12:31:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82A99C07E99 for ; Mon, 5 Jul 2021 12:32:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B6DF613AA for ; Mon, 5 Jul 2021 12:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbhGEMf0 (ORCPT ); Mon, 5 Jul 2021 08:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbhGEMfY (ORCPT ); Mon, 5 Jul 2021 08:35:24 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 282C6C061765 for ; Mon, 5 Jul 2021 05:32:48 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id 11so20616851oid.3 for ; Mon, 05 Jul 2021 05:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EXJlkMkYlqVSJ9c2kxvJ+Ii7Dm2ffiHE84wGkLqv9TI=; b=aTvaHjYuHqHBPk2JgE3qae+tiKc/wTXGxSzyQy2l+Fe7AD51s5Hza1SW9/gMhed2Cv zgjBn/Xi2rbYHN05UtjL7Ib4lDDUGRos09tJT44UHNItFjw4E0QoedWW+bB5Av0qoqoJ VhDHfLVYr8OfD2WlOuwtEmGP8p+i3Qii9tgWKke//nyhndHFmd8dD9Wk3bSgJFmLsI5C ctb7GMBruO4th8bcSr+OoPxDh+ZbJqyAwu/GO7AU2qC2b5Ew6Gdd7WoPjBvHHXFP96mo 7JQ+5OZFRYBnDp+Sf3HcEcVt3nxN0O7Da17AbHWCVmsxSsUkpxC+WZNvqQs3zyod+Atv Q5BQ== 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=EXJlkMkYlqVSJ9c2kxvJ+Ii7Dm2ffiHE84wGkLqv9TI=; b=dP22CBjFwS0cICrF8R8ByVsi0mVpoWgMHhUUHLfaY+s4LgE1Iasndy45eWVj0my72G bFKXXU0G8SoskFBeDULNJI+6SvzZPJOol/BQ9eiQ27FoP+Vc50GYq9tzYbVL1sB58KFp +onmWaL2QT2CguSpTsZ0qH+AqHwA1XmI9HzDpXARsDSKm5fO0PXqzyPe2T3gAi9NhJi5 /ShR2+DTdA2w2cbvTMbVFRCxeQcEMGDeEpcYtWfM0jLTstmZchTz7L2N3uiiqAQHZ3/h ZZCiG1WzIaGAbUpFa9AZzwY/3pv6jENsl7/dA4pQK37AF1EWdOhuxwJU8db35ek7qSo8 w8lw== X-Gm-Message-State: AOAM533yayg6ZQpfrbom4wia0e5iig0TxnU/wsgrE5/5jKW9KKsKU8wQ PEkTxQsV/1kRd1J+qthIyWzgZjMtbUFrIA== X-Google-Smtp-Source: ABdhPJzo5GUlAIfcY/GfEk/sT5GdY3PAw1UJsUu3q8S1RCXOodEXTEbvo/GWnwXJHRwb39Kw3sCEMQ== X-Received: by 2002:aca:3147:: with SMTP id x68mr10130303oix.126.1625488367354; Mon, 05 Jul 2021 05:32:47 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id 59sm2600548oto.3.2021.07.05.05.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:46 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 21/35] pull: trivial whitespace style fix Date: Mon, 5 Jul 2021 07:31:55 -0500 Message-Id: <20210705123209.1808663-22-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Two spaces unaligned to anything is not part of the coding-style. A single tab is. Signed-off-by: Felipe Contreras --- builtin/pull.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 80e2f55cbc..3e13f81084 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -126,9 +126,9 @@ static struct option pull_options[] = { /* Options passed to git-merge or git-rebase */ OPT_GROUP(N_("Options related to merging")), OPT_CALLBACK_F('r', "rebase", &opt_rebase, - "(false|true|merges|preserve|interactive)", - N_("incorporate changes by rebasing rather than merging"), - PARSE_OPT_OPTARG, parse_opt_rebase), + "(false|true|merges|preserve|interactive)", + N_("incorporate changes by rebasing rather than merging"), + PARSE_OPT_OPTARG, parse_opt_rebase), OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL, N_("do not show a diffstat at the end of the merge"), PARSE_OPT_NOARG | PARSE_OPT_NONEG), From patchwork Mon Jul 5 12:31:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F47FC07E9C for ; Mon, 5 Jul 2021 12:32:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EDFA613AA for ; Mon, 5 Jul 2021 12:32:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231415AbhGEMf1 (ORCPT ); Mon, 5 Jul 2021 08:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbhGEMf0 (ORCPT ); Mon, 5 Jul 2021 08:35:26 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3967C061574 for ; Mon, 5 Jul 2021 05:32:49 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id 11so20616906oid.3 for ; Mon, 05 Jul 2021 05:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QO47CqSagNIZgSICHTMXjdoSnRTs4R6eFSe5BJm0jHc=; b=KW00ibwmVVsbjvBQ/L97gdS+DaBy0f6b79gc/28i7YHKJ6E3Q5PzEsXkhwf0AqhtEH Tmumfe1JYs7gRhneUWepPkpQMoo8bcx0IvrJtjtMTGC2w2PNE/xrdqFmBU+LysuLklK3 9wLrsdxrGEiCzi072fQf+hh9baE872mnalRl9r5U/aGh6Bc3gUfjYeymI1z0heijvwTv WBBXMFi+mqZfTh3gku8EKCZRdUc2R6zqQhLwq9uXQTQGpmObzVipSHfWJ2RpVBSfKNRi kcL3qM1ZnLNa1GAvEdx5l7p5bhpL9zAgS+tUlvZX9iLUIGra/6OTI5RHIO525r+WalEt iojw== 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=QO47CqSagNIZgSICHTMXjdoSnRTs4R6eFSe5BJm0jHc=; b=lh8YBaa2xGngYLn7Mnv6RY4wUIG2jXX3TDQpmTZrjBbgTNYDHUckiZKAICR/xcsJgB lVr1Qu2/+MLqPRnx/K4wEJoaGQ0T415txlRrRjFKLQs4pu6ZPjVECUPsCR32xEsCsoHe NVmGXv+w+mR2VMyS8O5wfU+wfd+SMQxUNpddWflzBqYvWP4eW4e4yDipJTzHePAji1Ak rHVbjSQwELz/x/v5v4dz6T2MM8APjAPYyC46nbb5XYmentvsktKGZQPJQxdB/FtFTuhk SU+d37kXVM0CjQz0QROD9gqka2ohJI6rKpbwgENGoBRWHhbh7VpZLzcp/1NLzh18drjX L/hQ== X-Gm-Message-State: AOAM531WffLSV33WqUTFcg177S9Y/Oqbgu0T2QixYQA9d4ztyYWpRsFd HgVLjHt9tqhQ31mJ4NFYAIHjU2h2KEKKLw== X-Google-Smtp-Source: ABdhPJy/3WjV/H2TyH4NXaH8gPvBzHXJR31QiFN+qhonxBRBvAom978ctAyPqYFEby5pZo56RF7IgA== X-Received: by 2002:aca:bb41:: with SMTP id l62mr9773404oif.113.1625488369002; Mon, 05 Jul 2021 05:32:49 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id p18sm2586327oth.60.2021.07.05.05.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:48 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 22/35] pull: introduce --merge option Date: Mon, 5 Jul 2021 07:31:56 -0500 Message-Id: <20210705123209.1808663-23-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Previously --no-rebase (which still works for backwards compatibility). Now we can update the default warning, and the git-pull(1) man page to use --merge instead of the non-intuitive --no-rebase. Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 7 +++++-- builtin/pull.c | 4 +++- t/t7601-merge-pull-config.sh | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 5c3fb67c01..d23128fa72 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -131,8 +131,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 3e13f81084..0d76b54186 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -129,6 +129,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), @@ -936,7 +938,7 @@ static void show_advice_pull_non_ff(void) " 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" + "preference for all repositories. You can also pass --rebase, --merge,\n" "or --ff-only on the command line to override the configured default per\n" "invocation.\n")); } diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 52e8ccc933..6d03e0b9fe 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -60,9 +60,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 c0 && - git pull --no-rebase . c1 2>err && + git pull --merge . c1 2>err && test_i18ngrep ! "Pulling without specifying how to reconcile" err ' @@ -119,9 +119,9 @@ test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' -test_expect_success 'pull.rebase not set and --no-rebase given (not-fast-forward)' ' +test_expect_success 'pull.rebase not set and --merge given (not-fast-forward)' ' 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 Mon Jul 5 12:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 006FBC07E9B for ; Mon, 5 Jul 2021 12:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0354613AB for ; Mon, 5 Jul 2021 12:32:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbhGEMf3 (ORCPT ); Mon, 5 Jul 2021 08:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbhGEMf2 (ORCPT ); Mon, 5 Jul 2021 08:35:28 -0400 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD3FC061574 for ; Mon, 5 Jul 2021 05:32:51 -0700 (PDT) Received: by mail-oi1-x229.google.com with SMTP id u11so20612025oiv.1 for ; Mon, 05 Jul 2021 05:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Af52J6U3Q6JrsFdXd3iebD1QolicSqph543lfeYQaA=; b=ZK4Eu6Msr2CLj3p5gTQVUMHYod4Ie9JTHWWLmee/gx36u0BOw/1dcW/HAYdLg2iay0 gbgpMPN9empE+AQOLVaGz4nbtb+V1WGlWbYfY9WDhoBXrozWYaxn47XGFgiWvMrwED4F qBHtXGlTx7o93h7qGQYfy67Rz7CTJ/HOlCv+zbdlEsg4CsqaVXezZgXectyaCtpFw8GK yD9+21od99uZKGkY52HXyMBjjMjS9SAWS8uKSWAUg7uvxHlTgg0O9ziEIoWgJgDNijM8 wIXB6r/a2vQyF5FLWjw2LeTyic68JYPnuf5PAzwfu+OPShVvki1WeHHBAVe+cyLljskn BRow== 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=2Af52J6U3Q6JrsFdXd3iebD1QolicSqph543lfeYQaA=; b=uN7Cdlq7Vif3eT9nju0J5w0vDFN11fEEhDx4Q/3ygZjUgxL308XsP8E/CrKHt9Tabo mJuQhH1lEhwboTNzCWV9Q7eNxCBnDbe9Ge8VmV4MgCL/rnUnQSkqcM1of4bt3HyBZqI9 AFmrjAE6+UjNCoe4IvUzXqNfr9idF6pHbiActKRLKvJABun+Xs7HGy/uhLyfYBO8p5FE Gh1IFj/MlvzvFdQIrofMhigbxlfD00T5GP7AeLotK/LOzT57vgGpMQNSVJE9ZVC0U9gS AFMyBSCf+snSjPrehmJPyuaafO2ILt1KI+X6I+yqDxzUeQtHiht4ikXH4KJJ8ygu6liW +qaQ== X-Gm-Message-State: AOAM531A/UC6libvbSSh2ipXJ9rhMor5pfYJKz4jUkXiRUkRtxwVnVyS 3wPGNldh5oVPP1woRKn9QJ38qWdXrWsujw== X-Google-Smtp-Source: ABdhPJyfwq5LgUGjJUkkBfXYxITDhEccjOQILYdUbqWxO4podTGRWOtIAnvvsYJ0LRtHrTmX+K/nDg== X-Received: by 2002:aca:4541:: with SMTP id s62mr10129777oia.156.1625488370804; Mon, 05 Jul 2021 05:32:50 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id f3sm2683925otc.49.2021.07.05.05.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:50 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 23/35] rebase: add REBASE_DEFAULT Date: Mon, 5 Jul 2021 07:31:57 -0500 Message-Id: <20210705123209.1808663-24-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-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 pass around an extra variable variable (it's the same as opt_rebase == REBASE_DEFAULT), nor is there any need to initialize opt_rebase to an invalid value. Additionally this will allow us to override the default with a configuration, and subsequently the configuration with arguments. Cc: Junio C Hamano Signed-off-by: Felipe Contreras --- builtin/pull.c | 27 ++++++++++++--------------- rebase.h | 3 ++- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 0d76b54186..94fc8b0739 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -74,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; @@ -326,7 +326,7 @@ static const char *config_get_ff(void) * looks for the value of "pull.rebase". If both configuration keys do not * exist, returns REBASE_FALSE. */ -static enum rebase_type config_get_rebase(int *rebase_unspecified) +static enum rebase_type config_get_rebase(void) { struct branch *curr_branch = branch_get("HEAD"); const char *value; @@ -346,9 +346,7 @@ static enum rebase_type config_get_rebase(int *rebase_unspecified) if (!git_config_get_value("pull.rebase", &value)) return parse_config_rebase("pull.rebase", value, 1); - *rebase_unspecified = 1; - - return REBASE_FALSE; + return REBASE_DEFAULT; } /** @@ -443,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.")); @@ -456,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.")); @@ -471,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.")); @@ -949,7 +947,6 @@ int cmd_pull(int argc, const char **argv, const char *prefix) struct oid_array merge_heads = OID_ARRAY_INIT; struct object_id orig_head, curr_head; struct object_id rebase_fork_point; - int rebase_unspecified = 0; int can_ff; if (!getenv("GIT_REFLOG_ACTION")) @@ -971,8 +968,8 @@ 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) - opt_rebase = config_get_rebase(&rebase_unspecified); + if (!opt_rebase) + opt_rebase = config_get_rebase(); if (read_cache_unmerged()) die_resolve_conflict("pull"); @@ -983,7 +980,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; @@ -1043,17 +1040,17 @@ 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 (rebase_unspecified && !opt_ff && !can_ff) { + if (!opt_rebase && !opt_ff && !can_ff) { if (opt_verbosity >= 0) show_advice_pull_non_ff(); } - if (opt_rebase) { + if (opt_rebase >= REBASE_TRUE) { int ret = 0; struct object_id newbase; diff --git a/rebase.h b/rebase.h index cc723d4748..34d4acfd74 100644 --- a/rebase.h +++ b/rebase.h @@ -3,7 +3,8 @@ enum rebase_type { REBASE_INVALID = -1, - REBASE_FALSE = 0, + REBASE_DEFAULT = 0, + REBASE_FALSE, REBASE_TRUE, REBASE_PRESERVE, REBASE_MERGES, From patchwork Mon Jul 5 12:31:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12358999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 335B4C07E99 for ; Mon, 5 Jul 2021 12:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20109613AA for ; Mon, 5 Jul 2021 12:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231421AbhGEMfc (ORCPT ); Mon, 5 Jul 2021 08:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbhGEMfa (ORCPT ); Mon, 5 Jul 2021 08:35:30 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DC56C061762 for ; Mon, 5 Jul 2021 05:32:53 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id s17so20658107oij.0 for ; Mon, 05 Jul 2021 05:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dlSBBpeyaba2XyM+CDEBgPK8YEt+XD//eJWCQdAasCo=; b=HYl8DQNT1jiJif4Bn4zY7wh0bhgqr1iVA2V3i4MZ20vbEFdrxIgitemGDuhz5bYvX0 uPSRbTJ0XkSq4SjIB7LIvMfKvTmVwrhDgoK0etDpT4QqNLjHzPBKa4aybUN/SP/ByvKo JONkZx+Gakrao2VYyHgHCChQct2r7Jnf6OIF5psZ0fOwwyCr7Np89yv617aXhf9JDorz vsyQ8hWjL4QWnY2rXUJBvz1z8bYzrdS7zhveaBvqwNZocninqCMut21CIsTQYxQaPGbf KBcgWBwY18PwzMxeIHtQbC82FYPM5NWLqyO1wQhvJPAT7Hm9QxmX4m7mUSyaBiVkOHk8 7IqA== 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=dlSBBpeyaba2XyM+CDEBgPK8YEt+XD//eJWCQdAasCo=; b=shcE2sy4bzSvOwE7JJcen67xQHT/bKIjdOCZSXWNfV0UdCOaPvpPogqFzOCnnGBtaF 9OMQ1hZMyBvlng5QSxNok6eZA563kHgXhhap0KDToN5wFViDz6DgjKH0CFAroCh4KMyq dYRXfO4EOpB4/g7nJ8qnGXqfViv8qcSdq7C14/4PY7bYuOUYAUlIHy1OJ3drIWE/PYDl eoaK6MrtS8B57yBA7iTkOzHdmcd/phH42stQmTRb/nVE9Og+jcsQfk8CAiMOHDdOnDi3 XccCg/0NjViNGit8nnjqZd+n8FCHst4WQeyl1gaq4Wfj81SYHDoUJhuZjowAhPDIL8jA RVNA== X-Gm-Message-State: AOAM530ivF61XF+YpTkGhR7wuAaStpUaCuX6+/Vf8wYRulG2EQXNApYs svkFTbU8cwrPHiWPzOs0PrtZ8JZlvG5+/A== X-Google-Smtp-Source: ABdhPJz/gE0i00dvmn50CX6WBN7V0kjvUVASIbm4+e3FxkdK9RQiSgYHX0VBEVhNLSvoiUJA1moSqQ== X-Received: by 2002:aca:618a:: with SMTP id v132mr10070031oib.144.1625488372536; Mon, 05 Jul 2021 05:32:52 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id l7sm2619325otn.80.2021.07.05.05.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:52 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 24/35] pull: move configuration fetches Date: Mon, 5 Jul 2021 07:31:58 -0500 Message-Id: <20210705123209.1808663-25-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we have REBASE_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 REBASE_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 94fc8b0739..61af8ea2cb 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -949,6 +949,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); @@ -965,12 +968,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 Mon Jul 5 12:31:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA80BC07E9C for ; Mon, 5 Jul 2021 12:32:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93C49613AA for ; Mon, 5 Jul 2021 12:32:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231401AbhGEMfc (ORCPT ); Mon, 5 Jul 2021 08:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbhGEMfb (ORCPT ); Mon, 5 Jul 2021 08:35:31 -0400 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 233FFC06175F for ; Mon, 5 Jul 2021 05:32:55 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id h9so20607744oih.4 for ; Mon, 05 Jul 2021 05:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=56B58ZKb0REYSNPSVm4zhHzHtjpWoxQSwtDzOcmhUxw=; b=OhJqsYnavErF5b0QQf7rXrde4QPe2jm8m0dez2zEq6n8Obm4kvgchBpRhT0TrVaamv Pe727D6lr6wwXqDRLy5qqXOGiu1pwXS13ojrk2HQLIOi7k/BbOOtCnv9hjpNOyPGZCLv 38N5jlt63E3GTdMOdkCC+lLrKOT4Xzi1B/HlPTHXNxYPCcamwz/3OsWW3J6/P/h3BZg7 TThwIHkqTD59h5LxNFmYnZoJtxt19w+W1jb6CkdHNE5xpJY5I/ilO07QiHFIWO167x6v cZcNUydW7RPFpIfA2OXydSOYleWaSUW4/1xe5bufIyafdSlUD/dtc5+DWjK1RRVz9GCu OG5g== 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=56B58ZKb0REYSNPSVm4zhHzHtjpWoxQSwtDzOcmhUxw=; b=FiDN1x8WFI33+9/exE8JxmfcEGKbKxpYbBpsKBpg9ZmV70rU6FzxXL136JERhzCOdp QJSPogvQO3WhicThzgzJOr4QjCW7WThSV0cQoQ1OVWefUuSShm/R6bsXnaDoPx8MhkDh UTo3uE/SdNHbzHCwN2iOpLHfzKOmrGhimgLo9N761IFiSe22iuXyBrdzy/fH1ettHXHv xIvJw43cXSe8z/Vyq4k1cCpj+XlV3Nalfj5Oezg5v1JzPZVRQPd+tpZ3w6Zry0ZI2Obz AMbuiY6ls+Kn3hryM+JwnIiUOVnOsalRWPkTQp5Wmf8XLTSL15MTfGQUF13dljD1la+S l5pg== X-Gm-Message-State: AOAM533p2eYwYhKrb9A4d/3QwxaV+fRpjtaeRuNkArEFWBkYPEJoAQZ9 Sr+VTc/RvMQ3SPp1OuMhztJXA/fPk9RAMA== X-Google-Smtp-Source: ABdhPJxAvfwszFtD1VstTqfVCSzwkoHPCMsl+vcZbN4QkLmw36pycTReA4zd1RJTiT1JmVIsbY0T7g== X-Received: by 2002:aca:1809:: with SMTP id h9mr10204049oih.4.1625488374260; Mon, 05 Jul 2021 05:32:54 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id s131sm2624797oib.52.2021.07.05.05.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:53 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 25/35] pull: show warning with --ff options Date: Mon, 5 Jul 2021 07:31:59 -0500 Message-Id: <20210705123209.1808663-26-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We want the user to specify either --merge or --rebase, if she doesn't we throw a warning. Using --ff, --no-ff, or --ff-only does not make the merge explicit. For example, if the user has the following configuration: git config pull.rebase true git pull --no-ff A merge is not implied. We should be consistent and either imply a merge--in which case a previous "pull.rebase=true" configuration is overridden--or don't--in which case the warning should be thrown. Signed-off-by: Felipe Contreras --- builtin/pull.c | 2 +- t/t7601-merge-pull-config.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 61af8ea2cb..2c2f0822d5 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1042,7 +1042,7 @@ 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 && !opt_ff && !can_ff) { + if (!opt_rebase && !can_ff) { if (opt_verbosity >= 0) show_advice_pull_non_ff(); } diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 6d03e0b9fe..7c4607191a 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -96,21 +96,21 @@ test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' 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 (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff false && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff only && test_must_fail git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep "Pulling without specifying how to reconcile" err ' test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' ' @@ -128,19 +128,19 @@ test_expect_success 'pull.rebase not set and --merge given (not-fast-forward)' ' test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' ' 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 (not-fast-forward)' ' git reset --hard c2 && git pull --no-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 --ff-only given (not-fast-forward)' ' git reset --hard c2 && test_must_fail git pull --ff-only . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep "Pulling without specifying how to reconcile" err ' test_expect_success 'merge c1 with c2' ' From patchwork Mon Jul 5 12:32:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F169EC07E99 for ; Mon, 5 Jul 2021 12:32:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC622613AE for ; Mon, 5 Jul 2021 12:32:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231425AbhGEMfe (ORCPT ); Mon, 5 Jul 2021 08:35:34 -0400 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 S231405AbhGEMfd (ORCPT ); Mon, 5 Jul 2021 08:35:33 -0400 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5217C061574 for ; Mon, 5 Jul 2021 05:32:56 -0700 (PDT) Received: by mail-oi1-x234.google.com with SMTP id u11so20612266oiv.1 for ; Mon, 05 Jul 2021 05:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H/6WM4+ZiIqjZbE6bRQGmxLuso3TtwryNg+BP6KbkpQ=; b=Fyhe9gPXlhUysnGmX6E3K3nKmF6hHfzFLdOpHwzoGBPm3jBpzhp86qu5AVysapH6P6 8nKN1ObuH93M/WYEXK3dypSRvaDTVO6LuFV3NJDLv2iCLrICWLZGDK3hkv8z5jr+q1mI LJKXFpMcr+aW9Kk+9QliWUJMXT+rotTXE3g8ZQwqV0AyNWtiQZ3nlY5j7038OI5gKwYx K6+ydTsWUiIpgXImtM9WPkKr7TD7x1uUsiNkmlNH6pjGWNzHU8ngS4VyXqvxFE7wnETm YB/xvQwjB3/DWIwdqAlxp6jYs7CqNFxgoEasA+PqfUuhoXxH3HzJb1kAnDW4ygjozNoa JkOw== 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=H/6WM4+ZiIqjZbE6bRQGmxLuso3TtwryNg+BP6KbkpQ=; b=qlV3nFNipPWVnu5MS43JkZStyffpIIXg8k+GAD8ZBj1IGtcZ7HBzwZ1FrE+LmsKSeP 6Wf2F0Zun6/2uWi/pKqN8IpGSQVdQWmRT01/m3nWt+t5Qb/8q64Z+YNcvF14P5vTVpzx 0UQIydMyC2VqY591+CJvOCmGVrchGReaYXDLlgcRHFpbPnRdwZ5I7QfcCewgVhgfazsJ aJLOGjPUC2ZPF3AQHAnqCh9pUn4exZIA5mYVPsNo4URhYekuAx2jl9Vc0OuC5wgaWIeo 3S+RYpTcxHjMEMdO+/oTGerK/bk1RD8s2EKf9FjYFKdaC8B4NivSeEPmpyaCrCvue1YF rOtA== X-Gm-Message-State: AOAM531pnwawBMMIuyAtXN0GLwMxU/DhwdEchVzyyDKhh2zi7YNSAcqE mA1kTP5jP0MOCT4+RZ0dZgYR2slT97wefg== X-Google-Smtp-Source: ABdhPJy1eHspga8TX/JXr7Ydi5bNiDptU1ALDsfrqOdQDDPkxKE5VqZLnGF4diu+gTREFuqHdrlLdg== X-Received: by 2002:a54:4398:: with SMTP id u24mr9948351oiv.81.1625488375987; Mon, 05 Jul 2021 05:32:55 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id c4sm2618352ots.15.2021.07.05.05.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:55 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 26/35] pull: add pull.mode Date: Mon, 5 Jul 2021 07:32:00 -0500 Message-Id: <20210705123209.1808663-27-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The evolution of pull options has somewhat served most users, however, they have been found lacking for a very needed trio: merge / rebase / fast-forward-only. To avoid some of the problems of git pull Linus Torvalds suggested a configuration pull.merge [1], however, instead of having pull.merge and pull.rebase, we can have pull.mode which works for both. Additionally this would allow us to have a saner per-branch configuration: branch..pullMode. This patch adds a pull.mode option with two possible values (for now); merge and rebase. If set, it overrides what the user has specified in pull.rebase, and it's updated with either --merge, or --rebase. [1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/ Signed-off-by: Felipe Contreras --- Documentation/config/pull.txt | 5 +++ builtin/pull.c | 68 ++++++++++++++++++++++++++++++++--- rebase.c | 10 ++++++ rebase.h | 9 +++++ t/t5520-pull.sh | 42 ++++++++++++++++++++++ t/t7601-merge-pull-config.sh | 14 ++++++++ 6 files changed, 143 insertions(+), 5 deletions(-) diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index 5404830609..646431a02d 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -29,6 +29,11 @@ mode. it unless you understand the implications (see linkgit:git-rebase[1] for details). +pull.mode:: + When "git pull" is run, this determines if it would either merge or + rebase the fetched branch. The possible values are 'merge', + and 'rebase'. + pull.octopus:: The default merge strategy to use when pulling multiple branches at once. diff --git a/builtin/pull.c b/builtin/pull.c index 2c2f0822d5..124575c32c 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -27,6 +27,8 @@ #include "commit-reach.h" #include "sequencer.h" +static enum pull_mode_type mode; + /** * Parses the value of --rebase. If value is a false value, returns * REBASE_FALSE. If value is a true value, returns REBASE_TRUE. If value is @@ -49,6 +51,14 @@ static enum rebase_type parse_config_rebase(const char *key, const char *value, return REBASE_INVALID; } +static enum pull_mode_type parse_config_pull_mode(const char *key, const char *value) +{ + enum pull_mode_type v = pull_mode_parse_value(value); + if (v == PULL_MODE_INVALID) + die(_("Invalid value for %s: %s"), key, value); + return v; +} + /** * Callback for --rebase, which parses arg with parse_config_rebase(). */ @@ -60,9 +70,21 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset *value = parse_config_rebase("--rebase", arg, 0); else *value = unset ? REBASE_FALSE : REBASE_TRUE; + + if (*value > 0) + mode = *value >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE; + return *value == REBASE_INVALID ? -1 : 0; } +static int parse_opt_merge(const struct option *opt, const char *arg, int unset) +{ + enum rebase_type *value = opt->value; + mode = PULL_MODE_MERGE; + *value = REBASE_FALSE; + return 0; +} + static const char * const pull_usage[] = { N_("git pull [] [ [...]]"), NULL @@ -129,8 +151,9 @@ static struct option pull_options[] = { "(false|true|merges|preserve|interactive)", N_("incorporate changes by rebasing rather than merging"), PARSE_OPT_OPTARG, parse_opt_rebase), - OPT_SET_INT('m', "merge", &opt_rebase, - N_("incorporate changes by merging"), REBASE_FALSE), + OPT_CALLBACK_F('m', "merge", &opt_rebase, NULL, + N_("incorporate changes by merging"), + PARSE_OPT_NOARG | PARSE_OPT_NONEG, parse_opt_merge), OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL, N_("do not show a diffstat at the end of the merge"), PARSE_OPT_NOARG | PARSE_OPT_NONEG), @@ -349,6 +372,16 @@ static enum rebase_type config_get_rebase(void) return REBASE_DEFAULT; } +static enum pull_mode_type config_get_pull_mode(const char *repo) +{ + const char *value; + + if (!git_config_get_value("pull.mode", &value)) + return parse_config_pull_mode("pull.mode", value); + + return PULL_MODE_DEFAULT; +} + /** * Read config variables. */ @@ -931,9 +964,9 @@ static void show_advice_pull_non_ff(void) "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" + " git config pull.mode merge # the default strategy\n" + " git config pull.mode rebase\n" + " git config pull.ff only # fast-forward only\n" "\n" "You can replace \"git config\" with \"git config --global\" to set a default\n" "preference for all repositories. You can also pass --rebase, --merge,\n" @@ -968,6 +1001,31 @@ int cmd_pull(int argc, const char **argv, const char *prefix) parse_repo_refspecs(argc, argv, &repo, &refspecs); + /* + * If the user has not specified --merge or --rebase, fetch pull.mode to override + * pull.rename. + */ + if (!mode) { + mode = config_get_pull_mode(repo); + + switch (mode) { + case PULL_MODE_MERGE: + opt_rebase = REBASE_FALSE; + break; + case PULL_MODE_REBASE: + /* Do not oeverride other rebase modes */ + if (opt_rebase < REBASE_TRUE) + opt_rebase = REBASE_TRUE; + break; + case PULL_MODE_DEFAULT: + if (opt_rebase > 0) + mode = opt_rebase >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE; + break; + default: + break; + } + } + if (read_cache_unmerged()) die_resolve_conflict("pull"); diff --git a/rebase.c b/rebase.c index f8137d859b..bdfca49886 100644 --- a/rebase.c +++ b/rebase.c @@ -33,3 +33,13 @@ enum rebase_type rebase_parse_value(const char *value) return REBASE_INVALID; } + +enum pull_mode_type pull_mode_parse_value(const char *value) +{ + if (!strcmp(value, "merge") || !strcmp(value, "m")) + return PULL_MODE_MERGE; + else if (!strcmp(value, "rebase") || !strcmp(value, "r")) + return PULL_MODE_REBASE; + + return PULL_MODE_INVALID; +} diff --git a/rebase.h b/rebase.h index 34d4acfd74..5ab8f4ddd5 100644 --- a/rebase.h +++ b/rebase.h @@ -13,4 +13,13 @@ enum rebase_type { enum rebase_type rebase_parse_value(const char *value); +enum pull_mode_type { + PULL_MODE_INVALID = -1, + PULL_MODE_DEFAULT = 0, + PULL_MODE_MERGE, + PULL_MODE_REBASE +}; + +enum pull_mode_type pull_mode_parse_value(const char *value); + #endif /* REBASE */ diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index e2c0c51022..663c15fcd7 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -452,6 +452,16 @@ test_expect_success 'pull.rebase' ' test_cmp expect actual ' +test_expect_success 'pull.mode rebase' ' + git reset --hard before-rebase && + test_config pull.mode rebase && + git pull . copy && + test_cmp_rev HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual +' + test_expect_success 'pull --autostash & pull.rebase=true' ' test_config pull.rebase true && test_pull_autostash 1 --autostash @@ -526,6 +536,17 @@ test_expect_success 'pull.rebase=false create a new merge commit' ' test_cmp expect actual ' +test_expect_success 'pull.mode=merge create a new merge commit' ' + git reset --hard before-preserve-rebase && + test_config pull.mode merge && + git pull . copy && + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual +' + test_expect_success 'pull.rebase=true flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase true && @@ -555,6 +576,16 @@ test_expect_success REBASE_P \ test_cmp_rev HEAD^2 keep-merge ' +test_expect_success REBASE_P \ + 'pull.rebase=preserve rebases and merges keep-merge with pull.mode' ' + git reset --hard before-preserve-rebase && + test_config pull.mode rebase && + test_config pull.rebase preserve && + git pull . copy && + test_cmp_rev HEAD^^ copy && + test_cmp_rev HEAD^2 keep-merge +' + test_expect_success 'pull.rebase=interactive' ' write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF && echo I was here >fake.out && @@ -596,6 +627,17 @@ test_expect_success '--rebase=false create a new merge commit' ' test_cmp expect actual ' +test_expect_success '--rebase=false create a new merge commit with pull.mode' ' + git reset --hard before-preserve-rebase && + test_config pull.mode rebase && + git pull --rebase=false . copy && + test_cmp_rev HEAD^1 before-preserve-rebase && + test_cmp_rev HEAD^2 copy && + echo file3 >expect && + git show HEAD:file3.t >actual && + test_cmp expect actual +' + test_expect_success '--rebase=true rebases and flattens keep-merge' ' git reset --hard before-preserve-rebase && test_config pull.rebase preserve && diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 7c4607191a..47fd2e2d05 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -33,6 +33,13 @@ test_expect_success 'pull.rebase not set' ' test_i18ngrep ! "Pulling without specifying how to reconcile" err ' +test_expect_success 'pull.mode set' ' + git reset --hard c0 && + test_config pull.mode merge && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + test_expect_success 'pull.rebase not set and pull.ff=true' ' git reset --hard c0 && test_config pull.ff true && @@ -92,6 +99,13 @@ test_expect_success 'pull.rebase not set (not-fast-forward)' ' test_i18ngrep "Pulling without specifying how to reconcile" decoded ' +test_expect_success 'pull.mode set' ' + git reset --hard c2 && + test_config pull.mode merge && + git pull . c1 2>err && + test_i18ngrep ! "Pulling without specifying how to reconcile" err +' + test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff true && From patchwork Mon Jul 5 12:32:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 157EDC07E99 for ; Mon, 5 Jul 2021 12:33:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01C64613AE for ; Mon, 5 Jul 2021 12:33:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbhGEMfh (ORCPT ); Mon, 5 Jul 2021 08:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231429AbhGEMff (ORCPT ); Mon, 5 Jul 2021 08:35:35 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83006C061760 for ; Mon, 5 Jul 2021 05:32:58 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso18154878otu.10 for ; Mon, 05 Jul 2021 05:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R9m/vdK0srFXQMGiuPuI2YU3FWSnp1s5FMBfe2gPFgg=; b=Rr6ws2Khc5khJ+4BLjIGey5P7fSgz8djNjAIzDhzEudK11uomFnonna/eX5+8FT99O jFjQH/mKmd3JS2qui2W8zcuGFxaz6/BFr9+M1BExmK7mCPgd6UXuQAJBRKmFXqyFKKgZ v6CdKFtJgn7+euTccp+68LVm5qaicbOwXRELyx9noNqeyvIVCKZCPhr6m/kTUHnsAP5B TMGH/LnhXL247bQC2VXs8BoUPQHtHqiRVeM26p3rA2Jtka2S2kFwXAR2VZICfbRlNEXF IUbwOeJE0nX6kwtmHNbB0PkI1KCsN71JTIKqpUxC/IQrkj9O2ve3WLrbn4lhPRFsDzAw nGmg== 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=R9m/vdK0srFXQMGiuPuI2YU3FWSnp1s5FMBfe2gPFgg=; b=NyFMBDkWdceyuDGXekKTjSTOwliKWhLckI0n8uCtt73TR215IpNK2BiCWdRgw7bWUo 9+gYmGWQYAwbI/Zokcvwr9rUUv5KUlE2jJ3C54M0YU/Js2SJl/cX7pPjzzQ3EiSPKFok QhCtTtUBtdg4BnY+fbSaIORbyoDB5v8fh+IBtrWy/Fg4OdxzWKjiM02inM1GxirdeZjk pbfhfoWJsG8SDD1tgs+cbgnMWnHhFPGNq7rXxsQUpEjOaopNxRN8uiQMHcANOx4Iu6kB IVOIXDwDxSkdADiEKiiP7TTreFtjKzTikjRBNvt89G0PQO3T7q7e3EGAARG1+HaswBPw 2vIA== X-Gm-Message-State: AOAM5339TzH/YDH7DVrukwo7YSvzOlVwnlMmOy5EEnKkKrjGX/4z3gz1 Kc5G7qeJdx6vuT89ZzBLnD4bRDR6hkHMOw== X-Google-Smtp-Source: ABdhPJyslZXi+MSYYflRHciWrwLS+oyqdGB11+mH5MoKNn6BWdut4b+dDbOtd2Xr/ctswkr1GpxPWw== X-Received: by 2002:a9d:1b41:: with SMTP id l59mr10724449otl.8.1625488377709; Mon, 05 Jul 2021 05:32:57 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id e18sm2631938oiw.27.2021.07.05.05.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:57 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 27/35] pull: add per-branch mode configuration Date: Mon, 5 Jul 2021 07:32:01 -0500 Message-Id: <20210705123209.1808663-28-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Many people have argued that `git pull` should have a per-branch configuration for its mode of operation (e.g. Linus Torvalds [1] and Theodore Ts'o [2]). branch..pullMode achieves that. [1] https://lore.kernel.org/git/CA+55aFz2Uvq4vmyjJPao5tS-uuVvKm6mbP7Uz8sdq1VMxMGJCw@mail.gmail.com/ [2] https://lore.kernel.org/git/20130312212027.GE14792@thunk.org/ Signed-off-by: Felipe Contreras --- Documentation/config/branch.txt | 5 +++++ Documentation/config/pull.txt | 3 ++- builtin/pull.c | 13 +++++++++++++ t/t5520-pull.sh | 11 +++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index ba355f23e0..5f412caf62 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -101,6 +101,11 @@ branch..updateMode:: possible values are 'fast-forward', 'merge', and 'rebase'. See `update.mode` for doing this in a non branch-specific manner. +branch..pullMode:: + When `git pull` is run, this determines the mode of operation, + possible values are 'merge' and 'rebase'. See `pull.mode` for doing this + in a non branch-specific manner. + branch..description:: Branch description, can be edited with `git branch --edit-description`. Branch description is diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index 646431a02d..3fb9bfdfea 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -32,7 +32,8 @@ for details). pull.mode:: When "git pull" is run, this determines if it would either merge or rebase the fetched branch. The possible values are 'merge', - and 'rebase'. + and 'rebase'. See "branch..pullMode" for setting this on a + per-branch basis. pull.octopus:: The default merge strategy to use when pulling multiple branches diff --git a/builtin/pull.c b/builtin/pull.c index 124575c32c..bb3c0b55f9 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -374,8 +374,21 @@ static enum rebase_type config_get_rebase(void) static enum pull_mode_type config_get_pull_mode(const char *repo) { + struct branch *curr_branch = branch_get("HEAD"); const char *value; + if (curr_branch) { + char *key = xstrfmt("branch.%s.pullmode", curr_branch->name); + + if (!git_config_get_value(key, &value)) { + enum pull_mode_type ret = parse_config_pull_mode(key, value); + free(key); + return ret; + } + + free(key); + } + if (!git_config_get_value("pull.mode", &value)) return parse_config_pull_mode("pull.mode", value); diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 663c15fcd7..59894dd15a 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -493,6 +493,17 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' ' test_cmp expect actual ' +test_expect_success 'branch..pullmode overrides pull.mode' ' + git reset --hard before-rebase && + test_config pull.mode rebase && + test_config branch.to-rebase.pullmode merge && + git pull . copy && + test_cmp_rev ! HEAD^ copy && + echo new >expect && + git show HEAD:file2 >actual && + test_cmp expect actual +' + test_expect_success 'pull --rebase warns on --verify-signatures' ' git reset --hard before-rebase && git pull --rebase --verify-signatures . copy 2>err && From patchwork Mon Jul 5 12:32:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82054C07E9B for ; Mon, 5 Jul 2021 12:33:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DD56613AE for ; Mon, 5 Jul 2021 12:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbhGEMfi (ORCPT ); Mon, 5 Jul 2021 08:35:38 -0400 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 S231444AbhGEMfh (ORCPT ); Mon, 5 Jul 2021 08:35:37 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64E4CC06175F for ; Mon, 5 Jul 2021 05:33:00 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id t3so20600878oic.5 for ; Mon, 05 Jul 2021 05:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iZoMKVva73JHVGxMxaqbEh6QZSE+ZTuXKR7SfYFIxWk=; b=cbX8q7CNoMVUqGtIUELzj0I1RRy7jptTI6JlDKh0KOw74lrg+jrmgZfaG0qqdMpkIs GDTEIT16nLaX/TJ2fiOLdgs4T/fMWKS4CO4SMfQW3dobnOBh5NyZPapivNWjS4Fa7ism tvEvVmZ++Byy3Bh9XRF2YwgFLYkvyjwEl8Ub8a2+PCr9xmjyZoPSTHUMFFOgGMffU0Oe 2xNyynH7R1C5GFuTLRevNEGJAmKuclCPkRWLgYaWOct2OLJkewDtoX/sb7Lp+jel+25c clxaGijefc0q5FaOjjb51PwJTUkw3xOS6urOPF6qL7/k6OpBuL6wCa45gSTY7B9gQKSv ia8g== 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=iZoMKVva73JHVGxMxaqbEh6QZSE+ZTuXKR7SfYFIxWk=; b=ECRGkw3TPiW/JED8yifAAOJMjKO72DUwvu+f49dUz2flwoswb5wIzVK+644M1VDFfx FXeju147mnsQRRTR3IZ4EwXi2yL7uzRddie/M1I7DuuNwvAc3hctZ5A/Uu1VwNP8ldK3 Bltqsplb5xOdcsJ72EYNbVftcjGSVnclRjqtb3ZtN1HV3+LeXaZBm9i5yqXjrxWe7qCn f4gN8MHqB1u//XLpUZJHDfIBeJnVQCIRyEagICwVf4dKwPkkKQSRmWwu68Dz81JhZPO3 TwghQV1e6mNmajpYzslL56UVticdvGRH9lFO6BKT+jkiN4Y1YLO1IwLf8XXxR3QgBfJJ TU6g== X-Gm-Message-State: AOAM53047Ul0yLsR7sgeA/oWl9R5OdAFW87X//foaQDKtD5KPl4qxGPQ P6xOBZwczmYRaXYsxkRHi7fxUQlSHYWtsQ== X-Google-Smtp-Source: ABdhPJxwJMUVdun17P5vKw5uy31W9Q2XFrYzJtaTEjobdjSjr6NjBKpf5bPzCdLxMCHbnrypWKbqww== X-Received: by 2002:a05:6808:1312:: with SMTP id y18mr10051633oiv.82.1625488379564; Mon, 05 Jul 2021 05:32:59 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id v7sm2234535ooj.46.2021.07.05.05.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:32:59 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 28/35] pull: add pull.mode=fast-forward Date: Mon, 5 Jul 2021 07:32:02 -0500 Message-Id: <20210705123209.1808663-29-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It is very typical for Git newcomers to inadvertently create merges and worse; pushing them. This is one of the reasons many experienced users prefer to avoid 'git pull', and recommend newcomers to avoid it as well. To escape these problems--and keep 'git pull' useful--it has been suggested that 'git pull' barfs by default if the merge is non-fast-forward, which unfortunately would break backwards compatibility. This patch leaves everything in place to enable this new mode, but it only gets enabled if the user specifically configures it: pull.mode = fast-forward Later on this mode can be enabled by default. For *some* of the long discussions you can read: https://lore.kernel.org/git/742df4c2-2bc5-8a4b-8de1-cd5e48718398@redhat.com/ https://lore.kernel.org/git/20130522115042.GA20649@inner.h.apk.li https://lore.kernel.org/git/1377988690-23460-1-git-send-email-felipe.contreras@gmail.com https://lore.kernel.org/git/4ay6w9i74cygt6ii1b0db7wg.1398433713382@email.android.com Signed-off-by: Felipe Contreras --- Documentation/config/branch.txt | 4 +-- Documentation/config/pull.txt | 4 +-- builtin/pull.c | 6 ++++- rebase.c | 2 ++ rebase.h | 3 ++- t/t5520-pull.sh | 44 +++++++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt index 5f412caf62..a61c80c90b 100644 --- a/Documentation/config/branch.txt +++ b/Documentation/config/branch.txt @@ -103,8 +103,8 @@ branch..updateMode:: branch..pullMode:: When `git pull` is run, this determines the mode of operation, - possible values are 'merge' and 'rebase'. See `pull.mode` for doing this - in a non branch-specific manner. + possible values are 'fast-forward', 'merge', and 'rebase'. + See `pull.mode` for doing this in a non branch-specific manner. branch..description:: Branch description, can be edited with diff --git a/Documentation/config/pull.txt b/Documentation/config/pull.txt index 3fb9bfdfea..7b3dddf4d4 100644 --- a/Documentation/config/pull.txt +++ b/Documentation/config/pull.txt @@ -32,8 +32,8 @@ for details). pull.mode:: When "git pull" is run, this determines if it would either merge or rebase the fetched branch. The possible values are 'merge', - and 'rebase'. See "branch..pullMode" for setting this on a - per-branch basis. + 'rebase', and 'fast-forward'. See "branch..pullMode" for setting + this on a per-branch basis. pull.octopus:: The default merge strategy to use when pulling multiple branches diff --git a/builtin/pull.c b/builtin/pull.c index bb3c0b55f9..295c13fbe8 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -979,7 +979,7 @@ static void show_advice_pull_non_ff(void) "\n" " git config pull.mode merge # the default strategy\n" " git config pull.mode rebase\n" - " git config pull.ff only # fast-forward only\n" + " git config pull.mode fast-forward\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, --merge,\n" @@ -1023,6 +1023,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix) switch (mode) { case PULL_MODE_MERGE: + case PULL_MODE_FAST_FORWARD: opt_rebase = REBASE_FALSE; break; case PULL_MODE_REBASE: @@ -1113,6 +1114,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); + if (mode == PULL_MODE_FAST_FORWARD && !can_ff) + die(_("The pull was not fast-forward, either merge or rebase.\n")); + if (!opt_rebase && !can_ff) { if (opt_verbosity >= 0) show_advice_pull_non_ff(); diff --git a/rebase.c b/rebase.c index bdfca49886..9fe99b5b16 100644 --- a/rebase.c +++ b/rebase.c @@ -40,6 +40,8 @@ enum pull_mode_type pull_mode_parse_value(const char *value) return PULL_MODE_MERGE; else if (!strcmp(value, "rebase") || !strcmp(value, "r")) return PULL_MODE_REBASE; + else if (!strcmp(value, "fast-forward") || !strcmp(value, "f")) + return PULL_MODE_FAST_FORWARD; return PULL_MODE_INVALID; } diff --git a/rebase.h b/rebase.h index 5ab8f4ddd5..e66a73feb4 100644 --- a/rebase.h +++ b/rebase.h @@ -17,7 +17,8 @@ enum pull_mode_type { PULL_MODE_INVALID = -1, PULL_MODE_DEFAULT = 0, PULL_MODE_MERGE, - PULL_MODE_REBASE + PULL_MODE_REBASE, + PULL_MODE_FAST_FORWARD }; enum pull_mode_type pull_mode_parse_value(const char *value); diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 59894dd15a..7ea558651d 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -869,4 +869,48 @@ test_expect_success 'git pull --rebase against local branch' ' test_cmp expect file2 ' +setup_other () { + test_when_finished "git checkout main && 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 main +} + +setup_ff () { + setup_other main +} + +setup_non_ff () { + setup_other main^ +} + +test_expect_success 'fast-forward (pull.mode=fast-forward)' ' + setup_ff && + git -c pull.mode=fast-forward pull +' + +test_expect_success 'non-fast-forward (pull.mode=fast-forward)' ' + setup_non_ff && + test_must_fail git -c pull.mode=fast-forward pull +' + +test_expect_success 'non-fast-forward with merge (pull.mode=fast-forward)' ' + setup_non_ff && + git -c pull.mode=fast-forward pull --merge +' + +test_expect_success 'non-fast-forward with rebase (pull.mode=fast-forward)' ' + setup_non_ff && + git -c pull.mode=fast-forward pull --rebase +' + +test_expect_success 'non-fast-forward error message (pull.mode=fast-forward)' ' + setup_non_ff && + test_must_fail git -c pull.mode=fast-forward pull 2> error && + test_i18ngrep "The pull was not fast-forward" error +' + test_done From patchwork Mon Jul 5 12:32:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 806D1C07E9C for ; Mon, 5 Jul 2021 12:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CC40613B6 for ; Mon, 5 Jul 2021 12:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbhGEMfj (ORCPT ); Mon, 5 Jul 2021 08:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbhGEMfj (ORCPT ); Mon, 5 Jul 2021 08:35:39 -0400 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3C4C06175F for ; Mon, 5 Jul 2021 05:33:02 -0700 (PDT) Received: by mail-oi1-x231.google.com with SMTP id s17so20658537oij.0 for ; Mon, 05 Jul 2021 05:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PtO5XnfMe8RUxNKn6Gjps2RX8IziArLwFXFgMG4kYXo=; b=U4fzO4LOU9eYSYeoMlJ32SuCPp0TH08Pzn0sqIfWIjdhHt2U/uOaLAwIDaT93ZuhDR LndQ7Bo5FtL4AFn/zqJ/pg0GLmIhtvXdVSBMubUOwoRGUWy3NH+7+CDa0Jevv9KPkBJj IpZORDHVY6zbJr9kd/r7FwJLlPKX/G6iEUEiJLK+Qa5bMjBE1U9r6R0i6OoikO1FE/PQ xIKl86RRmTB+NTuKm1+8DVnGCVJPTnH345oaM2ygH7P8rrNAwddjzUc1U3zjjeF9+9cr o/qgicT9rjB3/TKDYwyDx8bEic7DZ9pA8cKwWprvK093MIqZs8mGtjp56P+2wcXnjR3K pTYw== 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=PtO5XnfMe8RUxNKn6Gjps2RX8IziArLwFXFgMG4kYXo=; b=d763LFAfbqBpSGfaKAfHPS1fJFQaaEx7OFdYBTNwq5qTMbGlfJvpnDiiKTQyxKFf5I sqxP0V+Ti2BL0tj6iq8TTvFMBfIDbZOcQAhOGMaHeEkiDMwpSgcrjMjLFx750QHqXTgf rEqok5TFtW7Ft4b8KQ/IFmA2iTqDDq4IQctRZSFWsJWvSDnTSmyPALZ+RbouSVegl8b/ icqKwo8obYwcS2psc99ysI6tq7s48H04xFog03Shm8yj1xWG5fTY17hSqC1I9suWEjB8 wUY9te8NWZ/rOPpjrpsdC4gA5rXuUHOeCW4TmF0jj2OgeIZPSw3Bq+NvdJURfq2QXp8c qmvQ== X-Gm-Message-State: AOAM532x/vK03yGuqTLP12fGkteGa3UlHgt2zZ4ar1mKScGGNEXffE3A yoTFxBKsVAedQfsjwyAFm75XrQTDJ52yCQ== X-Google-Smtp-Source: ABdhPJz7VRM8iajcyi3ohk18ZxVW0W7pc6tZowBW1ok2Pl8DYp2lKcxVRVxcL57hCRq6dS+KduicMA== X-Received: by 2002:a05:6808:14c8:: with SMTP id f8mr9812475oiw.7.1625488381251; Mon, 05 Jul 2021 05:33:01 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id u22sm1125069oie.26.2021.07.05.05.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:00 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 29/35] pull: reorganize mode conditionals Date: Mon, 5 Jul 2021 07:32:03 -0500 Message-Id: <20210705123209.1808663-30-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that everything is in place we can shuffle around the conditionals so it's clearer what we are trying to do. No functional changes. Signed-off-by: Felipe Contreras --- builtin/pull.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 295c13fbe8..cbc102ee45 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1114,12 +1114,12 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (mode == PULL_MODE_FAST_FORWARD && !can_ff) - die(_("The pull was not fast-forward, either merge or rebase.\n")); - - if (!opt_rebase && !can_ff) { - if (opt_verbosity >= 0) + if (!can_ff) { + if (!mode && opt_verbosity >= 0) show_advice_pull_non_ff(); + + if (mode == PULL_MODE_FAST_FORWARD) + die(_("The pull was not fast-forward, either merge or rebase.\n")); } if (opt_rebase >= REBASE_TRUE) { From patchwork Mon Jul 5 12:32:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25E07C07E99 for ; Mon, 5 Jul 2021 12:33:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A216613AB for ; Mon, 5 Jul 2021 12:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbhGEMfl (ORCPT ); Mon, 5 Jul 2021 08:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhGEMfk (ORCPT ); Mon, 5 Jul 2021 08:35:40 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0781C061762 for ; Mon, 5 Jul 2021 05:33:03 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id 11so20617505oid.3 for ; Mon, 05 Jul 2021 05:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YZ8FV/qzry/cy4/rRk6XfI2LNVE7d1NAm0BhI6ZtR9A=; b=Mhfyjni1o6eY8r6rOcuO55gJp3eDHvdihgAA4bdf1L0gARIGV0gwkjBMj3qVPCQHps 5WHw70om4YDSxzASwoJBVtlkUksr82H91Km85XEMN+VQgrt8gonoFjxe/ixR9/7lHB/k HPMtIFRrfLinow7U7OPseC8cmQvaw2ftM73/FtMu6gopiFg0a+EO75PUp3+IA0UQYvgn op4YiM0OTSNwp07zxLW/Hw3thgd3vxokojwuENzNZV1zliN3hoCmbEuGlr/mqPmX2Oop tmu1JuXemYg1Atcy6TKqLY5IkIQj3Rpq1GWKkGGaNszdjq4a+n9jAf1X6LpFNqbs4D11 BpRQ== 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=YZ8FV/qzry/cy4/rRk6XfI2LNVE7d1NAm0BhI6ZtR9A=; b=LNnlf6AeEQV7CNm8CWgM4gNToAETyizAN0MkdEkkUv8fbcJH3KU1edw/+NH0ANnK8u IHaSfzZUXjAyrHGM9K/FkVZSK8gJj/jEMe3/wbM8tyZo5gl/SWe3tsTkTz1yihhZkxUa UYIz8fjJtVUcdaNb2hm6+msAZE5sHe2WWVljp45Qsgp3R75BYRRJoaMCx9l5UwepHdLt blNJMVmEjMrfOYQ6MSafL6Ali42Vy9MKhJEKdHfE5c4tn+u6zZXYVppszcDJ6iH1Vp2d L6eC+y4JXFF1sqX8c5gQFeByuBz7K9UVKKefH8G0cptCIGq4TjSReI0u9gMcNPMEJoWu Z5DA== X-Gm-Message-State: AOAM531CVbUo/NeUZ38yqsSG0VxcxucP49Aen/XYH46RANnS0GEtR/WX KP8wPbkFifUZiKEXDrmUfXwVtNjZQrtQMw== X-Google-Smtp-Source: ABdhPJyPfPtzKazaxqccr9qUE+C7eRryDi/Ssw+nB0nUB+uF8+cHAu5WY6xl4tnOG1LF0HKbKqOq2A== X-Received: by 2002:aca:31ca:: with SMTP id x193mr2632568oix.84.1625488382909; Mon, 05 Jul 2021 05:33:02 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id i133sm2692786oia.2.2021.07.05.05.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:02 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 30/35] pull: add diverging advice on fast-forward mode Date: Mon, 5 Jul 2021 07:32:04 -0500 Message-Id: <20210705123209.1808663-31-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Felipe Contreras --- builtin/pull.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/builtin/pull.c b/builtin/pull.c index cbc102ee45..f4f822700a 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -1118,8 +1118,10 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (!mode && opt_verbosity >= 0) show_advice_pull_non_ff(); - if (mode == PULL_MODE_FAST_FORWARD) + if (mode == PULL_MODE_FAST_FORWARD) { + diverging_advice(); die(_("The pull was not fast-forward, either merge or rebase.\n")); + } } if (opt_rebase >= REBASE_TRUE) { From patchwork Mon Jul 5 12:32:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91479C07E99 for ; Mon, 5 Jul 2021 12:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FE8E613AB for ; Mon, 5 Jul 2021 12:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbhGEMfp (ORCPT ); Mon, 5 Jul 2021 08:35:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231449AbhGEMfm (ORCPT ); Mon, 5 Jul 2021 08:35:42 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EEDBC061765 for ; Mon, 5 Jul 2021 05:33:05 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id t24-20020a9d7f980000b029046f4a1a5ec4so18198109otp.1 for ; Mon, 05 Jul 2021 05:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ECxxfPK1SRxAWQfueTPq13GzKWFfnsCubYM8g8rb+x4=; b=kvRn1cuBdxQ3gNSg8OXPRVrE3ZT/YAMVNcZTWL6dpVefz0Rwj78qgxG64b3jLiZZKA g11KodxU8gLkePJPNo1hT3pnCtjUm/P3NBjIMCGDJm/Gtxl2GzLK9X+Q7jv7sc1ATDU5 pbZGsWpMEZjxIUipq/wzeUfpwrgmZA6hqFt0FgSdg06MDB6VuyU98fnZejnTnlL2auzU 9loUqHxdXMHfqdPDNHujsde0KvkdiXTRmZRBcKhELk2QMLkM+Urpl6Yf/CNr7Cq9DI2K 45EPxpy34TnktTyvDMJ4l5tvjBfLnhf0PBo05eCUpIItHnGKoeSrUb/NbM14YrnmEWbO wvzA== 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=ECxxfPK1SRxAWQfueTPq13GzKWFfnsCubYM8g8rb+x4=; b=PnMC7Al4eK6AVw0YrqUiFQB0GvLqtXnRJJJzwm5YOADAJsudD1LDoFsUUwCVr5NXj0 JrDHDf7AoP7Yc5mAf/Hg7pQcfLPrZ8ng7VAYmEap/rli8ZVFNu/GGo+T1OHUFZBaYgYG V52EAAWWDPw+ngT5wFYpNUKpzi3PD3qQJ+DstatxGKYuqsxKaMMoriEq1SoMT6opHT3R dbu2qUK3N1JuUNvUZS9ZawWdB9sDFTYZksnDsMkbWjV66I9wIng2ITcII2sQmci/QQBO OdXncHrrxgpPKZ9T+JBvKszV74b7/WLv/0b12SHgeMDkGPCiLtC6EzPoNPOgIUWlPURm DblQ== X-Gm-Message-State: AOAM532Zydp1Ke8IFq+MCrtJkRcj3L0crWuT9HK3NY8f/No3Xu4VR+/M Nx2cp5JfGu/SeandlINz00IMQblY2hvAvA== X-Google-Smtp-Source: ABdhPJxv+gyrfR60YApuYY1rxg2bHwSfikR8gU5tA4z2HiGr4zytcZYna2si9FAR1JJpohhw4EDPaQ== X-Received: by 2002:a9d:4b84:: with SMTP id k4mr6823343otf.262.1625488384577; Mon, 05 Jul 2021 05:33:04 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id p18sm2586451oth.60.2021.07.05.05.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:04 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 31/35] pull: improve --rebase and pull.rebase interaction Date: Mon, 5 Jul 2021 07:32:05 -0500 Message-Id: <20210705123209.1808663-32-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently --rebase without argument overrides pull.rebase: git config pull.rebase merges git pull --rebase Up until now this hasn't been a big issue, since user has not been forced to specify a merge, or a rebase. But with the introduction of --merge and pull.mode, the user could in theory have the following configuration: git config pull.mode merge git config pull.rebase merges In such case, the user would expect: git pull --rebase To be the same as: git pull --rebase=merges If the user wants to override the configuration, she can do: git pull --rebase=true Signed-off-by: Felipe Contreras --- builtin/pull.c | 10 ++++++++-- t/t5520-pull.sh | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index f4f822700a..e304b22bd8 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -68,8 +68,14 @@ static int parse_opt_rebase(const struct option *opt, const char *arg, int unset if (arg) *value = parse_config_rebase("--rebase", arg, 0); - else - *value = unset ? REBASE_FALSE : REBASE_TRUE; + else { + if (!unset) { + /* --rebase shouldn't override pull.rebase=merges (and others) */ + if (*value < REBASE_TRUE) + *value = REBASE_TRUE; + } else + *value = REBASE_FALSE; + } if (*value > 0) mode = *value >= REBASE_TRUE ? PULL_MODE_REBASE : PULL_MODE_MERGE; diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index 7ea558651d..b3b70d145f 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -597,6 +597,16 @@ test_expect_success REBASE_P \ test_cmp_rev HEAD^2 keep-merge ' +test_expect_success REBASE_P \ + 'pull.rebase=preserve interacts correctly with pull.mode and --rebase' ' + git reset --hard before-preserve-rebase && + test_config pull.mode merge && + test_config pull.rebase preserve && + git pull --rebase . copy && + test_cmp_rev HEAD^^ copy && + test_cmp_rev HEAD^2 keep-merge +' + test_expect_success 'pull.rebase=interactive' ' write_script "$TRASH_DIRECTORY/fake-editor" <<-\EOF && echo I was here >fake.out && From patchwork Mon Jul 5 12:32:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 685B0C07E9C for ; Mon, 5 Jul 2021 12:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 54D98613AB for ; Mon, 5 Jul 2021 12:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbhGEMfq (ORCPT ); Mon, 5 Jul 2021 08:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhGEMfo (ORCPT ); Mon, 5 Jul 2021 08:35:44 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C957C061760 for ; Mon, 5 Jul 2021 05:33:07 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id t3so20601206oic.5 for ; Mon, 05 Jul 2021 05:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iiRGE79cD5Fir74ETzs25vEZusqv1C5LQYgatYSNv6s=; b=Cdgtk9xUWWqLrGTSYcEOFoW+DLuDEIt+Xvt3H3yTaYXR50U9mWmmNdiZGsZp0ycqVp nM/9I2085AfVUtUZrbEsTyDd+LNDHpGixIKXBgKcNOm9+wcoLAJx/kTuwwKQ5mHQKbK0 9qIQnWiD03ycpF4JiO4c065BLLDkZbs0dLoAIjc7KrGzMWsmZHPVk89pbwfwc2zvVNv5 qryvggNP1MbKKONKAXHFL4XQikgDGM6WGZl96lYhb8BdD1hzoEGUd/1BhEoWuPSB7hC8 O7x82AJ/qwa1SvhLGNgUmty5Pqhuf9R4IONr91J/w3HI1TD2ZBixHUBO2r2uPjnfPjrf K9gQ== 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=iiRGE79cD5Fir74ETzs25vEZusqv1C5LQYgatYSNv6s=; b=oI8dWfiIs691M5SqQH9sVyeE/2nXMj1v4FoE16PjuRgGSmq4N3wfea0yY7Cy83VdEc qmoaT8f6AGd6aGpzZABTIZjYNBGgiaMh/j+q41PIkR6dTpyKCkqCuhWIVb5dGqwois26 dFJd+LOl3N/h9bwKY7xca8+bkHSHtt413D0o7b+5WGEjLMqzbZVGqd3ZUeBTqFLAbVxu AhzGgT8vkhaipa5SbEgUFW85uuZCYWgRjC6MUGGd0Xrm4dwWh6yURttjMQlopwjGpkBl KSxxwARY/itiinh3NjUJU7xuy5mJrHMjJWwWFFwObAR8Epi+oGzRwhnGCavE56ruDDuD wsNg== X-Gm-Message-State: AOAM533tZEqcSxwZJQUvbyLo96Bd/doxTHKY3f4Y9vfReL8L9Lm5CQVG jilEWmryrZLER1OqcCRtPxt8FNK0Drb5tA== X-Google-Smtp-Source: ABdhPJwaSpO3e6HIYyBm5MolK9+ZlTBGqqyjrWczYkQHaJSCBBJWz9tbQdUolnpRb0Zn364r6XCLgQ== X-Received: by 2002:aca:2806:: with SMTP id 6mr9724811oix.2.1625488386487; Mon, 05 Jul 2021 05:33:06 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id p9sm2543210otl.64.2021.07.05.05.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:05 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 32/35] pull: improve default warning Date: Mon, 5 Jul 2021 07:32:06 -0500 Message-Id: <20210705123209.1808663-33-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We don't want to start by recommending a permanent configuration, but a temporary solution so they start training their fingers and maybe learn how to do a rebase. So we start with the commands. Also, we need to be clear about what we mean by "specifying"; merge, or rebase. Moreover, it's better use --global in the configuration commands like we did with push.default. And finally, point to the documentation that explains what is a non-fast-forward, and how to solve it: git help fast-forward Signed-off-by: Felipe Contreras --- builtin/pull.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index e304b22bd8..27ce2f2183 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -979,18 +979,19 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_ static void show_advice_pull_non_ff(void) { - advise(_("Pulling without specifying how to reconcile divergent branches is\n" - "discouraged. You can squelch this message by running one of the following\n" - "commands sometime before your next pull:\n" + advise(_("Pulling without specifying how to reconcile divergent branches is discouraged;\n" + "you need to specify if you want a merge, or a rebase.\n" "\n" - " git config pull.mode merge # the default strategy\n" - " git config pull.mode rebase\n" - " git config pull.mode fast-forward\n" + " git pull --merge # the default\n" + " git pull --rebase\n" "\n" - "You can replace \"git config\" with \"git config --global\" to set a default\n" - "preference for all repositories. You can also pass --rebase, --merge,\n" - "or --ff-only on the command line to override the configured default per\n" - "invocation.\n")); + "You can quell this message by running one of the following commands:\n" + "\n" + " git config --global pull.mode merge\n" + " git config --global pull.mode rebase\n" + " git config --global pull.mode fast-forward\n" + "\n" + "For more information check \"git help fast-forward\".")); } int cmd_pull(int argc, const char **argv, const char *prefix) From patchwork Mon Jul 5 12:32:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BDCBC07E99 for ; Mon, 5 Jul 2021 12:33:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DCEA613AB for ; Mon, 5 Jul 2021 12:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231453AbhGEMft (ORCPT ); Mon, 5 Jul 2021 08:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231451AbhGEMfp (ORCPT ); Mon, 5 Jul 2021 08:35:45 -0400 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E558C06175F for ; Mon, 5 Jul 2021 05:33:09 -0700 (PDT) Received: by mail-ot1-x331.google.com with SMTP id 59-20020a9d0ac10000b0290462f0ab0800so18125440otq.11 for ; Mon, 05 Jul 2021 05:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkvncpALXIg5iSxdVNeDiPdx31gMIlchJV7kU3IwbQQ=; b=pzyXZyNRJr4cLSzo5EsJHUqO8HeSpMuU39cPAGRrLN0yAmuG8vTzK314a4CN0c4npq l4XwX8tpW2nWkgCryDk+IAV7hwRgEkwuz6V4m0zk2R+onEbP0g6QMz7FyD/QsnW2bMIi RyV11teqsCTFOsDtD6SbLFath0LBxbHUOy/1YuYboVpyYPKtewywy1ZcS4QKepE1g6Cb LGUvWpM+Um3rOqOCUfGuN9EJ+Zq0lKZn0BXhWLC4xD2Jh34ANOX7xqWeuFsSLd4220FH 9/l5/q+hKEQ1r5w7cgFr01d4SXQGAAmH65mVJhIWJdOmRo6pB/GKPXxOYT8K1MRE9Cej M4bA== 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=GkvncpALXIg5iSxdVNeDiPdx31gMIlchJV7kU3IwbQQ=; b=b2JphP+0aUle4PUvUb3dw++dob8/iDiiV9nVOPK9vhLujnM5yJTfKbYZxdDicEZFU/ FCqUOzAx04Nw8whGyfEoRdT7kKBILl2NtzTrZbsP+tUHDbJroIVH16OEdMiE8p4/zW0J ZLSRTGYoT5ChgvOskbnd/lywPhS+951zt0fcyviATEZcC5Z/QQDU6rqVhvlHukzpWWEf HcAjx6LexqHBcJ4SUmFBAIyxsHajlULKp7cHjlVXFt7/8QpiN+28wr8Dp/W1a+82Ajxx iOJ/4NQ1M+anyw0wSRw9bcolPKVUWPQTb8V/7Q/96hy/zi1fe6QriLcHobJgadwCSkGv 3LtA== X-Gm-Message-State: AOAM530yMGSS3JHBAgUPmnUGbHk7PnzNCy+MBU+lUoXwEXKQ4uz/1PK6 i3ThcigOtZ1EUtRa5Xb6tSE/AoUPxLdBsQ== X-Google-Smtp-Source: ABdhPJzV+JkuoAZRrq1+KB78ohm3Dw0mG99Zv265gZIxYuuvgYwqiHy1CG2HkpBkf6JsTejrPHKwtQ== X-Received: by 2002:a9d:826:: with SMTP id 35mr1138169oty.121.1625488388299; Mon, 05 Jul 2021 05:33:08 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id x130sm351109oix.22.2021.07.05.05.33.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:07 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 33/35] pull: advice of future changes Date: Mon, 5 Jul 2021 07:32:07 -0500 Message-Id: <20210705123209.1808663-34-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that we have `pull.mode=fast-forward`, we can make it the default any time we want to. For now, simply explain the upcoming changes in the default warning, and mention how to turn on the future default mode. Signed-off-by: Felipe Contreras --- builtin/pull.c | 28 +++++++++++++------------ t/t5520-pull.sh | 8 ++++++++ t/t7601-merge-pull-config.sh | 40 ++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 33 deletions(-) diff --git a/builtin/pull.c b/builtin/pull.c index 27ce2f2183..4771c953d2 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -979,19 +979,21 @@ static int get_can_ff(struct object_id *orig_head, struct object_id *orig_merge_ static void show_advice_pull_non_ff(void) { - advise(_("Pulling without specifying how to reconcile divergent branches is discouraged;\n" - "you need to specify if you want a merge, or a rebase.\n" - "\n" - " git pull --merge # the default\n" - " git pull --rebase\n" - "\n" - "You can quell this message by running one of the following commands:\n" - "\n" - " git config --global pull.mode merge\n" - " git config --global pull.mode rebase\n" - " git config --global pull.mode fast-forward\n" - "\n" - "For more information check \"git help fast-forward\".")); + advise(_("The pull was not a fast-forward, in the future you will have to choose\n" + "between a merge or a rebase.\n" + "\n" + "To quell this message you have two main options:\n" + "\n" + "1. Adopt the new behavior:\n" + "\n" + " git config --global pull.mode fast-forward\n" + "\n" + "2. Maintain the current behavior:\n" + "\n" + " git config --global pull.mode merge\n" + "\n" + "For now we will fall back to the traditional behavior: merge.\n" + "For more information check \"git help fast-forward\".")); } int cmd_pull(int argc, const char **argv, const char *prefix) diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index b3b70d145f..bc1c601b8b 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -923,4 +923,12 @@ test_expect_success 'non-fast-forward error message (pull.mode=fast-forward)' ' test_i18ngrep "The pull was not fast-forward" error ' +test_expect_success 'non-fast-forward warning (default)' ' + setup_non_ff && + git pull 2> error && + cat error && + test_i18ngrep "The pull was not a fast-forward" error && + test_i18ngrep "in the future you will have to choose" error +' + test_done diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 47fd2e2d05..16d1e1ba47 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -30,65 +30,65 @@ test_expect_success 'setup' ' test_expect_success 'pull.rebase not set' ' git reset --hard c0 && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.mode set' ' git reset --hard c0 && test_config pull.mode merge && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=true' ' git reset --hard c0 && test_config pull.ff true && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=false' ' git reset --hard c0 && test_config pull.ff false && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=only' ' git reset --hard c0 && test_config pull.ff only && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --rebase given' ' git reset --hard c0 && git pull --rebase . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --merge given' ' git reset --hard c0 && git pull --merge . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff given' ' git reset --hard c0 && git pull --ff . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --no-ff given' ' git reset --hard c0 && git pull --no-ff . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff-only given' ' git reset --hard c0 && git pull --ff-only . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set (not-fast-forward)' ' @@ -96,65 +96,65 @@ test_expect_success 'pull.rebase not set (not-fast-forward)' ' git -c color.advice=always pull . c1 2>err && test_decode_color decoded && test_i18ngrep "hint: " decoded && - test_i18ngrep "Pulling without specifying how to reconcile" decoded + test_i18ngrep "in the future you will have to choose" decoded ' test_expect_success 'pull.mode set' ' git reset --hard c2 && test_config pull.mode merge && git pull . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff true && git pull . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff false && git pull . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' ' git reset --hard c2 && test_config pull.ff only && test_must_fail git pull . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' ' git reset --hard c2 && git pull --rebase . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --merge given (not-fast-forward)' ' git reset --hard c2 && git pull --merge . c1 2>err && - test_i18ngrep ! "Pulling without specifying how to reconcile" err + test_i18ngrep ! "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' ' git reset --hard c2 && git pull --ff . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' ' git reset --hard c2 && git pull --no-ff . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' ' git reset --hard c2 && test_must_fail git pull --ff-only . c1 2>err && - test_i18ngrep "Pulling without specifying how to reconcile" err + test_i18ngrep "in the future you will have to choose" err ' test_expect_success 'merge c1 with c2' ' From patchwork Mon Jul 5 12:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7023DC07E9C for ; Mon, 5 Jul 2021 12:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B1E3613AA for ; Mon, 5 Jul 2021 12:33:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231451AbhGEMft (ORCPT ); Mon, 5 Jul 2021 08:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbhGEMfr (ORCPT ); Mon, 5 Jul 2021 08:35:47 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDAD6C061762 for ; Mon, 5 Jul 2021 05:33:10 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id m3so1656190oig.10 for ; Mon, 05 Jul 2021 05:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CVYotwuhI6FBI/3kC//mYo5k3GQrYq2pfEoDD07ObvU=; b=ExjgtlQiwVls2qdiQXx2mr4NaNsD69JXvdyH1LfXz1FxcPgVq5X5j0QL3GtgEcFO9r p0RLHriuBBVK8UByru+gD+qXtK8xmVy07HuwYtEOl9u256AbK6ra6QU2L/jb6P+OGB6i lUu3e8j6nX2+5N/3yDrmLnSkRUscZrJTf42Dx2PecW4HFXfWyM+QFG1aZJGCarQP6HTV baoXRUz0mQSlUqJodMRHsVtZY8oCSGm7yv5eDjrku3UdQoB6PFxZpzfHL99K4YZfCNsu YRQro6GnBFEi5aEC2kPdjsgHwcXtPJKaoFHcaC/RHBEky9fk+0v6erNf7Lb6uFjDtu/s FI7A== 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=CVYotwuhI6FBI/3kC//mYo5k3GQrYq2pfEoDD07ObvU=; b=hcPtUMb76iu9R0oldXK4eqKFY7sdDGTc74yv4jk1iGVLykDZyxCB80qjLiFKn0rGI4 eR6yVBdY2K2ztwYp8ppEgqnjJsEcrjAZ0wtS7ZYFzPUHQafxGqqlIG7m3x/RTCfp/0s9 QvLv4rkeLrHqFmirBNAjy2M9XiH8K+pJ7Xf32qIHg/aXTF1LZqTputvxnesDkI5bqKWC EamyYuEvVsaV1PnLi+x969/H60BWQRcPz7uo56UFh+x7jVIFOEI/J9CoWk1fxwGioA79 w2GN8t/gazlBw15q5zPNY/e+vOyG8+/bnKw9AAM2d+oDii878K5GK3iZBZ6FzGyuHvpj a0TA== X-Gm-Message-State: AOAM531EGNW/LqBEnheE42RO3R0pD4Mp9WoCHI4sYxo0c6EMni3jQwuO JjTK5uA28zjsF1GuU8ZDUaPk9ltVZCWkeQ== X-Google-Smtp-Source: ABdhPJy5LlbuKnc3TXV+SNYnpUzwPNcHfV0aUdXOMBB5kntd55a8ktpl2Nrt6g6KUTHkCVVikjxfKQ== X-Received: by 2002:aca:3a55:: with SMTP id h82mr9158032oia.59.1625488390021; Mon, 05 Jul 2021 05:33:10 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id g31sm2542800otb.53.2021.07.05.05.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:09 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 34/35] FUTURE: pull: enable ff-only mode by default Date: Mon, 5 Jul 2021 07:32:08 -0500 Message-Id: <20210705123209.1808663-35-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The user has been warned that this change was coming and should have already configured his/her preference. It's time to flip the switch and make ff-only the default. There's no need for the annoying warning anymore. Signed-off-by: Felipe Contreras --- Documentation/git-pull.txt | 3 + builtin/pull.c | 30 +------- t/t5520-pull.sh | 28 +++----- t/t7601-merge-pull-config.sh | 130 ----------------------------------- 4 files changed, 16 insertions(+), 175 deletions(-) diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index d23128fa72..c2768fadb1 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -35,6 +35,9 @@ Default values for and are read from the "remote" and "merge" configuration for the current branch as set by linkgit:git-branch[1] `--track`. +By default non-fast-forward merges fail, so you need to specify if you want to +do a merge or a rebase. + Assume the following history exists and the current branch is "`master`": diff --git a/builtin/pull.c b/builtin/pull.c index 4771c953d2..24c72e33c6 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -977,25 +977,6 @@ 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) -{ - advise(_("The pull was not a fast-forward, in the future you will have to choose\n" - "between a merge or a rebase.\n" - "\n" - "To quell this message you have two main options:\n" - "\n" - "1. Adopt the new behavior:\n" - "\n" - " git config --global pull.mode fast-forward\n" - "\n" - "2. Maintain the current behavior:\n" - "\n" - " git config --global pull.mode merge\n" - "\n" - "For now we will fall back to the traditional behavior: merge.\n" - "For more information check \"git help fast-forward\".")); -} - int cmd_pull(int argc, const char **argv, const char *prefix) { const char *repo, **refspecs; @@ -1123,14 +1104,9 @@ int cmd_pull(int argc, const char **argv, const char *prefix) can_ff = get_can_ff(&orig_head, &merge_heads.oid[0]); - if (!can_ff) { - if (!mode && opt_verbosity >= 0) - show_advice_pull_non_ff(); - - if (mode == PULL_MODE_FAST_FORWARD) { - diverging_advice(); - die(_("The pull was not fast-forward, either merge or rebase.\n")); - } + if ((!mode || mode == PULL_MODE_FAST_FORWARD) && !can_ff) { + diverging_advice(); + die(_("The pull was not fast-forward, either merge or rebase.\n")); } if (opt_rebase >= REBASE_TRUE) { diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh index bc1c601b8b..dea3ea8c37 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -897,38 +897,30 @@ setup_non_ff () { setup_other main^ } -test_expect_success 'fast-forward (pull.mode=fast-forward)' ' +test_expect_success 'fast-forward (default)' ' setup_ff && - git -c pull.mode=fast-forward pull + git pull ' -test_expect_success 'non-fast-forward (pull.mode=fast-forward)' ' +test_expect_success 'non-fast-forward (default)' ' setup_non_ff && - test_must_fail git -c pull.mode=fast-forward pull + test_must_fail git pull ' -test_expect_success 'non-fast-forward with merge (pull.mode=fast-forward)' ' +test_expect_success 'non-fast-forward with merge (default)' ' setup_non_ff && - git -c pull.mode=fast-forward pull --merge + git pull --merge ' -test_expect_success 'non-fast-forward with rebase (pull.mode=fast-forward)' ' +test_expect_success 'non-fast-forward with rebase (default)' ' setup_non_ff && - git -c pull.mode=fast-forward pull --rebase + git pull --rebase ' -test_expect_success 'non-fast-forward error message (pull.mode=fast-forward)' ' +test_expect_success 'non-fast-forward error message (default)' ' setup_non_ff && - test_must_fail git -c pull.mode=fast-forward pull 2> error && + test_must_fail git pull 2> error && test_i18ngrep "The pull was not fast-forward" error ' -test_expect_success 'non-fast-forward warning (default)' ' - setup_non_ff && - git pull 2> error && - cat error && - test_i18ngrep "The pull was not a fast-forward" error && - test_i18ngrep "in the future you will have to choose" error -' - test_done diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh index 16d1e1ba47..c6c44ec570 100755 --- a/t/t7601-merge-pull-config.sh +++ b/t/t7601-merge-pull-config.sh @@ -27,136 +27,6 @@ test_expect_success 'setup' ' git tag c3 ' -test_expect_success 'pull.rebase not set' ' - git reset --hard c0 && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.mode set' ' - git reset --hard c0 && - test_config pull.mode merge && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=true' ' - git reset --hard c0 && - test_config pull.ff true && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=false' ' - git reset --hard c0 && - test_config pull.ff false && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=only' ' - git reset --hard c0 && - test_config pull.ff only && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --rebase given' ' - git reset --hard c0 && - git pull --rebase . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --merge given' ' - git reset --hard c0 && - git pull --merge . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff given' ' - git reset --hard c0 && - git pull --ff . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --no-ff given' ' - git reset --hard c0 && - git pull --no-ff . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff-only given' ' - git reset --hard c0 && - git pull --ff-only . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -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 "in the future you will have to choose" decoded -' - -test_expect_success 'pull.mode set' ' - git reset --hard c2 && - test_config pull.mode merge && - git pull . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=true (not-fast-forward)' ' - git reset --hard c2 && - test_config pull.ff true && - git pull . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=false (not-fast-forward)' ' - git reset --hard c2 && - test_config pull.ff false && - git pull . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and pull.ff=only (not-fast-forward)' ' - git reset --hard c2 && - test_config pull.ff only && - test_must_fail git pull . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --rebase given (not-fast-forward)' ' - git reset --hard c2 && - git pull --rebase . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --merge given (not-fast-forward)' ' - git reset --hard c2 && - git pull --merge . c1 2>err && - test_i18ngrep ! "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff given (not-fast-forward)' ' - git reset --hard c2 && - git pull --ff . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --no-ff given (not-fast-forward)' ' - git reset --hard c2 && - git pull --no-ff . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - -test_expect_success 'pull.rebase not set and --ff-only given (not-fast-forward)' ' - git reset --hard c2 && - test_must_fail git pull --ff-only . c1 2>err && - test_i18ngrep "in the future you will have to choose" err -' - test_expect_success 'merge c1 with c2' ' git reset --hard c1 && test -f c0.c && From patchwork Mon Jul 5 12:32:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 12359021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B97AC07E9E for ; Mon, 5 Jul 2021 12:33:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3122D613AB for ; Mon, 5 Jul 2021 12:33:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbhGEMfv (ORCPT ); Mon, 5 Jul 2021 08:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbhGEMfu (ORCPT ); Mon, 5 Jul 2021 08:35:50 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B0DAC06175F for ; Mon, 5 Jul 2021 05:33:12 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id s17so20658993oij.0 for ; Mon, 05 Jul 2021 05:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JfTUuV5jJT6i1tmtxrZIocTKxMUFp9EVp7mzLHla8Yk=; b=Y29TaTiIUKNExoUyL2xYZ33DauFTIF4UcZ3miMQmJ6c3HDXad2+698f143x4cm5Bho GA0Y7iNr8ZoVmRtw+M+MtzAD06Q0Mhi2/FPi3rt5s2gha1E/TURQ8ucmEl96JIUJFpsR RdBSl3xdMoV7yDoYQDvL+MYo7x9vV/gYiD4prIboy/b71apW3nc9cgK0GQaMQKHIP7wc o9oz8h1Jv7p60vVvIykOHzs7tdskKvKPwzEMYHLltkcQoqdMBQSY0imBFatQHq4apqu0 z4PrIY+vZZ3Dv9bcGpyjxa+hMZkNaguCDsjaG8q8K1TSGOtO+atxFm4qHreDLECeW6f6 bEsw== 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=JfTUuV5jJT6i1tmtxrZIocTKxMUFp9EVp7mzLHla8Yk=; b=piZZynyqXjx0hpnGMTtaRX9z+mdebU8xT+ZW1vByJpMb4pRbAMGxceIRCTwNKCfB4r cqBwB0zeEgtvfoN0ardYuyydS1nbvSuQzueNgbDgIG0yKwXXG1qoNfNwuMEPZ0TZEyVb e2vCxEwLffJpVUL6GhleqTLHn6U0Lrs0tifwu5tKAAS3xkgZ50Do9WOdwRdpGuRkxQvo bpdnQO2328Ld2byLEs+Y1j4/L8Wu+xejjvGNspQQsEnvXC1hG8Keu4AW+BMBi4uQAD5X sGAts8ae2zDomSquPhEVhmv0j0FiViqMmYG9qNPXNqQxoacmHhr+rcgKR1beUotm26EC gRCw== X-Gm-Message-State: AOAM530GVsav8ARGZ/+gB7E7IJnGuFFmZMIZxXQodP3PREk5QlPJJdhF AlV1vRmnErB70CPH5G/H44wi8J+HxssMXw== X-Google-Smtp-Source: ABdhPJxqZ0MOjMGXUj9Qp7+W+A//3d9LiMyYA7kHt9CDBzUitT25dlOlHEWQuUg7Pbq/jT+i0X4+hA== X-Received: by 2002:aca:d755:: with SMTP id o82mr9938561oig.178.1625488391579; Mon, 05 Jul 2021 05:33:11 -0700 (PDT) Received: from localhost (fixed-187-189-187-231.totalplay.net. [187.189.187.231]) by smtp.gmail.com with ESMTPSA id v62sm2620922oig.10.2021.07.05.05.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jul 2021 05:33:11 -0700 (PDT) From: Felipe Contreras To: git@vger.kernel.org Cc: Alex Henrie , Richard Hansen , Junio C Hamano , Felipe Contreras Subject: [RFC PATCH 35/35] !fixup FUTURE: pull: enable ff-only mode by default Date: Mon, 5 Jul 2021 07:32:09 -0500 Message-Id: <20210705123209.1808663-36-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.32.0.36.g70aac2b1aa In-Reply-To: <20210705123209.1808663-1-felipe.contreras@gmail.com> References: <20210705123209.1808663-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Fix all the tests. TODO: some of these should probably not even use `git pull .` but `git merge` instead. Signed-off-by: Felipe Contreras --- t/t4013-diff-various.sh | 2 +- t/t5520-pull.sh | 16 ++++++++-------- 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 | 16 ++++++++-------- t/t6409-merge-subtree.sh | 6 +++--- t/t6417-merge-ours-theirs.sh | 10 +++++----- t/t7603-merge-reduce-heads.sh | 2 +- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 7fadc985cc..48ae585e1a 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 --merge -s ours . 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 dea3ea8c37..ad4fe1998e 100755 --- a/t/t5520-pull.sh +++ b/t/t5520-pull.sh @@ -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 --merge . 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 --merge ' test_expect_success 'pull --autostash & merge.autostash=true' ' test_config merge.autostash true && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --merge --autostash ' test_expect_success 'pull --autostash & merge.autostash=false' ' test_config merge.autostash false && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --merge --autostash ' test_expect_success 'pull --autostash & merge.autostash unset' ' test_unconfig merge.autostash && - test_pull_autostash 2 --autostash + test_pull_autostash 2 --merge --autostash ' test_expect_success 'pull --no-autostash & merge.autostash=true' ' test_config merge.autostash true && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --merge --no-autostash ' test_expect_success 'pull --no-autostash & merge.autostash=false' ' test_config merge.autostash false && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --merge --no-autostash ' test_expect_success 'pull --no-autostash & merge.autostash unset' ' test_unconfig merge.autostash && - test_pull_autostash_fail --no-autostash + test_pull_autostash_fail --merge --no-autostash ' test_expect_success 'pull.rebase' ' diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh index 63a688bdbf..361800a6f4 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 --all --force --merge ) ' @@ -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 --allow-unrelated-histories --merge ../src side ) ' diff --git a/t/t5524-pull-msg.sh b/t/t5524-pull-msg.sh index c278adaa5a..2f8a20de18 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 --log --merge && 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 --log=1 --merge && 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 b1d614ce18..dabbea76d3 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 --merge --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 --merge --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 --merge --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 --merge --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 --merge --set-upstream upstream HEAD && check_config main upstream HEAD && git checkout other && - git pull --set-upstream upstream HEAD && + git pull --merge --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 --merge --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 e845d621f6..1c9b121814 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 --merge 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 --merge 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 425dad97d5..833b799e25 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 --merge . 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 --merge . 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 --merge . 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 --merge . 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 --merge . 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 --merge . 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 --merge . yellow && test_path_is_missing M && git reset --hard anchor ' @@ -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 --merge . 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 d406b2343c..e1011f6325 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 --merge -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 --merge -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 --merge -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 ac9aee9a66..06cebb2974 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 --merge -s recursive -Xours . side && + git reset --hard main && git pull --merge -s recursive -X ours . side && + git reset --hard main && git pull --merge -s recursive -Xtheirs . side && + git reset --hard main && git pull --merge -s recursive -X theirs . side && + git reset --hard main && test_must_fail git pull --merge -s recursive -X bork . side ' test_expect_success SYMLINKS 'symlink with -Xours/-Xtheirs' ' diff --git a/t/t7603-merge-reduce-heads.sh b/t/t7603-merge-reduce-heads.sh index 98948955ae..566b1c1a2a 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 --merge . 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)" &&