git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] pull: introduce --merge option
@ 2021-07-21 13:46 Felipe Contreras
  2021-07-21 17:06 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Felipe Contreras @ 2021-07-21 13:46 UTC (permalink / raw)
  To: git; +Cc: Alex Henrie, Linus Torvalds, Junio C Hamano, Felipe Contreras

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] pull: introduce --merge option
  2021-07-21 13:46 [PATCH v2] pull: introduce --merge option Felipe Contreras
@ 2021-07-21 17:06 ` Linus Torvalds
  2021-07-21 17:11   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2021-07-21 17:06 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: Git List Mailing, Alex Henrie, Junio C Hamano

On Wed, Jul 21, 2021 at 6:47 AM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> Users need to specify if they want to either --merge or --rebase, but
> unfortunately the former is missing.

Ack. I think it's just historical, because long long ago it used to be
that 'git pull' always merged unless told otherwise with --rebase.

               Linus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] pull: introduce --merge option
  2021-07-21 17:06 ` Linus Torvalds
@ 2021-07-21 17:11   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2021-07-21 17:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Felipe Contreras, Git List Mailing, Alex Henrie

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Wed, Jul 21, 2021 at 6:47 AM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>>
>> Users need to specify if they want to either --merge or --rebase, but
>> unfortunately the former is missing.
>
> Ack. I think it's just historical, because long long ago it used to be
> that 'git pull' always merged unless told otherwise with --rebase.

The "--no-rebase" option, which is documented as a synonym for
"--rebase=false", has been there, but the implementation is buggy in
some corner cases, which has been worked on recently in a separate
thread.  I do not think it is too bad to add "--merge" as yet
another synonym for "--rebase=false".


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-21 17:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 13:46 [PATCH v2] pull: introduce --merge option Felipe Contreras
2021-07-21 17:06 ` Linus Torvalds
2021-07-21 17:11   ` Junio C Hamano

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

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

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git