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

Re: [PATCH v2 4/4] rebase: add a config option for --rebase-merges

From
Alex Henrie <alexhenrie24@gmail.com>
Date
Feb 22, 2023, 01:41 UTC
Message-ID
<CAMMLpeQpSMVm0ZNMNz20+9bKAGhn4pFwTX62nR+B-V-KzvqT+A@mail.gmail.com>
In-Reply-To
<d1f10c52-9cfb-8e6a-cbd6-cd81b778b8cc@dunelm.org.uk>
On Tue, Feb 21, 2023 at 3:46 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
Show 7 quoted lines
>
> On 21/02/2023 05:58, Alex Henrie wrote:
> > +rebase.merges::
> > +     Default value of `--rebase-merges` option.
>
> Below I see this takes a boolean in addition to [no-]rebase-cousins, it
> would be nice to document that, especially what "true" means.

Good point. I'll add another sentence explaining that "true" is equivalent to --rebase-merges without arguments and "false" is equivalent to --no-rebase-merges.

Show 16 quoted lines
> > +     if (!strcmp(var, "rebase.merges")) {
> > +             const char *rebase_merges;
> > +             if (!git_config_string(&rebase_merges, var, value) &&
> > +                 rebase_merges && *rebase_merges) {
>
> rebase_merges is guaranteed to be non-NULL if git_config_string returns 0.
>
> > +                     opts->rebase_merges = git_parse_maybe_bool(rebase_merges);
> > +                     if (opts->rebase_merges < 0)
> > +                             parse_merges_value(opts, rebase_merges);
> > +             }
> > +             return 0;
> > +     }
>
> I think this leaks rebase_merges as git_config_string() returns a copy
> despite taking a "const char*".

Come to think of it, I don't think we need git_config_string at all here. As far as I can tell, it should be fine to just check (value && *value) and not duplicate the string in memory.

Show 5 quoted lines
> > +test_expect_success 'rebase.merges="" is equivalent to not passing --rebase-merges' '
> > +     git config rebase.merges "" &&
>
> test_config is generally preferred as it clears the value at the end of
> the test. Then you don't need the final hunk of this patch.
I've used test_config before but I forgot about it. Thanks for the reminder.
-Alex
Previous: Phillip WoodNext: Phillip Wood
Message 16 of 17 in “rebase: document the --no-rebase-merges option”
  1. 1/4 rebase: document the --no-rebase-merges optionAlex Henrie, Feb 21, 2023
  2. 2/4 rebase: add tests for --no-rebase-mergesAlex Henrie, Feb 21, 2023
  3. Phillip WoodFeb 21, 2023
  4. Alex HenrieFeb 22, 2023
  5. Phillip WoodFeb 22, 2023
  6. Alex HenrieFeb 23, 2023
  7. 3/4 rebase: stop accepting --rebase-merges=""Alex Henrie, Feb 21, 2023
  8. Phillip WoodFeb 21, 2023
  9. Alex HenrieFeb 22, 2023
  10. Alex HenrieFeb 22, 2023
  11. Phillip WoodFeb 22, 2023
  12. Junio C HamanoFeb 22, 2023
  13. Alex HenrieFeb 22, 2023
  14. 4/4 rebase: add a config option for --rebase-mergesAlex Henrie, Feb 21, 2023
  15. Phillip WoodFeb 21, 2023
  16. Alex HenrieFeb 22, 2023
  17. Phillip WoodFeb 21, 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.