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

Re: Feature request: --format=json

From
Samuel Lijin <sxlijin@gmail.com>
Date
Apr 18, 2017, 09:39 UTC
Message-ID
<CAJZjrdXBbBiy0f=RJ2m7iHnh70Nz97-tdHWkSJtYbW6CKBr5ow@mail.gmail.com>
In-Reply-To
<CAJgfmqXqfp3A+A74dfkKjQb_26ZNH9anY52-G2L5ipg=+6--2w@mail.gmail.com>

If for some reason your use case is so performance intensive that you can't just `git cat-file commit` every entry in `git rev-list --all` individually, then you can also pipe input into `git cat-file --batch` and read output as you pipe input in, which will give you a very simple mechanism for delimiting the cat-file output.

In any case, as developers, it's rare to have our job done for us. That's why we write code.

I'm sure people would be happy to help if you submitted patches to support --format=json.

On Tue, Apr 18, 2017 at 3:44 AM, Fred .Flintstone <eldmannen@gmail.com> wrote:
Show 26 quoted lines
> Well the easiest way to work with that would be JSON.
> So the best would be if Git could output the data I want in JSON format.
> Then it would be easy for me to work with data.
>
> With git rev-list and git-cat file, its not so easy to reliably parse
> that output.
>
> On Tue, Apr 18, 2017 at 2:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> "Fred .Flintstone" <eldmannen@gmail.com> writes:
>>
>>> So I would either have to do:
>>> git rev-list --all
>>> Then iterate over each line and do git-cat-file commit <commit-id>.
>>>
>>> Or do:
>>> git rev-list --all | git cat-file --batch
>>>
>>> If I do it in a batch, then it will be tricky to reliably parse since
>>> I don't know when the message body ends and when the next commit
>>> starts.
>>>
>>> JSON output would have been very handy.
>>
>> I am somewhat puzzled.  I thought that you were trying to come up
>> with a way to produce JSON output and people are trying to help you
>> by pointing out tools that you can use for that.
Previous: Fred .FlintstoneNext: Fred .Flintstone
Message 9 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.