From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id C03A11F8C6 for ; Wed, 30 Jun 2021 17:59:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232694AbhF3SCO (ORCPT ); Wed, 30 Jun 2021 14:02:14 -0400 Received: from cloud.peff.net ([104.130.231.41]:37632 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229573AbhF3SCO (ORCPT ); Wed, 30 Jun 2021 14:02:14 -0400 Received: (qmail 24720 invoked by uid 109); 30 Jun 2021 17:59:44 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 30 Jun 2021 17:59:44 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 9333 invoked by uid 111); 30 Jun 2021 17:59:44 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 30 Jun 2021 13:59:44 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 30 Jun 2021 13:59:43 -0400 From: Jeff King To: Martin Langhoff Cc: Git Mailing List Subject: Re: Structured (ie: json) output for query commands? Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, Jun 30, 2021 at 01:00:24PM -0400, Martin Langhoff wrote: > 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). It's been discussed off-and-on over the years, but I don't think anybody's actively working on it. The trace2 facility has some json output. That's probably not helpful for what you're doing, but it does mean we have basic json output routines available. One complication we faced is that a lot of Git's data is bag-of-bytes, not utf8. And json technically requires utf8. I don't remember if we simply fudged that and output possibly non-utf8 sequences, or if we actually encode them. -Peff