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

Re: Efficient parsing of `status -z` output

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 8, 2015, 08:14 UTC
Message-ID
<xmqqlhj7sy7l.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAMJduDuxBDoJ9_ETY8FCRoANf+taAS7-1acf5CFRGXDFyL72Rg@mail.gmail.com>
Matthew Rothenberg <mrothenberg@gmail.com> writes:
Show 12 quoted lines
>  2. Read from buffer until the first NUL, parse the entry status
> codes, and if the entry status code represents a status that *should*
> have multiple filenames, read from buffer until a second NUL is found,
> and then reparse that entry with both filenames. The issues I see with
> this approach:
>    a.) One has to know exactly which status code combinations will end
> up with two filenames, and this list has to be exhaustive. As far as I
> can tell, there is no canonical documentation for this?
>    b.) It seems a bit brittle, because if the logic from the above is
> wrong and we miss an extended entry or ask for one when it doesn't
> exist we will leave the buffer an essentially corrupt state for future
> reads.

I think this is how -z was designed to be used, and if that isn't clear, then the documentation must be updated to clarify. Rename and Copy are the only ones that needs two pathnames, and I suspect that whoever did the original description of the short format in the documentation knew Git too well that he forgot to mention it ;-)

Previous: Matthew RothenbergNext: Matthew Rothenberg
Message 2 of 7 in “Efficient parsing of `status -z` output”
  1. Matthew RothenbergMar 7, 2015
  2. Junio C HamanoMar 8, 2015
  3. Matthew RothenbergMar 9, 2015
  4. Jeff KingMar 9, 2015
  5. Jeff KingMar 9, 2015
  6. Matthew RothenbergMar 9, 2015
  7. Jeff KingMar 10, 2015

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.