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

Re: [PATCH 2/2] merge: avoid searching for strategies with fewer than 0 conflicts

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 22, 2022, 16:19 UTC
Message-ID
<xmqqr118dzek.fsf@gitster.g>
In-Reply-To
<CABPp-BHy-Xs0S1-9kL7X4mi6JNfd420-vpVsswXNuXsc5C7AtA@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 14 quoted lines
> No, the original code would not have taken 'ort'.  You have overlooked
> the part of the code immediately above these two lines:
>
>     if (ret < 2) {
>         if (!ret) {
>             if (option_commit) {
>                 /* Automerge succeeded. */
>                 automerge_was_ok = 1;
>                 break;
>             }
>         merge_was_ok = 1;
>         }
>
> In particular, the "break" is key.

I noticed that much but then would "git merge --no-commit -s A -s B" have the issue?

> ...  In contrast, if the user did specify
> --no-commit and the previous strategy succeeded, then we will continue
> the loop.  That seems rather inconsistent, since --no-commit should
> not affect the choice of strategy.
Yeah, exactly.
Show 7 quoted lines
> However, I missed two things in my reading.  You are correct that I
> missed the "<=" as opposed to "<" when I wrote my commit message,
> though that turns out to not matter much due to the second thing.  The
> second thing I missed was part of the code at the beginning of the
> loop:
>
>     for (i = 0; !merge_was_ok && i < use_strategies_nr; i++) {

Ahhhh, that explains it. We leave as soon as we find merge_was_ok so this patch is not necessary. There is nothing to fix. The original was fine as-is.

Thanks.
Previous: Elijah NewrenNext: Elijah Newren
Message 5 of 15 in “Miscellaneous merge fixes”
  1. 0/2 Miscellaneous merge fixesElijah Newren via GitGitGadget, Aug 21, 2022
  2. 2/2 merge: avoid searching for strategies with fewer than 0 conflictsElijah Newren via GitGitGadget, Aug 21, 2022
  3. Junio C HamanoAug 21, 2022
  4. Elijah NewrenAug 22, 2022
  5. Junio C HamanoAug 22, 2022
  6. Elijah NewrenAug 23, 2022
  7. 1/2 merge: only apply autostash when appropriateElijah Newren via GitGitGadget, Aug 21, 2022
  8. Eric SunshineAug 21, 2022
  9. Elijah NewrenAug 21, 2022
  10. 0/3 Miscellaneous merge fixesElijah Newren via GitGitGadget, Aug 23, 2022
  11. 1/3 merge: only apply autostash when appropriateElijah Newren via GitGitGadget, Aug 23, 2022
  12. 2/3 merge: cleanup confusing logic for handling successful mergesElijah Newren via GitGitGadget, Aug 23, 2022
  13. 3/3 merge: small code readability improvementElijah Newren via GitGitGadget, Aug 23, 2022
  14. Elijah NewrenAug 23, 2022
  15. Junio C HamanoAug 24, 2022

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.