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

Re: More git status --porcelain lossage

From
Eric Raymond <esr@thyrsus.com>
Date
Apr 10, 2010, 22:57 UTC
Message-ID
<20100410225704.GA4623@thyrsus.com>
In-Reply-To
<201004102321.59263.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com>:
> [JSON] is a bit chatty, but is to some extent self documenting.

Yes. But to my mind, the big win of JSON is that you can extend it without breaking parsers looking for older versions - they just skip the new fields and all is happy.

Jakub, you seem to know this, but other listmermbers may not: I've recently re-engineered GPSD, a service daemon for watching geolocation sensors, to report JSON objects up the socket to client apps. The benefits in clarity and extensibility of the protocol have been *huge*. Like, today I'm adding a reporting type for digital compass/gyroscope sensors.

> The question is whether it should output well formed array of objects,
> or just list of objects not wrapped in array...

Yes, I know this dance. Answer: one big JSON object, tagged by the name of the output generator, and also *containing a version-stamp field*. Array of file status objects is another top-level member.

The point is: later, if we want to enrich the reporting format, we add whatever fields we want and bump the version stamp. Self-describing goodness. Python, Perl, JavaScript, and Emacs LISP clients win especially big. Slurping this into a native data structure is one function call.

The more I think about this, the better I like it.
 
> What I am worrying about is correct handling of escaping, quoting,
> and non-ASCII characters in strings (the JSON-quoting and JSON-escapes
> are different than C escape codes, IIRC).  JSON rules are simple,
> but are different than C.

Yes. Perhaps there's some scope for reuse here after all. GPSD has well-tested code for uttering the JSON quote/escape conventions. The git project is welcome to it.

-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
Previous: Jakub NarebskiNext: Eric Raymond
Message 15 of 18 in “More git status --porcelain lossage”
  1. Eric RaymondApr 9, 2010
  2. Eric RaymondApr 9, 2010
  3. Jakub NarebskiApr 9, 2010
  4. Eric RaymondApr 9, 2010
  5. Jeff KingApr 10, 2010
  6. Jeff KingApr 10, 2010
  7. SimonApr 10, 2010
  8. Jakub NarebskiApr 10, 2010
  9. Eric RaymondApr 10, 2010
  10. Martin LanghoffApr 10, 2010
  11. Paolo BonziniApr 10, 2010
  12. Eric RaymondApr 10, 2010
  13. David AguilarApr 11, 2010
  14. Jakub NarebskiApr 10, 2010
  15. Eric RaymondApr 10, 2010
  16. Eric RaymondApr 10, 2010
  17. Ævar Arnfjörð BjarmasonApr 10, 2010
  18. SimonApr 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.