From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01FB2C433B4 for ; Tue, 13 Apr 2021 07:33:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CDD60613B1 for ; Tue, 13 Apr 2021 07:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240151AbhDMHeP (ORCPT ); Tue, 13 Apr 2021 03:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240288AbhDMHeK (ORCPT ); Tue, 13 Apr 2021 03:34:10 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3A98C061574 for ; Tue, 13 Apr 2021 00:33:50 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id w18so18251982edc.0 for ; Tue, 13 Apr 2021 00:33:50 -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; bh=IsCGrj7j4AwaukPUVPddJLtzGHBkJxgpEL+4K3Kziew=; b=i9NGOODRNIP0kTDm3mneCxBaMZg1Um6sAdZ9/deYr0BAgU3WJXQUwxU4ph5q1xOh8T whPlQPQ3jYr5xYnAGtF6ZDibo11BG/5q8OZqOtdqlhm9+JFHk/KM/GjSsa2swriZWDuR 2RM0EGiENu/c9e8IdSoOi4WrKvcOyUMuhR0EoW+X/FV6mCT0pm0R+N/Y7hn0TxTeNoV4 fzakplbMNxAz8KPlG8WeX9uI58jWWlRWikTDn1Un6frJD5e8ydmMecPHPTIC6v192hEI VOvt0kgj52OJ2NsjhQmpsqEjQBzSV99weokcwdYeSovv6Adq/RSwfu21bDMvdwL7AQtR 96YQ== 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; bh=IsCGrj7j4AwaukPUVPddJLtzGHBkJxgpEL+4K3Kziew=; b=ULWMUE5HhHATntPolszRwvmPi7iOHaYbFvXsj/yMFo+8EIzvvfjaWyCsTT5jEtu5T3 xXTxFJF0PSgVDWDr9mpLEi1pMd1EYJ7qMhxJl7OPgC3JLirXiGWqV+DDAXQJoBSXEQG3 VA0NS3+FKlUPNCfnMysBCRpVNks17XobcgWNQAZ55ZsBqtMW8F4n5lFoOHQi7GBWbk0k rMxOGPYhOQ1isi8DNVHfC0y0l3ZfN8zqCqsLg7852C39A0f+ooyCqtfCgHcVAO6Lx1eD U1sajHtPFtNKzZIncvhFmbjS/e2qedE9cdxj1sV3eiNa/J6NIGmFqo23V2HTpx8U04rl IpKQ== X-Gm-Message-State: AOAM5300TM9qTZIZ8ZZIfkCNa9vgiGDkwfGrWleiQ/FX5i3m0sj/GGOh JU84aIMEd64Ebw2PO8jbOpkYoYdxR3qV3jWJCvZuL9sYpE7b7A== X-Google-Smtp-Source: ABdhPJwKbx2FnvhWnL0Pn8U2VMWkXwQ7SHYfTuXLg7Z8oTHQqpquNxwRzcsfH+nQsIP/SCoshTi4cFNGbJS/I432cEI= X-Received: by 2002:aa7:cf90:: with SMTP id z16mr33248050edx.273.1618299229444; Tue, 13 Apr 2021 00:33:49 -0700 (PDT) MIME-Version: 1.0 References: <7f645ec95f48a206311973ee45578ba14ac58b7f.1618245568.git.gitgitgadget@gmail.com> In-Reply-To: From: Christian Couder Date: Tue, 13 Apr 2021 09:33:38 +0200 Message-ID: Subject: Re: [PATCH v9 2/2] [GSOC] trailer: add new .cmd config option To: Junio C Hamano Cc: ZheNing Hu via GitGitGadget , git , ZheNing Hu Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Apr 12, 2021 at 10:51 PM Junio C Hamano wrote: > > "ZheNing Hu via GitGitGadget" writes: > > > +For consistency, the $1 is also passed, this time with the empty string, > > +in the command when the command is first called to add a trailer with > > +the specified . > > I guess the same question as 1/2 applies to this part. I am not > sure what "consistency" the behaviour of calling the configured > command with no argument is trying to achieve. To me, .cmd doing > this may be for consistency with .command but I am not sure why > the consistency is even desiable. It might be desirable to make it easier for people to migrate from ".command" to ".cmd". I agree this is debatable, but I don't see a big downside in it. Maybe, if no argument was passed at all the first time the command is called instead of the empty string, the command could then know that it's called for the first time. I am not sure this would be very helpful in practice though. > > +$ cat ~/bin/gcount > > +#!/bin/sh > > +test -n "$1" && git shortlog -s --author="$1" HEAD || true > > +$ git config trailer.cnt.key "Commit-count: " > > +$ git config trailer.cnt.ifExists "replace" > > +$ git config trailer.cnt.cmd "~/bin/gcount" > > +$ git interpret-trailers --trailer="cnt:Junio" < > +> subject > > +> > > +> message > > +> > > +> EOF > > +subject > > + > > +message > > + > > +Commit-count: 22484 Junio C Hamano > > +------------ > > This and the other (omitted) example demonstrates how the initial > "empty" invocation is useless by using "replace". Which also means > that you cannot add more than one trailer of the same with the > mechanism (since the older ones are replaced with the latest). You can add more than one trailer with the same key if you don't use "replace" but use "--trim-empty" on the command line, so that an empty trailer added by the initial invocation is removed. And we can later add a `trailer..runMode` to remove the initial invocation. > The code change and the test change are consistent with the design, > though. Yeah, this patch looks good to me now. Thanks!