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

Re: git status --porcelain is a mess that needs fixing

From
Eric Raymond <esr@thyrsus.com>
Date
Apr 10, 2010, 14:43 UTC
Message-ID
<20100410144334.GB23959@thyrsus.com>
In-Reply-To
<9c7e1f33b7ec0dab68a92aa8f067989e@212.159.54.234>
Julian Phillips <julian@quantumfyre.co.uk>:
Show 29 quoted lines
> On Sat, 10 Apr 2010 00:09:59 -0400, Jeff King <peff@peff.net> wrote:
> > Your parser is already broken if you are calling split, as the filenames
> > may contain spaces (and will be quoted in that case, and you need to
> > unmangle). You should use "-z".
> > 
> > You will probably then realize that the "-z" format looks like:
> > 
> >   XY file1\0file2\0
> > 
> > which still sucks. It would be more friendly as:
> > 
> >   XY\0file1\0file2\0
> > 
> > So you could split on "\0". But even with that, you can't just blindly
> > split, as the column and record separators are the same, and you might
> > have one or two filenames.
> 
> Not true.  If the second form was used, then you _can_ split on \0.  It
> will tokenise the data for you, and then you consume ether two or three
> tokens depending on the status flags.  So it would make the parsing
> simpler.  But to make it even easier, how about adding a -Z that makes the
> output format "XY\0file1\0[file2]\0" (i.e. always three tokens per record,
> with the third token being empty if there is no second filename)?  Though
> if future expandability was wanted you could end each record with \0\0 and
> then parsing would be a two stages of split on \0\0 for records and then
> split on \0 for entries?  The is already precedence for the -z option to
> change the output format, so a second similar switch should be ok?  Then
> the updated documentation could recommend --porcelain -Z for new users
> without affecting old ones.
+1

-Z could fix some of the other issues, as well, like use of space as a flag character.

-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
Previous: Julian PhillipsNext: Jon Seymour
Message 11 of 19 in “git status --porcelain is a mess that needs fixing”
  1. Eric RaymondApr 9, 2010
  2. Junio C HamanoApr 9, 2010
  3. Jeff KingApr 10, 2010
  4. Jonathan NiederApr 10, 2010
  5. Jonathan NiederApr 10, 2010
  6. Jeff KingApr 10, 2010
  7. Jonathan NiederApr 10, 2010
  8. Jeff KingApr 10, 2010
  9. Eric RaymondApr 10, 2010
  10. Julian PhillipsApr 10, 2010
  11. Eric RaymondApr 10, 2010
  12. Jon SeymourApr 10, 2010
  13. Julian PhillipsApr 10, 2010
  14. Jon SeymourApr 10, 2010
  15. status: Add a new NUL separated output formatJulian Phillips, Apr 10, 2010
  16. Eric RaymondApr 10, 2010
  17. Julian PhillipsApr 10, 2010
  18. Eric RaymondApr 10, 2010
  19. status: Add json output formatJulian Phillips, Apr 10, 2010

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.