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
Elijah Newren <newren@gmail.com>
Date
Aug 23, 2022, 01:18 UTC
Message-ID
<CABPp-BHH6isv7iRKee34c1AEJ8JT5iUX7i7j6s9CVbmYN0Ervw@mail.gmail.com>
In-Reply-To
<xmqqr118dzek.fsf@gitster.g>
On Mon, Aug 22, 2022 at 9:19 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
[...]
Show 18 quoted lines
> > ...  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.
>
> > 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.

Right, there was no bug or even optimization opportunity in the original, it was just confusing...as evidenced by the fact that we both misread the code.

The fact that we both misread the code, though, suggests there is something to fix: code readability.

Previous: Junio C HamanoNext: Elijah Newren via GitGitGadget
Message 6 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.