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

Re: Structured (ie: json) output for query commands?

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Jul 1, 2021, 08:18 UTC
Message-ID
<CAFQ2z_MGJ7Qo5fq7bnwXi3m32iVeaC2WfdsKjRW0JO4Tq+M37Q@mail.gmail.com>
In-Reply-To
<CACPiFCLzsiUjx-vm-dcd=0E8HezMWkErPyS==OQ7OhaXqR6CUA@mail.gmail.com>

On Wed, Jun 30, 2021 at 7:00 PM Martin Langhoff <martin.langhoff@gmail.com> wrote:

Show 11 quoted lines
> I'm used to automating git by parsing stuff in Unix shell style. But
> the golden days that gave us Perl are well behind us.
>
> Before I write (unreliable, leaky, likely buggy) text parsing bits one
> more time, has git grown formatted output? I'm aware of fmt and
> friends, I'm thinking of something that handles escaping, nested data
> structures, etc.
>
> Something like "git shortlog --json".
>
> Have there been discussions? Patches? (I don't spot anything in what's cooking).
<unpopular opinion>

text parsing is fine if you're doing a one-off, but if it's anything that needs to be just moderately complex, robust or long-lived, writing a proper program is a better idea. I'd recommend either go-git (single file programs can easily be run with "go run"), or Dulwhich (no experience, though) in python.

-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--

Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich

Registergericht und -nummer: Hamburg, HRB 86891

Sitz der Gesellschaft: Hamburg

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Previous: Ævar Arnfjörð Bjarmason
Message 11 of 11 in “Structured (ie: json) output for query commands?”
  1. Martin LanghoffJun 30, 2021
  2. Jeff KingJun 30, 2021
  3. Martin LanghoffJun 30, 2021
  4. Jeff KingJul 1, 2021
  5. brian m. carlsonJun 30, 2021
  6. Martin LanghoffJun 30, 2021
  7. Jeff KingJul 1, 2021
  8. brian m. carlsonJul 1, 2021
  9. Jeff KingJul 1, 2021
  10. Ævar Arnfjörð BjarmasonJul 2, 2021
  11. Han-Wen NienhuysJul 1, 2021

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.