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

Re: [PATCH v2 5/7] rebase: don't have loop over "struct strvec" depend on signed "nr"

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Sep 12, 2021, 02:57 UTC
Message-ID
<CAPig+cTWjqCiW=M37sf41F7-M0U=fJdTgtM_YqdPTqS53rFHHg@mail.gmail.com>
In-Reply-To
<patch-v2-5.7-be85a0565ef-20210912T001420Z-avarab@gmail.com>

On Sat, Sep 11, 2021 at 8:16 PM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 13 quoted lines
> As in the preceding commit, prepare for the "nr" member of "struct
> strvec" changing from an "int" to a "size_t".
>
> Let's change this code added in f57696802c3 (rebase: really just
> passthru the `git am` options, 2018-11-14) so that it won't cause a
> bug if the "i" variable here is updated to be a "size_t" instead of an
> "int".
>
> The reason it would be buggy is because this for-loop relied on
> "counting down" from nr-1 to 0, we'll then decrement the variable one
> last time, so a value of -1 indicates that we've visited all
> elements. Since we're looking for a needle in the haystack having
> looked at all the hay means that the needle isn't there.
s/haystack/&,/
> Let's replace this with simpler code that loops overthe "struct
> strvec" and checks the current needle is "-q", if it isn't and we're
> doing a merge we die, otherwise we do a "REBASE_APPLY".
s/overthe/over the/
Nit: comma-splice[1] at `"-q",`; replace comma with semicolon or period.
[1]: https://lore.kernel.org/git/CAPx1GvfFPWvJsj+uJV7RZrv1rgEpio=pk6rKF2UrjHebVY=LPA@mail.gmail.com/
Show 6 quoted lines
> We've been able to simplify this code since 8295ed690bf (rebase: make
> the backend configurable via config setting, 2020-02-15) when we
> stopped using this for anything except this one check, so let's do
> that and move the check into the loop itself.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 12 of 23 in “strvec: use size_t to store nr and alloc”
  1. strvec: use size_t to store nr and allocJeff King, Sep 11, 2021
  2. Ævar Arnfjörð BjarmasonSep 11, 2021
  3. Philip OakleySep 11, 2021
  4. 0/7 strvec: use size_t to store nr and allocÆvar Arnfjörð Bjarmason, Sep 12, 2021
  5. 1/7 remote-curl: pass "struct strvec *" instead of int/char ** pairÆvar Arnfjörð Bjarmason, Sep 12, 2021
  6. Carlo ArenasSep 12, 2021
  7. Ævar Arnfjörð BjarmasonSep 13, 2021
  8. 2/7 pack-objects: pass "struct strvec *" instead of int/char ** pairÆvar Arnfjörð Bjarmason, Sep 12, 2021
  9. 3/7 sequencer.[ch]: pass "struct strvec *" instead of int/char ** pairÆvar Arnfjörð Bjarmason, Sep 12, 2021
  10. 4/7 upload-pack.c: pass "struct strvec *" instead of int/char ** pairÆvar Arnfjörð Bjarmason, Sep 12, 2021
  11. 5/7 rebase: don't have loop over "struct strvec" depend on signed "nr"Ævar Arnfjörð Bjarmason, Sep 12, 2021
  12. Eric SunshineSep 12, 2021
  13. 6/7 strvec: use size_t to store nr and allocÆvar Arnfjörð Bjarmason, Sep 12, 2021
  14. 7/7 strvec API users: change some "int" tracking "nr" to "size_t"Ævar Arnfjörð Bjarmason, Sep 12, 2021
  15. Eric SunshineSep 12, 2021
  16. Jeff KingSep 12, 2021
  17. Junio C HamanoSep 13, 2021
  18. Ævar Arnfjörð BjarmasonSep 13, 2021
  19. Jeff KingSep 13, 2021
  20. Philip OakleySep 13, 2021
  21. Jeff KingSep 12, 2021
  22. Philip OakleySep 13, 2021
  23. Jeff KingSep 12, 2021

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.