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

Re: [PATCH] rebase: mark --update-refs as requiring the merge backend

From
Elijah Newren <newren@gmail.com>
Date
Jan 20, 2023, 01:54 UTC
Message-ID
<CABPp-BFMJZx8BfWK5NPSt_4Mjz+MGA7d6_jwBivm-5A9fovbWw@mail.gmail.com>
In-Reply-To
<f480813c-7583-179f-0149-d970d3f2519f@github.com>
On Thu, Jan 19, 2023 at 1:47 PM Derrick Stolee <derrickstolee@github.com> wrote:
Show 29 quoted lines
>
> On 1/19/2023 12:36 AM, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > --update-refs is built in terms of the sequencer, which requires the
> > merge backend.  It was already marked as incompatible with the apply
> > backend in the git-rebase manual, but the code didn't check for this
> > incompatibility and warn the user.  Check and warn now.
>
> Thank you for submitting this version.
>
> > @@ -1514,6 +1514,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
> >               }
> >       }
> >
> > +     if (options.update_refs)
> > +             imply_merge(&options, "--update-refs");
> > +
>
> This solution is very elegant. The only downside is the lack of warning
> if --update-refs was implied by rebase.updateRefs=true, but I'm happy to
> delay implementing that warning in favor of your complete solution here.
>
> Thinking ahead to that option, are there other options that are implied
> by config that are required in imply_merge()? Is --autosquash in that
> camp? If so, then maybe it would make sense to expand imply_merge() to
> include a boolean config key and supply that warning within its
> implementation. (This consideration should not block this patch, as it
> is complete as-is.)
Ooh, that does sound like a useful future idea to improve things further.
Show 21 quoted lines
> > While at it, fix a typo in t3422...and fix some misleading wording (all
> > useful options other than --whitespace=fix have long since been
> > implemented in the merge backend).
>
> >  #
> > -# Rebase has lots of useful options like --whitepsace=fix, which are
> > -# actually all built in terms of flags to git-am.  Since neither
> > -# --merge nor --interactive (nor any options that imply those two) use
> > -# git-am, using them together will result in flags like --whitespace=fix
> > -# being ignored.  Make sure rebase warns the user and aborts instead.
> > +# Rebase has a useful option, --whitespace=fix, which is actually
> > +# built in terms of flags to git-am.  Since neither --merge nor
> > +# --interactive (nor any options that imply those two) use git-am,
> > +# using them together will result in --whitespace=fix being ignored.
> > +# Make sure rebase warns the user and aborts instead.
> >  #
>
> Thanks for the update here. The -C option is also used in this test,
> so --whitespace=fix isn't the only option, right? At least, -C doesn't
> make sense to port over to the merge backend, so maybe that's what
> you mean by --whitespace=fix being the last one?

Sorry if it was confusing. I was trying to figure out how to word it to remove the old confusion, and actually spent a while thinking about this point you brought up...but after a while gave up and just submitted my patch because it was taking too long and I didn't think the -C option was worth as much brain power as has been spent on it. But since you noted the incongruity, let me explain my thought process a little...

* I stated that --whitespace=... was the last *useful* option, not
that it was the last option.  Yes, that was an implicit assertion that
-C is not useful, though I avoided stating it directly for fear I'd
have to dig up proof and/or spend a bunch of time trying to reproduce
an old bug and debug it.
* The correct way to port the '-C' option to the merge backend would
probably be to just accept the flag and ignore it.  The merge backend
already functions with entire files or essentially infinite context.
I can't think of any case where ignoring this option would result in
negative surprises, other than possibly confusing people about how the
algorithm behaves and making them decide to tweak it to no avail.  And
even if users were to waste time twiddling that flag in combination
with the merge backend, even that might be a correct "port" of the
existing -C option because...
* I once tried to use the '-C' option with the apply backend to see if
it could workaround a bug inherent to the apply backend (where people
have a source file with several very similar code blocks, and rebase
or am applying changes to the wrong one due to fuzz factor and large
deletions/insertions having happened upstream elsewhere in the file).
It appeared to have absolutely no effect.  I suspected it was buggy,
but didn't feel the option was worth debugging (I thought switching
the default rebase backend was a much better use of time).
* We have *zero* tests of the functionality of rebase's -C option in
the testsuite.  The only testing we do for rebase's -C option is
solely around option parsing.
....

And you inspired me to do some digging. rebase -C was introduced with 67dad687ad ("add -C[NUM] to git-am", 2007-02-08). Based on feedback on the patch, the author added the -C option not just to git-am but also to git-rebase. However, the way it was added to rebase was to just pass it through to git-am, with no corresponding option to format-patch. Therefore, format-patch is going to continue generating patches with 3 lines of context, while we tell git-am/git-apply to pay attention to more than 3 lines of context. The -C<num> option is documented as using all available context if <num> exceeds the number of lines of context provided in the input patches. So, the -C option to rebase has never done anything useful, and the port from the legacy rebase script to the builtin C did not accidentally introduce any modicum of utility to this option; rather, it faithfully ported this pointless option precisely as-is.

So, I'll adjust this series to include a preliminary patch that rips the rebase -C option out.

Show 21 quoted lines
> The user could also explicitly request the apply backend with --apply,
> but this test script doesn't check it, strangely. That seems like an
> oversight, but not a drawback to your patch.
>
> >  test_rebase_am_only () {
> > @@ -60,6 +60,11 @@ test_rebase_am_only () {
> >               test_must_fail git rebase $opt --exec 'true' A
> >       "
> >
> > +     test_expect_success "$opt incompatible with --update-refs" "
> > +             git checkout B^0 &&
> > +             test_must_fail git rebase $opt --update-refs A
> > +     "
> > +
>
> Thanks for adding this test. I would delay the rebase.updateRefs
> version until there is extra behavior to check, such as the
> warning message.
>
> Thanks,
> -Stolee
Previous: Derrick StoleeNext: Junio C Hamano
Message 3 of 70 in “rebase: mark --update-refs as requiring the merge backend”
  1. rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 19, 2023
  2. Derrick StoleeJan 19, 2023
  3. Elijah NewrenJan 20, 2023
  4. Junio C HamanoJan 20, 2023
  5. Elijah NewrenJan 20, 2023
  6. 0/2 rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 20, 2023
  7. 1/2 rebase: remove completely useless -C optionElijah Newren via GitGitGadget, Jan 20, 2023
  8. Eric SunshineJan 20, 2023
  9. Elijah NewrenJan 20, 2023
  10. Martin ÅgrenJan 20, 2023
  11. Elijah NewrenJan 20, 2023
  12. Junio C HamanoJan 20, 2023
  13. Elijah NewrenJan 20, 2023
  14. Junio C HamanoJan 20, 2023
  15. Elijah NewrenJan 21, 2023
  16. Junio C HamanoJan 22, 2023
  17. 2/2 rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 20, 2023
  18. Phillip WoodJan 20, 2023
  19. Elijah NewrenJan 21, 2023
  20. 0/7 rebase: fix several code/testing/documentation issues around flag incompatibilitiesElijah Newren via GitGitGadget, Jan 21, 2023
  21. 1/7 rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 21, 2023
  22. 2/7 rebase: flag --apply and --merge as incompatibleElijah Newren via GitGitGadget, Jan 21, 2023
  23. 3/7 rebase: remove --allow-empty-message from incompatible optsElijah Newren via GitGitGadget, Jan 21, 2023
  24. Phillip WoodJan 21, 2023
  25. 4/7 rebase: fix docs about incompatibilities with --rootElijah Newren via GitGitGadget, Jan 21, 2023
  26. 5/7 rebase: add coverage of other incompatible optionsElijah Newren via GitGitGadget, Jan 21, 2023
  27. Phillip WoodJan 21, 2023
  28. Phillip WoodJan 21, 2023
  29. Elijah NewrenJan 22, 2023
  30. 6/7 rebase: clarify the OPT_CMDMODE incompatibilitiesElijah Newren via GitGitGadget, Jan 21, 2023
  31. 7/7 rebase: fix formatting of rebase --reapply-cherry-picks option in docsElijah Newren via GitGitGadget, Jan 21, 2023
  32. Phillip WoodJan 21, 2023
  33. 0/9 rebase: fix several code/testing/documentation issues around flag incompatibilitiesElijah Newren via GitGitGadget, Jan 22, 2023
  34. 2/9 rebase: flag --apply and --merge as incompatibleElijah Newren via GitGitGadget, Jan 22, 2023
  35. 1/9 rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 22, 2023
  36. 3/9 rebase: remove --allow-empty-message from incompatible optsElijah Newren via GitGitGadget, Jan 22, 2023
  37. 8/9 rebase: put rebase_options initialization in single placeElijah Newren via GitGitGadget, Jan 22, 2023
  38. 5/9 rebase: add coverage of other incompatible optionsElijah Newren via GitGitGadget, Jan 22, 2023
  39. Phillip WoodJan 23, 2023
  40. Elijah NewrenJan 24, 2023
  41. Phillip WoodJan 24, 2023
  42. Phillip WoodJan 24, 2023
  43. Junio C HamanoJan 24, 2023
  44. Elijah NewrenJan 24, 2023
  45. Phillip WoodJan 24, 2023
  46. Elijah NewrenJan 24, 2023
  47. Phillip WoodJan 24, 2023
  48. 9/9 rebase: provide better error message for apply options vs. merge configElijah Newren via GitGitGadget, Jan 22, 2023
  49. 4/9 rebase: fix docs about incompatibilities with --rootElijah Newren via GitGitGadget, Jan 22, 2023
  50. 7/9 rebase: fix formatting of rebase --reapply-cherry-picks option in docsElijah Newren via GitGitGadget, Jan 22, 2023
  51. 6/9 rebase: clarify the OPT_CMDMODE incompatibilitiesElijah Newren via GitGitGadget, Jan 22, 2023
  52. Derrick StoleeJan 23, 2023
  53. Elijah NewrenJan 24, 2023
  54. 00/10 rebase: fix several code/testing/documentation issues around flag incompatibilitiesElijah Newren via GitGitGadget, Jan 25, 2023
  55. 01/10 rebase: mark --update-refs as requiring the merge backendElijah Newren via GitGitGadget, Jan 25, 2023
  56. 02/10 rebase: flag --apply and --merge as incompatibleElijah Newren via GitGitGadget, Jan 25, 2023
  57. 03/10 rebase: remove --allow-empty-message from incompatible optsElijah Newren via GitGitGadget, Jan 25, 2023
  58. 04/10 rebase: fix docs about incompatibilities with --rootElijah Newren via GitGitGadget, Jan 25, 2023
  59. 05/10 rebase: fix incompatiblity checks for --[no-]reapply-cherry-picksElijah Newren via GitGitGadget, Jan 25, 2023
  60. Phillip WoodJan 25, 2023
  61. 08/10 rebase: fix formatting of rebase --reapply-cherry-picks option in docsElijah Newren via GitGitGadget, Jan 25, 2023
  62. 06/10 rebase: add coverage of other incompatible optionsElijah Newren via GitGitGadget, Jan 25, 2023
  63. 07/10 rebase: clarify the OPT_CMDMODE incompatibilitiesElijah Newren via GitGitGadget, Jan 25, 2023
  64. 10/10 rebase: provide better error message for apply options vs. merge configElijah Newren via GitGitGadget, Jan 25, 2023
  65. 09/10 rebase: put rebase_options initialization in single placeElijah Newren via GitGitGadget, Jan 25, 2023
  66. Phillip WoodJan 25, 2023
  67. Junio C HamanoJan 25, 2023
  68. Elijah NewrenJan 25, 2023
  69. rebase --merge vs --whitespace=fix, was Re: [PATCH v5 00/10] rebase: fix several code/testing/documentation issues around flag incompatibilitiesJohannes Schindelin, Feb 2, 2023
  70. Elijah NewrenFeb 2, 2023

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.