git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "D. Ben Knoble" <ben.knoble@gmail.com>
To: Chris Down <chris@chrisdown.name>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	kernel-team@fb.com
Subject: Re: [PATCH] commit: Add commit.signoff configuration option
Date: Tue, 13 May 2025 17:09:40 -0400	[thread overview]
Message-ID: <CALnO6CBdhYFsDN=HPo9HbKeoZH7bb=xVVXUCK7nUdadLg-U_Pw@mail.gmail.com> (raw)
In-Reply-To: <aCM5JY25NVPgyYRP@chrisdown.name>

On Tue, May 13, 2025 at 8:21 AM Chris Down <chris@chrisdown.name> wrote:
>
> Introduce a new `commit.signoff` config variable that mirrors the
> behavior of the -s/--signoff flag.
>
> We already have prior art in format-patch with `format.signoff`; this
> brings parity for those who don’t use a patch-based workflow but still
> rely on signoffs.
>
> Right now people who have to do this regularly often alias commit to
> `commit --signoff` in their shell, which is less than ideal -- this
> config option avoids having to do that.

It would probably be nice to say why this makes sense in light of
previously-raised objections, too [1].

[1]: https://lore.kernel.org/git/xmqqo6x4p6z2.fsf@gitster.g/

>
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
>  Documentation/signoff-option.adoc         |  4 ++++
>  builtin/commit.c                          |  4 ++++
>  t/t7500-commit-template-squash-signoff.sh | 10 ++++++++++
>  3 files changed, 18 insertions(+)
>
> diff --git a/Documentation/signoff-option.adoc b/Documentation/signoff-option.adoc
> index cddfb225d1..0055874e84 100644
> --- a/Documentation/signoff-option.adoc
> +++ b/Documentation/signoff-option.adoc
> @@ -13,6 +13,10 @@ endif::git-commit[]
>         Linux kernel and Git projects.)  Consult the documentation or
>         leadership of the project to which you're contributing to
>         understand how the signoffs are used in that project.
> +ifdef::git-commit[]
> +       The `commit.signoff` configuration variable may also be used to imply
> +       `--signoff`.
> +endif::git-commit[]
>  +
>  The `--no-signoff` option can be used to countermand an earlier `--signoff`
>  option on the command line.
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 66bd91fd52..da98895438 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1670,6 +1670,10 @@ static int git_commit_config(const char *k, const char *v,
>                                                                &is_bool);
>                 return 0;
>         }
> +       if (!strcmp(k, "commit.signoff")) {
> +               signoff = git_config_bool(k, v);
> +               return 0;
> +       }
>
>         return git_status_config(k, v, ctx, s);
>  }
> diff --git a/t/t7500-commit-template-squash-signoff.sh b/t/t7500-commit-template-squash-signoff.sh
> index 4dca8d97a7..03c20dcb1d 100755
> --- a/t/t7500-commit-template-squash-signoff.sh
> +++ b/t/t7500-commit-template-squash-signoff.sh
> @@ -181,6 +181,16 @@ test_expect_success '--signoff' '
>         test_cmp expect output
>  '
>
> +test_expect_success 'config commit.signoff implies signoff' '
> +       git config commit.signoff true &&

This should use test_config, I think. Otherwise, the config will stick
around if the test fails. You /could/ use test_when_finished, but
test_config sets that up for you.

> +       echo "871119" >> bar &&
> +       git add bar &&
> +       echo "zort" | git commit -F - bar &&
> +       git cat-file commit HEAD | sed "1,/^\$/d" > output &&
> +       test_cmp expect output &&

Took me a bit to realize (since it doesn't show in the context);
"expect" is setup outside the previous signoff test and then (re)used
here. Reasonable, but we now have commit_msg_is in this test script.
Perhaps worth a quick refactor patch preceding this one to make it use
that function? Probably not required, though?

> +       git config --unset commit.signoff
> +'
> +
>  test_expect_success 'commit message from file (1)' '
>         mkdir subdir &&
>         echo "Log in top directory" >log &&
> --
> 2.49.0
>
>


-- 
D. Ben Knoble

  parent reply	other threads:[~2025-05-13 21:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 12:20 [PATCH] commit: Add commit.signoff configuration option Chris Down
2025-05-13 13:12 ` Kristoffer Haugsbakk
2025-05-13 21:09 ` D. Ben Knoble [this message]
2025-05-14 16:46   ` Chris Down
2025-05-15  0:17     ` Junio C Hamano
2025-05-15 13:22       ` Chris Down
2025-05-16 13:09         ` Junio C Hamano
2025-05-16 15:04           ` Chris Down
2025-06-03  6:54             ` Chris Down
2025-06-04 13:32               ` Junio C Hamano
2025-06-05  1:46                 ` Collin Funk
2025-06-09  4:24                 ` Chris Down
2025-05-16 11:50     ` Ben Knoble
2025-05-16 14:28       ` Chris Down

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALnO6CBdhYFsDN=HPo9HbKeoZH7bb=xVVXUCK7nUdadLg-U_Pw@mail.gmail.com' \
    --to=ben.knoble@gmail.com \
    --cc=chris@chrisdown.name \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).