Re: Feature request: --format=json
- From
- Fred .Flintstone <eldmannen@gmail.com>
- Date
- Apr 17, 2017, 12:44 UTC
- Message-ID
- <CAJgfmqWf9j=R1=qy-kGTL4+y_40O+8S5q=VZuD3A-DbfRJer2Q@mail.gmail.com>
- In-Reply-To
- <xmqqpogblvfr.fsf@gitster.mtv.corp.google.com>
So I did "git rev-list --all --pretty" and it looks like "git log". Which outputs a human-readable format.
However, if I want something more suitable for machine parsing, is there any way to get that output?
Example maybe I want another date format like ISO dates, or maybe a serializable format like JSON or CSV or something. Maybe I want more data than commit, auhor, date, subject and body?
On Mon, Apr 17, 2017 at 2:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 24 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Sat, Apr 8, 2017 at 6:07 PM, Fred .Flintstone <eldmannen@gmail.com> wrote:
>>> $ 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.
>
> They are apples and oranges. log is about traversing the history.
> "for-each-ref" is about listing the tips of refs. It doesn't and it
> shouldn't traverse the history.
>
> The plumbing to use when you want to reimplement "git log" lookalike
> is "rev-list".