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

Re: [PATCH v4 5/9] rebase: add coverage of other incompatible options

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Jan 24, 2023, 10:27 UTC
Message-ID
<83d27162-59d4-d8c0-fde3-f522630d024d@dunelm.org.uk>
In-Reply-To
<CABPp-BE+wRgjmWknARQpNsdUFjNOz0ND9wgx_-_RTyK+EwJjXA@mail.gmail.com>
Hi Elijah
On 24/01/2023 02:36, Elijah Newren wrote:
Show 75 quoted lines
> Hi Phillip,
> 
> On Mon, Jan 23, 2023 at 12:08 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>>
>> Hi Elijah
>>
>> On 22/01/2023 06:12, Elijah Newren via GitGitGadget wrote:
>>> From: Elijah Newren <newren@gmail.com>
>>>
>>> The git-rebase manual noted several sets of incompatible options, but
>>> we were missing tests for a few of these.  Further, we were missing
>>> code checks for some of these, which could result in command line
>>> options being silently ignored.
>>>
>>> Also, note that adding a check for autosquash means that using
>>> --whitespace=fix together with the config setting rebase.autosquash=true
>>> will trigger an error.  A subsequent commit will improve the error
>>> message.
>>
>> Thanks for updating the commit message and for the new commits at the
>> end of the series.
>>
>>> Signed-off-by: Elijah Newren <newren@gmail.com>
>>> --- a/builtin/rebase.c
>>> +++ b/builtin/rebase.c
>>> @@ -1224,6 +1224,26 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>>>                if (options.fork_point < 0)
>>>                        options.fork_point = 0;
>>>        }
>>> +     /*
>>> +      * The apply backend does not support --[no-]reapply-cherry-picks.
>>> +      * The behavior it implements by default is equivalent to
>>> +      * --no-reapply-cherry-picks (due to passing --cherry-picks to
>>> +      * format-patch), but --keep-base alters the upstream such that no
>>> +      * cherry-picks can be found (effectively making it act like
>>> +      * --reapply-cherry-picks).
>>> +      *
>>> +      * Now, if the user does specify --[no-]reapply-cherry-picks, but
>>> +      * does so in such a way that options.reapply_cherry_picks ==
>>> +      * keep_base, then the behavior they get will match what they
>>> +      * expect despite options.reapply_cherry_picks being ignored.  We
>>> +      * could just allow the flag in that case, but it seems better to
>>> +      * just alert the user that they've specified a flag that the
>>> +      * backend ignores.
>>> +      */
>>
>> I'm a bit confused by this. --keep-base works with either
>> --reapply-cherry-picks (which is the default if --keep-base is given) or
>> --no-reapply-cherry-picks. Just below this hunk we have
>>
>>          if (options.reapply_cherry_picks < 0)
>>                  options.reapply_cherry_picks = keep_base;
>>
>> So we only set options.reapply_cherry_picks to match keep_base if the
>> user did not specify -[-no]-reapply-cherry-picks on the commandline.
> 
> options.reapply_cherry_picks is totally ignored by the apply backend,
> regardless of whether it's set by the user or the setup code in
> builtin/rebase.c.  And if we have an option which is ignored, isn't it
> nicer to provide an error message to the user if they tried to set it?
> 
> Said another way, while users could start with these command lines:
> 
>      (Y) git rebase --whitespace=fix
>      (Z) git rebase --whitespace=fix --keep-base
> 
> and modify them to include flags that would be ignored, we could allow:
> 
>      (A) git rebase --whitespace=fix --no-reapply-cherry-picks
>      (B) git rebase --whitespace=fix --keep-base --reapply-cherry-picks
> 
> But we could not allow commands like
> 
>      (C) git rebase --whitespace=fix --reapply-cherry-picks
>      (D) git rebase --whitespace=fix --keep-base --no-reapply-cherry-picks

(C) is already an error (D) is currently allowed and I think works as expected (--keep-base only implies --reapply-cherry-picks, the user is free to override that with --no-reapply-cherry-picks) so I don't see why we'd want to make it an error.

> For all four cases (A)-(D), the apply backend will ignore whatever
> --[no-]reapply-cherry-picks flag is provided.

For (D) the flag is respected, (C) errors out, the other cases correspond to the default so it's like saying

	git rebase --merge --no-reapply-cherry-picks

ignores the flag. Arguably it is confusing that the apply backend only supports -[-no]-reapply-cherry-picks if --keep-base is given but I'm not sure that is a good reason to reject a combination that currently works as expected.

Best Wishes
Phillip
Show 39 quoted lines
> For (A) and (B), the > behavior the apply backend provides happens to match what the user
> is requesting, while for (C) and (D) the behavior does not match.
> So we should at least reject (C) and (D).  But, although we could
> technically allow (A) and (B), what advantage would it provide?  I
> think the results of allowing those two commands would be:
> 
>      1) Confusion by end users -- why should (C) & (D) throw errors if
>         (A) and (B) are accepted?  That's not an easy rule to understand.
> 
>      2) More confusion by end users -- the documentation for years has
>         stated that --reapply-cherry-picks is incompatible with the apply
>         backend, suggesting users would be surprised if at least (B) and
>         probably (A) didn't throw error messages.
> 
>      3) Confusing documentation -- If we don't want to throw errors for
>         (A) and (B), how do we modify the "INCOMPATIBLE OPTIONS" section
>         of Documentation/git-rebase.txt to explain the relevant details
>         of when these flags are (or are not) incompatible with the apply
>         backend?   I think it'd end up with a very verbose explanation
>         that likely confuses more than it helps.
> 
>      4) Excessively complicated code -- The previous attempts to
>         implement this got it wrong.  Prior to ce5238a690 ("rebase
>         --keep-base: imply --reapply-cherry-picks", 2022-10-17), the code
>         would error out on (B) and (C).  After that commit, it would only
>         error out on (C).  Both solutions are incorrect since they miss
>         (D), and I think the code just becomes hard to hard to follow in
>         order to only error out on both (C) and (D) without (A) and (B).
> 
> (#2 and #3 might just be a repeat of the same issue, documentation,
> but it seemed easier to write separately.)
> 
> I think it's simpler for the code, for the documentation, and for end
> users to just error out on all of (A), (B), (C), and (D).
>   --[no-]reapply-cherry-picks is not supported by the apply backend.
> 
> But, given this lengthy email, perhaps I should split out the handling
> of --[no-]reapply-cherry-picks into its own commit and copy some or
> all of the description above into the commit message?
Previous: Elijah NewrenNext: Phillip Wood
Message 41 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.