Re: Pretty output in JSON format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-09-24 at 21:52:35, Ron Ziroby Romero wrote:
> Howdy git folk,
> 
> I want to revive the discussion on JSON output. I see a discussion in
> 2021 about it, but it didnt come to a resolution. That discussion was
> talking about adding a --json flag. I have a slightly different
> approach.
> 
> I see online that many people have tried to make various hacks to
> convert git output into JSON, but they all lack completeness,
> especially with log messages with arbitrary text. I believe the best
> and most correct way to get JSON output from git is to add it as a new
> format to the pretty option. Then, it would be easy to pipe the output
> into something like jq to parse the JSON.  Trying to convert git's
> output into JSON is a losing proposition. You've already lost some of
> the context of the output by getting it out of the git program itself.
> A pretty option would provide a standard way to get correct JSON
> output, with git's code handling the weird corner cases.
> 
> What do y'all think?

I think this is ultimately a bad idea.  JSON requires that the output be
UTF-8, but Git processes a large amount of data, including file names,
ref names, commit messages, author and committer identities, diff
output, and other file contents, that are not restricted to UTF-8.  In
fact, despite my recommendation, the trace2 JSON output simply outputs
invalid UTF-8, which just doesn't work in nearly any tool, if it
encounters such data.  We shouldn't add more broken-by-default
functionality.

However, if you were interested in CBOR output, which isn't
human-readable but is capable of handling byte strings, then I don't see
a problem.  CBOR is used in FIDO2 and a variety of other protocols and
is interoperable, so it should be a fine choice here.
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux