All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>,
	Philip Oakley <philipoakley@iee.email>,
	Alex Henrie <alexhenrie24@gmail.com>, Jeff King <peff@peff.net>,
	Junio C Hamano <gitster@pobox.com>,
	Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 1/3] pull: cleanup autostash check
Date: Sat, 12 Jun 2021 23:59:47 -0500	[thread overview]
Message-ID: <20210613045949.255090-2-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20210613045949.255090-1-felipe.contreras@gmail.com>

Currently "git pull --rebase" takes a shortcut in the case a
fast-forward merge is possible; run_merge() is called with --ff-only.

However, "git merge" didn't have an --autostash option, so, when "git
pull --rebase --autostash" was called *and* the fast-forward merge
shortcut was taken, then the pull failed.

This was fixed in commit f15e7cf5cc (pull: ff --rebase --autostash
works in dirty repo, 2017-06-01) by simply skipping the fast-forward
merge shortcut.

Later on "git merge" learned the --autostash option [a03b55530a
(merge: teach --autostash option, 2020-04-07)], and so did "git pull"
[d9f15d37f1 (pull: pass --autostash to merge, 2020-04-07)].

Therefore it's not necessary to skip the fast-forward merge shortcut
anymore when called with --rebase --autostash.

Let's always take the fast-forward merge shortcut by essentially
reverting f15e7cf5cc.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 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);
-- 
2.32.0


  reply	other threads:[~2021-06-13  5:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13  4:59 [PATCH 0/3] pull: obvious fixes Felipe Contreras
2021-06-13  4:59 ` Felipe Contreras [this message]
2021-06-14 14:56   ` [PATCH 1/3] pull: cleanup autostash check Elijah Newren
2021-06-15 10:59     ` Felipe Contreras
     [not found]   ` <CAPUEspg_MmerWb7h8MyhgcJXbWrJeeSyeJ7z2S6eHgDfRDPKvA@mail.gmail.com>
2021-06-15 11:09     ` Felipe Contreras
2021-06-13  4:59 ` [PATCH 2/3] pull: trivial cleanup Felipe Contreras
2021-06-14 14:57   ` Elijah Newren
2021-06-13  4:59 ` [PATCH 3/3] pull: trivial whitespace style fix Felipe Contreras
2021-06-14 15:03   ` Elijah Newren
2021-06-14 14:47 ` [PATCH 0/3] pull: obvious fixes Elijah Newren
2021-06-15  1:25   ` Junio C Hamano
2021-06-15 10:41   ` Felipe Contreras
2021-06-17 16:17 ` [PATCH v2 " Felipe Contreras
2021-06-17 16:17   ` [PATCH v2 1/3] pull: cleanup autostash check Felipe Contreras
2021-06-17 16:17   ` [PATCH v2 2/3] pull: trivial cleanup Felipe Contreras
2021-06-17 16:17   ` [PATCH v2 3/3] pull: trivial whitespace style fix Felipe Contreras
2021-06-17 16:48   ` [PATCH v2 0/3] pull: obvious fixes Elijah Newren

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

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

  git send-email \
    --in-reply-to=20210613045949.255090-2-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=alexhenrie24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=peff@peff.net \
    --cc=philipoakley@iee.email \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.