git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git pull --rebase should use fast forward merge if possible

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 29, 2016, 16:32 UTC
Message-ID
<xmqqd1n0552i.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<OF95D98CB6.47969C1C-ONC1257FE1.0058D980-C1257FE1.0059986D@dakosy.de>
neuling@dakosy.de writes:
Show 11 quoted lines
> since I have added "pull.rebase=preserve" to my global configuration I 
> wonder why "git pull" also trys to rebase if a fast forward merge is 
> possible. 
>
> A fast forward merge would speed up every pull if your local branch 
> contains no new commits and the remote branch is ahead. The result would 
> be the same. 
>
> Is it possible to change the behavior of "git pull 
> --rebase=true|preserve|interactive" to use a fast forward merge if the 
> remote branch is ahead and the local branch contains no new commits? 
Interesting.  I do not think of a reason why we shouldn't.

If we were still working in scripted Porcelain, it would have been a five minute hack, perhaps like this.

 contrib/examples/git-pull.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/contrib/examples/git-pull.sh b/contrib/examples/git-pull.sh
index 6b3a03f..3648040 100755
--- a/contrib/examples/git-pull.sh
+++ b/contrib/examples/git-pull.sh
@@ -358,6 +358,14 @@ fi
 
 if test true = "$rebase"
 then
+	if git merge-base --is-ancestor "$orig_head" "$merge_head"
+	then
+		# We can just fast-forward, as "git rebase --no-ff"
+		# is nonsense.
+		git merge --ff-only "$merge_head"
+		exit
+	fi
+
 	o=$(git show-branch --merge-base $curr_branch $merge_head $oldremoteref)
 	if test "$oldremoteref" = "$o"
 	then
Previous: neuling@dakosy.deNext: Junio C Hamano
Message 2 of 9 in “git pull --rebase should use fast forward merge if possible”
  1. neuling@dakosy.deJun 29, 2016
  2. Junio C HamanoJun 29, 2016
  3. Junio C HamanoJun 29, 2016
  4. Stefan BellerJun 29, 2016
  5. Junio C HamanoJun 29, 2016
  6. Re* git pull --rebase should use fast forward merge if possibleJunio C Hamano, Dec 1, 2016
  7. Stefan BellerDec 1, 2016
  8. Junio C HamanoDec 1, 2016
  9. Stefan BellerDec 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.