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

Re: [PATCH 1/1] rebase -r: let `label` generate safer labels

From
Matt Rogers <mattr94@gmail.com>
Date
Sep 3, 2019, 22:40 UTC
Message-ID
<CAOjrSZsFeGsuNM2v=fPMnbHJH27Z6NU3UQrgoWt-peXjzWsD+w@mail.gmail.com>
In-Reply-To
<xmqq5zm9taza.fsf@gitster-ct.c.googlers.com>
I agree that the code locally was simple enough.

Ultimately I feel that sanitizing and uniqueifying the label should probably be done closer together/at the same place. I'm just not familiar enough with the codebase to know a good place (if any) to move that to. Eventually though this would still need to be expanded further to protect against reserved filenames (e.g. NUL on windows). Although the behavior around these (espescially with file extensions like NUL.txt) become less reliable, and although they are much more unlikely to be encountered in practice, are still allowed by git as oneliners.

On Tue, Sep 3, 2019 at 3:51 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
>
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > If you care deeply about double dashes and leading dashes, how about
> > this instead?
> >
> >               char *from, *to;
> >
> >               for (from = to = label.buf; *from; from++)
> >                       if ((*from & 0x80) || isalnum(*from))
> >                               *(to++) = *from;
> >                       /* avoid leading dash and double-dashes */
> >                       else if (to != label.buf && to[-1] != '-')
> >                               *(to++) = '-';
> >               strbuf_setlen(&label, to - label.buf);
>
> Simple enough and is a good change when judged locally.
>
> It still would cause readers to wonder if label_oid() later append
> '-%d' to end up with double-dash near the end, etc., which made me
> wonder if the resulting code becomes better if sanitization and
> uniquefying are done at the same single place in the other message.
-- 
Matthew Rogers
Previous: Junio C HamanoNext: Johannes Schindelin
Message 9 of 22 in “Make git rebase -r's label generation more resilient”
  1. 0/1 Make git rebase -r's label generation more resilientJohannes Schindelin via GitGitGadget, Sep 2, 2019
  2. 1/1 rebase -r: let `label` generate safer labelsMatt R via GitGitGadget, Sep 2, 2019
  3. Phillip WoodSep 2, 2019
  4. Junio C HamanoSep 2, 2019
  5. brian m. carlsonSep 2, 2019
  6. Philip OakleySep 2, 2019
  7. Johannes SchindelinSep 3, 2019
  8. Junio C HamanoSep 3, 2019
  9. Matt RogersSep 3, 2019
  10. Johannes SchindelinSep 2, 2019
  11. Junio C HamanoSep 3, 2019
  12. Johannes SchindelinNov 18, 2019
  13. 0/2 Make git rebase -r's label generation more resilientJohannes Schindelin via GitGitGadget, Nov 17, 2019
  14. 2/2 rebase -r: let `label` generate safer labelsMatthew Rogers via GitGitGadget, Nov 17, 2019
  15. 1/2 rebase-merges: move labels' whitespace mangling into `label_oid()`Johannes Schindelin via GitGitGadget, Nov 17, 2019
  16. Junio C HamanoNov 18, 2019
  17. sequencer: handle rebase-merge for "onto" messageDanh Doan, Nov 18, 2019
  18. sequencer: handle rebase-merges for "onto" messageDoan Tran Cong Danh, Nov 18, 2019
  19. Johannes SchindelinNov 18, 2019
  20. Junio C HamanoNov 21, 2019
  21. Johannes SchindelinNov 18, 2019
  22. Philip OakleySep 2, 2019

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.