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

Re: [PATCHv3] Teach -f/--force-rebase option to 'rebase -i'.

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 23, 2010, 22:42 UTC
Message-ID
<7vzl1yd5j4.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1269361187-31291-1-git-send-email-marcnarc@xiplink.com>
Marc Branchaud <marcnarc@xiplink.com> writes:
Show 22 quoted lines
> This option tells rebase--interactive to cherry-pick all the commits in the
> rebased branch, instead of fast-forwarding over any unchanged commits.
>
> Also expanded -f's description in rebase's man page.
>
> -f offers an alterntive way to deal with reverted merges.  Instead of
> "reverting the revert" you can use "rebase -f [-i]" to recreate the branch
> with entirely new commits (they're new because at the very least the
> committer time is different).  This obviates the need to revert the
> reversion, as you can re-merge the new topic branch directly.  Added an
> addendum to revert-a-faulty-merge.txt describing the situation and how to
> use -f to handle it.
>
> Signed-off-by: Marc Branchaud <marcnarc@xiplink.com>
> ---
>
> It seems more natural to me to just teach -f to "rebase -i" instead of adding
> a new --no-ff option.
>
> This patch combines my initial "--no-ff" patch with the documentation changes
> in my "reword" patch.  I moved the unit test for "rebase -f -i" into
> t3404-rebase-interactive.sh.
Hmm, to be honest, this is not what I expected.

A non-interactive "rebase" will _refuse_ to do anything, because it knows that the end result will be exactly the same, in a fast-forward situation. In general, the option "--force" is "I know the precondition I am in will trigger your logic to refuse this request---but please do so anyway", and the use of that option in non-interactive one is in line with that definition. So "--force" makes perfect sense to non-interactive rebase.

But "rebase -i" cannot _refuse_ when the range to be rebased is already fast-forward, as the whole point of the command is to be able to rewrite chosen commits, and that "rewriting chosen commits" is the reason why it makes sense for the command to fast-forward the earlier picks that were not chosen to be rewritten. But "forcing" doesn't make sense, if the command does not even refuse to begin with. So "--no-ff" is sensible there.

What I meant was that as a measure to prepare for a future merge of (corrected) side branch whose earlier merge was once reverted, it would make sense to use "rebase -f" without any "interactive", compared to the "start rebase -i, and to ensure it wouldn't fast-forward, lie to it that you will reword the first one and do nothing in reality", which your earlier documentation suggested.

If anything, teaching --no-ff to non-interactive rebase would also make sense. Just like saying "I know you will refuse if it is a fast forward, but please do so anyway" with --force makes sense, it is sensible to say "I know you will make this a no-op if it is a fast forward, but please rewrite all of them" with --no-ff.

Previous: Marc BranchaudNext: Marc Branchaud
Message 20 of 32 in “Teach --no-ff option to 'rebase -i'.”
  1. Teach --no-ff option to 'rebase -i'.Marc Branchaud, Mar 16, 2010
  2. Marc BranchaudMar 16, 2010
  3. [PATCHv2] Teach --no-ff option to 'rebase -i'.Marc Branchaud, Mar 16, 2010
  4. Jonathan NiederMar 16, 2010
  5. Johannes SixtMar 17, 2010
  6. Peter BaumannMar 17, 2010
  7. Johannes SixtMar 17, 2010
  8. Peter BaumannMar 17, 2010
  9. Johannes SixtMar 18, 2010
  10. Peter BaumannMar 18, 2010
  11. Marc BranchaudMar 17, 2010
  12. Johannes SixtMar 17, 2010
  13. Marc BranchaudMar 17, 2010
  14. Test that the 'rebase -i' "reword" command always cherry-picks a commit.Marc Branchaud, Mar 22, 2010
  15. Avery PennarunMar 22, 2010
  16. Marc BranchaudMar 22, 2010
  17. Junio C HamanoMar 22, 2010
  18. Marc BranchaudMar 23, 2010
  19. [PATCHv3] Teach -f/--force-rebase option to 'rebase -i'.Marc Branchaud, Mar 23, 2010
  20. Junio C HamanoMar 23, 2010
  21. 0/2 Teach the --no-ff option to 'rebase -i'.Marc Branchaud, Mar 24, 2010
  22. Junio C HamanoMar 24, 2010
  23. [PATCHv5] Teach rebase the --no-ff option.Marc Branchaud, Mar 24, 2010
  24. Junio C HamanoMar 24, 2010
  25. 1/2 Teach 'rebase -i' to accept and ignore the -f/--force-rebase option.Marc Branchaud, Mar 24, 2010
  26. 2/2 Teach the --no-ff option to 'rebase -i'.Marc Branchaud, Mar 24, 2010
  27. Junio C HamanoMar 24, 2010
  28. Jonathan NiederMar 23, 2010
  29. Jonathan NiederMar 22, 2010
  30. Marc BranchaudMar 17, 2010
  31. Jonathan NiederMar 17, 2010
  32. Jonathan NiederMar 17, 2010

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.