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-Status: No, score=-2.8 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, 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 334E41F9FC for ; Mon, 22 Mar 2021 21:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbhCVVfC (ORCPT ); Mon, 22 Mar 2021 17:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229467AbhCVVef (ORCPT ); Mon, 22 Mar 2021 17:34:35 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E409C061574 for ; Mon, 22 Mar 2021 14:34:35 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id hq27so23690465ejc.9 for ; Mon, 22 Mar 2021 14:34:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=LM57kOnr11HrH03RgGQ56tIitTFNvJsqsKOSA+zkW6k=; b=PrYHyVcHADufhHPbw58zExFQKrJRfXQ6qvb59F9Z8i2CfO+nrcIGq8srTc3fFgFXcf xsEPDaN+UoqaEYYXJyggW9U5cNdiw8D8pb3HXvGPJDG0Ze2G2/5SoII7m6qGKFBk2ZMv EVwauVQRbN1m0DejflqM8fcrjhmb3W043mCMvy6NiiTX1b8Ei3jFJHRcXJn84/TKM2ip BzVcXczv1D+pWyLNFgcYWBsSMw84SWpUVdEfkgFBueRjjNEKuYQOrDfiHdvvG8K6lzp3 8yTSbp0aFlUR3z+vAXrgvwMiY1dMKMjF+SMbQaNRHq234iAAby2m3GxIoja9gXAONyNC JPjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=LM57kOnr11HrH03RgGQ56tIitTFNvJsqsKOSA+zkW6k=; b=lXWRBtw/2cTDysJvhOkbFRGTFsEpsPEcBZkaud13P6CVfFiOITtfZow+sfT0+CMalC +3oHqCA3o7DXswJRqOG9JL27lqFnllD4+hVTuy7IT25JmxouyQkYrnk7lghcz0qw6x6J Yg3qfJqic7CGbSWh38ZcOUf3zOQtLgMzSibIEp2bKTc4IHHeNecuLf3UzNwv+Z/tDzg7 cl6jyVR+Kjdd04GReU+RhB6TNUH5hZqlSevs281E17Fp4FFNMTN23+HdfXe6gc5UpgG+ fwjJkRMtUG19QNTIUbNKDiamI49DnaMZGqpScJ7qQK9PuDRirDq0OzR8747+3lsP61Z6 qt1g== X-Gm-Message-State: AOAM532dYXVOhu5/zz7flLT3opAeVfIYDgLUgGTGS1QL64LIed3whut2 WpV8J5ZjAUz2KfZBO9pd0fnI9eGBWy8g55/b3wc= X-Google-Smtp-Source: ABdhPJwjZGDg8G8/sMlCKwGZu+ZSkh0kq3QirQpce1HfRboOMpzMDV8HjnDG2DUMA0Q/E2genMAZ+mcL3XDbo4jT11o= X-Received: by 2002:a17:906:c405:: with SMTP id u5mr1716579ejz.341.1616448873812; Mon, 22 Mar 2021 14:34:33 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Christian Couder Date: Mon, 22 Mar 2021 22:34:21 +0100 Message-ID: Subject: Re: [PATCH v13] [GSOC] commit: add --trailer option To: ZheNing Hu Cc: ZheNing Hu via GitGitGadget , git , "Bradley M. Kuhn" , Junio C Hamano , Brandon Casey , Shourya Shukla , Rafael Silva , =?UTF-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Jeff King , =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Mar 22, 2021 at 11:23 AM ZheNing Hu wrote: > > Christian Couder =E4=BA=8E2021=E5=B9=B43=E6= =9C=8822=E6=97=A5=E5=91=A8=E4=B8=80 =E4=B8=8B=E5=8D=883:43=E5=86=99=E9=81= =93=EF=BC=9A > > Nice that you have added such a test! > > Thanks. > > But at the same time I have two little doubt. > > 1. > If we have your config: > > $ git config trailer.sign.key "Signed-off-by: " > $ git config trailer.sign.ifexists replace > $ git config trailer.sign.command "git log --author=3D'\$ARG' -1 > --format=3D'format:%aN <%aE>'" > > Then I touch a test.c and use: > > $ git interpret-trailers --in-place test.c > > without `--trailer`, See what is happen: > > It seem like your local repo last commit "name " pair > have been record in `test.c`. > > Could this be considered a bug? First it seems strange to use `git interpret-trailers` on a "test.c" file. It's supposed to be used on commit messages. Then, as the doc says, every command specified by any "trailer..command" config option is run at least once when `git interpret-trailers` is run. This is because users might want to automatically add some trailers all the time. If you want nothing to happen when $ARG isn't set, you can change the config option to something like: $ git config trailer.sign.command "NAME=3D'\$ARG'; test -n \"\$NAME\" && git log --author=3D\"\$NAME\" -1 --format=3D'format:%aN <%aE>' || true" (This is because it looks like $ARG is replaced only once with the actual value, which is perhaps a bug. Otherwise something like the following might work: git config trailer.sign.command "test -n '\$ARG' && git log --author=3D'\$ARG' -1 --format=3D'format:%aN <%aE>' || true") Then you can run `git interpret-trailers` with the --trim-empty option like this: ------ $ git interpret-trailers --trim-empty --trailer sign=3DLinus< ------ or like: ------ $ git interpret-trailers --trim-empty< EOF ------