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

Re: [PATCH] rev-parse: match @{u}, @{push} and ^{<type>} case-insensitively

From
Jeff King <peff@peff.net>
Date
Mar 21, 2017, 19:43 UTC
Message-ID
<20170321194330.5nghzisbud5yy6wq@sigill.intra.peff.net>
In-Reply-To
<CACBZZX6g694p9WkiK75+HJCLUPwjpdQhjBrAU713KahAKm53hA@mail.gmail.com>
On Tue, Mar 21, 2017 at 08:19:34PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 23 quoted lines
> On Sat, Mar 18, 2017 at 11:34 PM, Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
> 
> > The new starts_with_case() function is a copy of the existing adjacent
> > starts_with(), just with a tolower() in the "else if".
> > [...]
> > +int starts_with_case(const char *str, const char *prefix)
> > +{
> > +       for (; ; str++, prefix++)
> > +               if (!*prefix)
> > +                       return 1;
> > +               else if (tolower(*str) != tolower(*prefix))
> > +                       return 0;
> > +}
> > +
> >  /*
> 
> One thing I'd like feedback on is whether I should be adding this to
> strbuf.c. There are >300 uses of starts_with(), but sha1_name.c will
> be the only one using this modified starts_with_case() function.
> Wouldn't it be better to just add it to sha1_name.c rather than
> expanding the strbuf API with something that'll likely be used by
> nothing else for a while?

I was thinking that I had written this same function before (in a patch that didn't end up merged), but it was actually the related skip_prefix_icase(). I'm fine with it either next to starts_with() or as a static next to its callers.

-Peff
Previous: Junio C Hamano
Message 24 of 24 in “rev-parse: match @{u}, @{push} and ^{<type>} case-insensitively”
  1. rev-parse: match @{u}, @{push} and ^{<type>} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 18, 2017
  2. Duy NguyenMar 19, 2017
  3. Ævar Arnfjörð BjarmasonMar 19, 2017
  4. Junio C HamanoMar 19, 2017
  5. Ævar Arnfjörð BjarmasonMar 19, 2017
  6. Junio C HamanoMar 19, 2017
  7. 0/3 rev-parse case insensitivity & @{p} synonymÆvar Arnfjörð Bjarmason, Mar 26, 2017
  8. 1/3 rev-parse: match @{upstream}, @{u} and @{push} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 26, 2017
  9. Junio C HamanoMar 27, 2017
  10. rev-parse: match @{upstream}, @{u} and @{push} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 27, 2017
  11. Junio C HamanoMar 27, 2017
  12. Ævar Arnfjörð BjarmasonMar 27, 2017
  13. 2/3 rev-parse: add @{p} as a synonym for @{push}Ævar Arnfjörð Bjarmason, Mar 26, 2017
  14. Jeff KingMar 27, 2017
  15. Ævar Arnfjörð BjarmasonMar 27, 2017
  16. 3/3 rev-parse: match ^{<type>} case-insensitivelyÆvar Arnfjörð Bjarmason, Mar 26, 2017
  17. Junio C HamanoMar 27, 2017
  18. Jeff KingMar 27, 2017
  19. Junio C HamanoMar 27, 2017
  20. Jeff KingMar 27, 2017
  21. Ævar Arnfjörð BjarmasonMar 27, 2017
  22. Ævar Arnfjörð BjarmasonMar 21, 2017
  23. Junio C HamanoMar 21, 2017
  24. Jeff KingMar 21, 2017

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.