git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Alex Henrie <alexhenrie24@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Junio C Hamano <gitster@pobox.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v2] pull: introduce --merge option
Date: Wed, 21 Jul 2021 08:46:50 -0500	[thread overview]
Message-ID: <20210721134650.1866387-1-felipe.contreras@gmail.com> (raw)

Users need to specify if they want to either --merge or --rebase, but
unfortunately the former is missing.

In many discussions regarding `git pull` --merge is often mentioned, but
for one reason or another the patches have not been merged.

Let's just go ahead and do it.

Now we can update the default warning to say --merge instead of the
non-intuitive --no-rebase.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---

Since v1 I've removed any hint of deprecation (even though we obviously
want to do that), and added an actual test (I don't seem to find a
simialr one for --no-rebase).

Range-diff against v1:
1:  80d7866599 < -:  ---------- pull: introduce --merge option
-:  ---------- > 1:  5969fc4455 pull: introduce --merge option

 Documentation/git-pull.txt | 6 ++++++
 builtin/pull.c             | 4 +++-
 t/t5520-pull.sh            | 7 +++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 5c3fb67c01..c7a1f676cc 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -134,6 +134,12 @@ unless you have read linkgit:git-rebase[1] carefully.
 --no-rebase::
 	Override earlier --rebase.
 
+-m::
+--merge::
+	Do a merge.
++
+Alias for --no-rebase.
+
 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/t5520-pull.sh b/t/t5520-pull.sh
index e2c0c51022..f299a82405 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -452,6 +452,13 @@ test_expect_success 'pull.rebase' '
 	test_cmp expect actual
 '
 
+test_expect_success 'pull.rebase with --merge' '
+	git reset --hard before-rebase &&
+	test_config pull.rebase true &&
+	git pull --merge . copy &&
+	test_cmp_rev HEAD^2 copy
+'
+
 test_expect_success 'pull --autostash & pull.rebase=true' '
 	test_config pull.rebase true &&
 	test_pull_autostash 1 --autostash
-- 
2.32.0.40.gb9b36f9b52


             reply	other threads:[~2021-07-21 13:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 13:46 Felipe Contreras [this message]
2021-07-21 17:06 ` [PATCH v2] pull: introduce --merge option Linus Torvalds
2021-07-21 17:11   ` Junio C Hamano
2021-07-26  4:06     ` Alex Henrie
2021-07-27  2:56       ` Felipe Contreras
2021-07-27  8:45       ` Junio C Hamano
2021-07-27 15:52         ` Alex Henrie
2021-07-27 16:48           ` Felipe Contreras
2021-07-28  7:44             ` Matthias Baumgarten
2021-07-28 17:18               ` Junio C Hamano
2021-07-28 18:18                 ` Matthias Baumgarten
2021-07-28 19:25                 ` Felipe Contreras
2021-07-27  6:31     ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721134650.1866387-1-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).