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

Re: Feature request: --format=json

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 8, 2017, 16:26 UTC
Message-ID
<CACBZZX4fDu-o+ERiTyjVq2rWkXK6rjErU4KyW33qMx1_6vjMCQ@mail.gmail.com>
In-Reply-To
<CAJgfmqU+1Ex1YkP94H2amXV+oqscbQwvb-CueuCiM7-n0AAP8Q@mail.gmail.com>
On Sat, Apr 8, 2017 at 6:07 PM, Fred .Flintstone <eldmannen@gmail.com> wrote:
Show 11 quoted lines
> $ git log --format=json
> [{
>     "commit": "64eabf050e315a4c7a11e0c05ca163be7cf9075e",
>     "tree": "b1e977800f40bbf6de906b1fe4f2de4b4b14f0fd",
>     "author": "Tux <tux@example.com> 1490981516 +0200",
>     "committer": "Tux <tux@example.com> 1490981516 +0200",
>     "message": "This is a test commit",
>     "long_message": "This explains in more details the commit"
> }]
>
> This would make it easy to parse the output.

The git-log command isn't plumbing that's meant for machines, but the git-for-each-ref command is what you're most likely looking for.

It doesn't have JSON output, but you can make e.g. --format emit something even more easily parsable, e.g. a version of what you have with each field delimited by a custom delimiter, and then split on that.

It does have --perl, --tcl etc. options to make it easy to quote the fields, however there's no logic to manage the state machine JSON would need to omit trailing commas, whereas emitting output for languages like Perl where trailing commas don't matter is much easier.

Previous: Fred .FlintstoneNext: Junio C Hamano
Message 2 of 14 in “Feature request: --format=json”
  1. Fred .FlintstoneApr 8, 2017
  2. Ævar Arnfjörð BjarmasonApr 8, 2017
  3. Junio C HamanoApr 17, 2017
  4. Fred .FlintstoneApr 17, 2017
  5. Duy NguyenApr 17, 2017
  6. Fred .FlintstoneApr 17, 2017
  7. Junio C HamanoApr 18, 2017
  8. Fred .FlintstoneApr 18, 2017
  9. Samuel LijinApr 18, 2017
  10. Fred .FlintstoneApr 18, 2017
  11. demerphqApr 18, 2017
  12. Sebastian SchuberthApr 17, 2017
  13. Duy NguyenApr 24, 2017
  14. shawn wilsonApr 24, 2017

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.