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

Re: [PATCH] Documentation: clarify whitespace rules for trailers

From
Christian Couder <christian.couder@gmail.com>
Date
Aug 25, 2022, 11:59 UTC
Message-ID
<CAP8UFD0EfhDo9ZMNSYp8YVHXJs6mYtSBs=hwoFZWWF3xZ0wjpg@mail.gmail.com>
In-Reply-To
<xmqq4jy18q7h.fsf@gitster.g>
On Wed, Aug 24, 2022 at 8:13 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Christian Couder <christian.couder@gmail.com> writes:
Show 40 quoted lines
> > -When reading trailers, there can be whitespaces after the
> > -token, the separator and the value. There can also be whitespaces
> > -inside the token and the value. The value may be split over multiple lines with
> > -each subsequent line starting with whitespace, like the "folding" in RFC 822.
> > +When reading trailers, there can be no whitespace inside the token,
> > +and only one regular space or tab character between the token and the
> > +separator.
>
> That may have been the intent, but does it match the behaviour?
>
>         static ssize_t find_separator(const char *line, const char *separators)
>         {
>                 int whitespace_found = 0;
>                 const char *c;
>                 for (c = line; *c; c++) {
>                         if (strchr(separators, *c))
>                                 return c - line;
>                         if (!whitespace_found && (isalnum(*c) || *c == '-'))
>                                 continue;
>                         if (c != line && (*c == ' ' || *c == '\t')) {
>                                 whitespace_found = 1;
>                                 continue;
>                         }
>                         break;
>                 }
>                 return -1;
>         }
>
> When parsing "X  :", first we encounter 'X', we haven't seen
> whitespace, 'X' passes isalnum(), and we continue.  Then we
> encounter ' ', we haven't seen whitespace but it is neither isalnum
> or dash, so we go on without hitting the first continue.  We are not
> at the beginning of the line, we are seeing a space, so we remember
> the fact that we saw whitespace and continue.  Next we see another ' ',
> we do not hit the first continue, we are not at the beginning of the
> line, and we are looking at ' ', so we again continue.  Finally, we see
> ':' that is a separator and we return happily.
>
> The code seems to be allowing zero or more space/tab before the
> separator.
Yeah, I agree. I misread the code. I will send a new version soon.
Thanks.
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 19 in “trailer: allow spaces in tokens”
  1. trailer: allow spaces in tokensMax Bernstein via GitGitGadget, Aug 18, 2022
  2. trailer: allow spaces in tokensMax Bernstein via GitGitGadget, Aug 18, 2022
  3. Junio C HamanoAug 18, 2022
  4. Jonathan TanAug 18, 2022
  5. Maxwell BernsteinAug 18, 2022
  6. Christian CouderAug 18, 2022
  7. Junio C HamanoAug 18, 2022
  8. Junio C HamanoAug 19, 2022
  9. Christian CouderAug 19, 2022
  10. Johannes SchindelinAug 22, 2022
  11. Documentation: clarify whitespace rules for trailersChristian Couder, Aug 23, 2022
  12. Junio C HamanoAug 24, 2022
  13. Christian CouderAug 25, 2022
  14. Junio C HamanoAug 25, 2022
  15. Documentation: clarify whitespace rules for trailersChristian Couder, Aug 30, 2022
  16. Junio C HamanoAug 30, 2022
  17. Junio C HamanoAug 18, 2022
  18. Jonathan TanAug 18, 2022
  19. Junio C HamanoAug 18, 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.