But a repository or branch can have thousands of commits, so running
`git commit-file <commit>` seems maybe not be a wide idea.
But parsing `git cat-file --batch` is difficult, because there seems
to be no reliable way to discern when a commit starts and ends.

I don't code in C though. A JSON formatter option would need a JSON library.
But maybe there should be raised a discussion about JSON in Git if
there are other people interested in this?

On Tue, Apr 18, 2017 at 11:39 AM, Samuel Lijin <sxli...@gmail.com> wrote:
> 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 <eldman...@gmail.com> wrote:
>> 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 <gits...@pobox.com> wrote:
>>> "Fred .Flintstone" <eldman...@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.

Reply via email to