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

Re: [PATCH 5/9] pull: ensure --rebase overrides ability to ff

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 20, 2021, 23:35 UTC
Message-ID
<xmqqwnpkftjv.fsf@gitster.g>
In-Reply-To
<3d9ff69198e5a604b124bf861df4d6ecf6eb661e.1626536508.git.gitgitgadget@gmail.com>
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> From: Elijah Newren <newren@gmail.com>
>
> Now that the handling of fast-forward-only in combination with rebases
> has been moved before the merge-vs-rebase logic, we have an unnecessary
> special fast-forward case left within the rebase logic.

It is correct to say that we could call run_rebase() and it will do the right thing, even when can_ff is true, in this codepath.

But I am not sure if you want to do this as a part of this series.

The code in question comes from 33b842a1 (pull: fast-forward "pull --rebase=true", 2016-06-29). It was meant as a mere optimization to avoid calling run_rebase() when we know we have nothing to replay on top of their head after we fast-forward, and doing a pure fast-forward is easier by calling run_merge().

In other words, the code this patch touches should not have anything to do with the rebase-vs-fast-forward logic.

Now, if a benchmarking tells us that there is no difference between calling an empty run_rebase() and run_merge(), I'd be perfectly fine with this change, with the justification that we are "discarding an earlier optimization that has become irrelevant". But that would be totally outside the theme of this topic, I would think.

Thanks.
Show 38 quoted lines
> @@ -1070,13 +1070,7 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
>  		    submodule_touches_in_range(the_repository, &upstream, &curr_head))
>  			die(_("cannot rebase with locally recorded submodule modifications"));
>  
> -		if (can_ff) {
> -			/* we can fast-forward this without invoking rebase */
> -			opt_ff = "--ff-only";
> -			ret = run_merge();
> -		} else {
> -			ret = run_rebase(&newbase, &upstream);
> -		}
> +		ret = run_rebase(&newbase, &upstream);
>  
>  		if (!ret && (recurse_submodules == RECURSE_SUBMODULES_ON ||
>  			     recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND))
> diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
> index e2c0c510222..4b50488141f 100755
> --- a/t/t5520-pull.sh
> +++ b/t/t5520-pull.sh
> @@ -295,7 +295,7 @@ test_expect_success '--rebase (merge) fast forward' '
>  	# The above only validates the result.  Did we actually bypass rebase?
>  	git reflog -1 >reflog.actual &&
>  	sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
> -	echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
> +	echo "OBJID HEAD@{0}: pull --rebase . ff (finish): returning to refs/heads/to-rebase" >reflog.expected &&
>  	test_cmp reflog.expected reflog.fuzzy
>  '
>  
> @@ -307,8 +307,8 @@ test_expect_success '--rebase (am) fast forward' '
>  
>  	# The above only validates the result.  Did we actually bypass rebase?
>  	git reflog -1 >reflog.actual &&
> -	sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
> -	echo "OBJID HEAD@{0}: pull --rebase . ff: Fast-forward" >reflog.expected &&
> +	sed -e "s/^[0-9a-f][0-9a-f]*/OBJID/" -e "s/[0-9a-f][0-9a-f]*$/OBJID/" reflog.actual >reflog.fuzzy &&
> +	echo "OBJID HEAD@{0}: rebase finished: refs/heads/to-rebase onto OBJID" >reflog.expected &&
>  	test_cmp reflog.expected reflog.fuzzy
>  '
Previous: Felipe ContrerasNext: Elijah Newren
Message 18 of 59 in “Handle pull option precedence”
  1. 0/9 Handle pull option precedenceElijah Newren via GitGitGadget, Jul 17, 2021
  2. 2/9 t7601: add tests of interactions with multiple merge heads and configElijah Newren via GitGitGadget, Jul 17, 2021
  3. Felipe ContrerasJul 17, 2021
  4. Junio C HamanoJul 20, 2021
  5. Elijah NewrenJul 21, 2021
  6. 1/9 t7601: add relative precedence tests for merge and rebase flags/optionsElijah Newren via GitGitGadget, Jul 17, 2021
  7. Felipe ContrerasJul 17, 2021
  8. Junio C HamanoJul 19, 2021
  9. Elijah NewrenJul 20, 2021
  10. Junio C HamanoJul 20, 2021
  11. Felipe ContrerasJul 20, 2021
  12. 3/9 pull: abort if --ff-only is given and fast-forwarding is impossibleAlex Henrie via GitGitGadget, Jul 17, 2021
  13. Felipe ContrerasJul 17, 2021
  14. 4/9 pull: since --ff-only overrides, handle it firstElijah Newren via GitGitGadget, Jul 17, 2021
  15. Felipe ContrerasJul 17, 2021
  16. 5/9 pull: ensure --rebase overrides ability to ffElijah Newren via GitGitGadget, Jul 17, 2021
  17. Felipe ContrerasJul 17, 2021
  18. Junio C HamanoJul 20, 2021
  19. Elijah NewrenJul 21, 2021
  20. 6/9 pull: make --rebase and --no-rebase override pull.ff=onlyElijah Newren via GitGitGadget, Jul 17, 2021
  21. Felipe ContrerasJul 17, 2021
  22. Junio C HamanoJul 20, 2021
  23. Felipe ContrerasJul 21, 2021
  24. 8/9 pull: update docs & code for option compatibility with rebasingElijah Newren via GitGitGadget, Jul 17, 2021
  25. Junio C HamanoJul 21, 2021
  26. Elijah NewrenJul 21, 2021
  27. Junio C HamanoJul 21, 2021
  28. 7/9 pull: abort by default when fast-forwarding is not possibleElijah Newren via GitGitGadget, Jul 17, 2021
  29. Felipe ContrerasJul 17, 2021
  30. 9/9 pull: fix handling of multiple headsElijah Newren via GitGitGadget, Jul 17, 2021
  31. Felipe ContrerasJul 17, 2021
  32. 0/8 Handle pull option precedenceElijah Newren via GitGitGadget, Jul 21, 2021
  33. 3/8 pull: abort if --ff-only is given and fast-forwarding is impossibleAlex Henrie via GitGitGadget, Jul 21, 2021
  34. Felipe ContrerasJul 21, 2021
  35. 1/8 t7601: test interaction of merge/rebase/fast-forward flags and optionsElijah Newren via GitGitGadget, Jul 21, 2021
  36. Felipe ContrerasJul 21, 2021
  37. 2/8 t7601: add tests of interactions with multiple merge heads and configElijah Newren via GitGitGadget, Jul 21, 2021
  38. 5/8 pull: make --rebase and --no-rebase override pull.ff=onlyElijah Newren via GitGitGadget, Jul 21, 2021
  39. Felipe ContrerasJul 21, 2021
  40. 8/8 pull: fix handling of multiple headsElijah Newren via GitGitGadget, Jul 21, 2021
  41. 7/8 pull: update docs & code for option compatibility with rebasingElijah Newren via GitGitGadget, Jul 21, 2021
  42. 6/8 pull: abort by default when fast-forwarding is not possibleElijah Newren via GitGitGadget, Jul 21, 2021
  43. Felipe ContrerasJul 21, 2021
  44. 4/8 pull: since --ff-only overrides, handle it firstElijah Newren via GitGitGadget, Jul 21, 2021
  45. Matthias BaumgartenJul 21, 2021
  46. Felipe ContrerasJul 21, 2021
  47. Junio C HamanoJul 21, 2021
  48. Elijah NewrenJul 22, 2021
  49. Felipe ContrerasJul 21, 2021
  50. 0/8 Handle pull option precedenceElijah Newren via GitGitGadget, Jul 22, 2021
  51. 1/8 t7601: test interaction of merge/rebase/fast-forward flags and optionsElijah Newren via GitGitGadget, Jul 22, 2021
  52. 2/8 t7601: add tests of interactions with multiple merge heads and configElijah Newren via GitGitGadget, Jul 22, 2021
  53. 3/8 pull: abort if --ff-only is given and fast-forwarding is impossibleAlex Henrie via GitGitGadget, Jul 22, 2021
  54. 5/8 pull: make --rebase and --no-rebase override pull.ff=onlyElijah Newren via GitGitGadget, Jul 22, 2021
  55. 4/8 pull: since --ff-only overrides, handle it firstElijah Newren via GitGitGadget, Jul 22, 2021
  56. 6/8 pull: abort by default when fast-forwarding is not possibleElijah Newren via GitGitGadget, Jul 22, 2021
  57. 8/8 pull: fix handling of multiple headsElijah Newren via GitGitGadget, Jul 22, 2021
  58. 7/8 pull: update docs & code for option compatibility with rebasingElijah Newren via GitGitGadget, Jul 22, 2021
  59. Felipe ContrerasJul 22, 2021

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.