git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <stolee@gmail.com>
To: Hans Jerry Illikainen <hji@dyntopia.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/1] commit: make the sign-off trailer configurable
Date: Mon, 6 Jan 2020 08:38:23 -0500	[thread overview]
Message-ID: <71a718a7-2be7-391c-dc8f-0626a0a21aac@gmail.com> (raw)
In-Reply-To: <20200105174127.9278-2-hji@dyntopia.com>

On 1/5/2020 12:41 PM, Hans Jerry Illikainen wrote:
> The commit builtin did not previously have a configuration option to
> enable the 'Signed-off-by' trailer by default.
> 
> For some use-cases (namely, when the user doesn't always have the right
> to contribute patches to a project) it makes sense to make it a
> conscientious decision to add the signoff trailer.  However, others'
> might always have the right to ship patches -- in which case it makes
> sense to have an option to add the trailer by default for projects that
> require it.

My initial thought was that the sign-off was supposed to be a purposeful
decision, but then I also realized that I never do anything in the Git
codebase that I _can't_ put online under the GPL. (It may not make it
upstream, but it will always be put online somewhere.)

> This patch introduces a commit.signOff configuration option that
> determine whether the trailer should be added for commits.  It can be
> overridden with the --(no-)signoff command-line option.

With that in mind, I think this is a valuable feature.
 
> Signed-off-by: Hans Jerry Illikainen <hji@dyntopia.com>

Did you generate this with your config option? ;)

> +commit.signOff::
> +	A boolean to specify whether commits should enable the
> +	`-s/--signoff` option by default.  *Note:* Adding the
> +	Signed-off-by: line to a commit message should be a conscious
> +	act and means that you certify you have the rights to submit the
> +	work under the same open source license.  Please see the
> +	'SubmittingPatches' document for further discussion.
> +

I wonder about the language of "should be a conscious act" here. It's
as if you are trying to convince someone to not use this feature. Perhaps
switch it to "is a deliberate act" and add something such as "Enable this
value only in repos where you are the only user and always have these
rights."

The multi-user scenario may be worth clarifying explicitly here. If there
is any chance that another user will join the machine and use that same
repo, then they would have a different user.name and user.email in their
global config (probably) but this as a local setting would provide their
sign-off.

> diff --git a/builtin/commit.c b/builtin/commit.c
> index c70ad01cc9..497e29c58c 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -1474,6 +1474,10 @@ static int git_commit_config(const char *k, const char *v, void *cb)
>  		sign_commit = git_config_bool(k, v) ? "" : NULL;
>  		return 0;
>  	}
> +	if (!strcmp(k, "commit.signoff")) {
> +		signoff = git_config_bool(k, v);
> +		return 0;
> +	}

Since we are directly modifying the same global used by the --[no-]signoff
option, I verified that the config options are checked before the arguments
are parsed. Thus, --no-signoff will override commit.signOff=true...

> +test_expect_success 'commit.signOff=true' '
> +	test_config commit.signOff true &&
> +	echo 1 >>positive &&
> +	git add positive &&
> +	git commit -m "thank you" &&
> +	git cat-file commit HEAD >commit.msg &&
> +	sed -ne "s/Signed-off-by: //p" commit.msg >actual &&
> +	git var GIT_COMMITTER_IDENT >ident &&
> +	sed -e "s/>.*/>/" ident >expected &&
> +	test_cmp expected actual
> +'
> +
> +test_expect_success 'commit.signOff=true and --no-signoff' '
> +	test_config commit.signOff true &&
> +	echo 2 >>positive &&
> +	git add positive &&
> +	git commit --no-signoff -m "thank you" &&
> +	git cat-file commit HEAD >commit.msg &&
> +	sed -ne "s/Signed-off-by: //p" commit.msg >actual &&
> +	git var GIT_COMMITTER_IDENT >ident &&
> +	sed -e "s/>.*/>/" ident >expected &&
> +	! test_cmp expected actual
> +'

...which you test here, too. Excellent.

> +test_expect_success 'commit.signOff=false and --signoff' '
> +	test_config commit.signOff false &&
> +	echo 1 >>positive &&
> +	git add positive &&
> +	git commit --signoff -m "thank you" &&

Perhaps it is worth adding an explicit "-c commit.signOff=false" here?

> +	git cat-file commit HEAD >commit.msg &&
> +	sed -ne "s/Signed-off-by: //p" commit.msg >actual &&
> +	git var GIT_COMMITTER_IDENT >ident &&
> +	sed -e "s/>.*/>/" ident >expected &&
> +	test_cmp expected actual
> +'
> +

I wonder if the boilerplate for these tests could be simplified or
shared across the tests?

For example: could we not just use test_i18ngrep to see if commit.msg
contains (or does not contain) the string "Signed-off-by"?

I believe this patch delivers the stated feature well. Hopefully others
can add commentary on its usefulness or possible issues in using it.

Thanks,
-Stolee

  reply	other threads:[~2020-01-06 13:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-05 17:41 [PATCH 0/1] commit: make the sign-off trailer configurable Hans Jerry Illikainen
2020-01-05 17:41 ` [PATCH 1/1] " Hans Jerry Illikainen
2020-01-06 13:38   ` Derrick Stolee [this message]
2020-01-06 16:53     ` Junio C Hamano
2020-01-06 19:53       ` Derrick Stolee
2020-01-06 20:31         ` Junio C Hamano
2020-01-06 20:45           ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=71a718a7-2be7-391c-dc8f-0626a0a21aac@gmail.com \
    --to=stolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hji@dyntopia.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).