All of lore.kernel.org
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Ron Ziroby Romero <ziroby@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Pretty output in JSON format
Date: Tue, 24 Sep 2024 22:06:45 +0000	[thread overview]
Message-ID: <ZvM39VNFptcfwMGk@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <CAGW8g7=21pPAgCixjpayEvmw_ns-hcB4e59NP476TKtCRXHPXQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1869 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2024-09-24 22:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 21:52 Pretty output in JSON format Ron Ziroby Romero
2024-09-24 22:06 ` brian m. carlson [this message]
2024-09-25 18:45   ` Sean Allred
2024-09-26 21:04     ` brian m. carlson
2024-09-27  6:49       ` Ron Ziroby Romero
     [not found]       ` <CANgJU+Xs-sQgAOCPL-5skaZGq7eHmhg0MaFGDr8N57=CK67iog@mail.gmail.com>
     [not found]         ` <CAGW8g7=xK0S-i_Ekfwwo_NjMbngO_5m4LERtWRhSCgA0vf+ZAg@mail.gmail.com>
2025-07-31 20:19           ` Ron Ziroby Romero
2025-08-04 20:39         ` Ron Ziroby Romero
2025-08-04 21:19           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZvM39VNFptcfwMGk@tapette.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=ziroby@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.