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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 1EA921F953 for ; Mon, 10 Jan 2022 19:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243927AbiAJTlo (ORCPT ); Mon, 10 Jan 2022 14:41:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243815AbiAJTlk (ORCPT ); Mon, 10 Jan 2022 14:41:40 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79963C06173F for ; Mon, 10 Jan 2022 11:41:40 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id c14-20020a17090a674e00b001b31e16749cso314890pjm.4 for ; Mon, 10 Jan 2022 11:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C5igQ0Zs+VUFFzO/Kzf5FTMRZZIWb1GV1bohCFyqlyQ=; b=CbjigvQWk+dXqF0xtzRAQZd3Th8ln2PUSHyb2KpSwkC/LEHfiG5agUgTdQBKEPHbFg D/JGGEHl7509GSl9vKfnrZRqL6oO6e9AY1wZ0o2KIWJ30RhqDhL+Is1oZk9MeZn6eTa8 ++TVLMlc0dQafbxZDXEqwjU+qYVD1MbTjPQ9PjnMPGieQ9owAU24fpVpDYEX6UHA/INQ DXEjtTMOTG8WvkvrXzu5gxnUivpOnuFjQIxqBQ869O4S3/spXnJMl1WzC14D4rYLRiEa p5qYstdJ0DeJg2MJPUEnzwz3moiAcM6DPPauyxy6cK2RM9z+QxVKh3pCiF0fZoWC5gm0 tv3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C5igQ0Zs+VUFFzO/Kzf5FTMRZZIWb1GV1bohCFyqlyQ=; b=ZpfsxuTcGQXGOSprmMUkgHSBs3nWaVWtvzTkC7GEoPQ/sM0lYhXU9yRZqxOwoKGq57 NgYKUAK2OvFMQOFu9ZNPwkM/XpxZOm0rtl55Z59seS5tvR7Ne672177tofb5Vhviy8ss jzMeN1MfmI4z3Il7ZvvooXxLQoQ33kX8/qOdf6mlf/EVnEKQWSSC7ZXYIMXmdG2Mdz3h f27Su4LhwVvmpenZqn2Kq37jo2VfKdw9obYH6RlHTuVZjyCGoLX1L59lsqWDMdST7ciR aGEFRRqYBZLgGuLiKADr3SV2oM1LgpDlAFKvyxPuSIVDYAJGsG++8R1Y3wVWWESs2DM7 hzxQ== X-Gm-Message-State: AOAM531aJRyxt4Puy+pe5nuhEAQGj5Qx8DAWx19PkaZAnPNEMNlkWaoO 4Xti1K1HPCFUViq8qlYNQsmYx5UPEuZ20uarTS0= X-Google-Smtp-Source: ABdhPJx3GcXBHf+Ero0UvaM7uzAB0hG+rCMxFsD/koz+MMHdN9HFcZyEGSIiC2QoVcEA2hCsg2UaK44FiceczNQpTgc= X-Received: by 2002:a17:90a:348c:: with SMTP id p12mr11269371pjb.90.1641843700016; Mon, 10 Jan 2022 11:41:40 -0800 (PST) MIME-Version: 1.0 References: <7df58483a4f665f9f54b92a97a6b57704f1e7a0d.1641440700.git.dyroneteng@gmail.com> In-Reply-To: <7df58483a4f665f9f54b92a97a6b57704f1e7a0d.1641440700.git.dyroneteng@gmail.com> From: =?UTF-8?Q?Martin_=C3=85gren?= Date: Mon, 10 Jan 2022 20:41:28 +0100 Message-ID: Subject: Re: [PATCH v9 8/9] ls-tree.c: introduce "--format" option To: Teng Long Cc: =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , =?UTF-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Git Mailing List , Junio C Hamano , Jeff King , tenglong.tl@alibaba-inc.com, Johannes Schindelin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Teng, On Fri, 7 Jan 2022 at 06:34, Teng Long wrote: > +--format=:: > + A string that interpolates `%(fieldname)` from the result > + being shown. It also interpolates `%%` to `%`, and > + `%xx` where `xx`are hex digits interpolates to character Above, there is a missing space just before "are". That causes the manpage to render a little bit funny. > + with hex code `xx`; for example `%00` interpolates to > + `\0` (NUL), `%09` to `\t` (TAB) and `%0a` to `\n` (LF). > + When specified, `--format` cannot be combined with other > + format-altering options, including `--long`, `--name-only` > + and `--object-only`. > + > +Customized format: > + > +It's support to print customized format by `%(fieldname)` with `--format` option. I had to re-read this to understand. How about the following? It is possible to print in a custom format by using the `--format` option, which is able to interpolate different fields using a `%(fieldname)` notation. Just a suggestion. Feel free to tweak or ignore. :-) > +For example, if you want to only print the and fields with a > +JSON style, executing with a specific "--format" like > + > + git ls-tree --format='{"object":"%(object)", "file":"%(file)"}' > + > +The output format changes to: > + > + {"object":"", "file":""} > + Nice! Martin