From: Chen Jingpiao <chenjingpiao@gmail.com>
To: git@vger.kernel.org
Cc: Chen Jingpiao <chenjingpiao@gmail.com>
Subject: [GSoC][PATCH] commit: add a commit.signOff config variable
Date: Sun, 4 Feb 2018 10:03:18 +0800 [thread overview]
Message-ID: <20180204020318.4363-1-chenjingpiao@gmail.com> (raw)
Add the commit.signOff configuration variable to use the -s or --signoff
option of git commit by default.
Signed-off-by: Chen Jingpiao <chenjingpiao@gmail.com>
---
Though we can configure signoff using format.signOff variable. Someone like to
add Signed-off-by line by the committer.
Documentation/config.txt | 4 +++
Documentation/git-commit.txt | 2 ++
builtin/commit.c | 4 +++
t/t7501-commit.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 79 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 0e25b2c92..5dec3f0cb 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1303,6 +1303,10 @@ commit.gpgSign::
convenient to use an agent to avoid typing your GPG passphrase
several times.
+commit.signOff::
+ A boolean value which lets you enable the `-s/--signoff` option of
+ `git commit` by default. See linkgit:git-commit[1].
+
commit.status::
A boolean to enable/disable inclusion of status information in the
commit message template when using an editor to prepare the commit
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index f970a4342..7a28ea765 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -166,6 +166,8 @@ The `-m` option is mutually exclusive with `-c`, `-C`, and `-F`.
the rights to submit this work under the same license and
agrees to a Developer Certificate of Origin
(see http://developercertificate.org/ for more information).
+ See the `commit.signOff` configuration variable in
+ linkgit:git-config[1].
-n::
--no-verify::
diff --git a/builtin/commit.c b/builtin/commit.c
index 4610e3d8e..324213254 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1548,6 +1548,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;
+ }
if (!strcmp(k, "commit.verbose")) {
int is_bool;
config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index fa61b1a4e..46733ed2a 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -505,6 +505,75 @@ Myfooter: x" &&
test_cmp expected actual
'
+test_expect_success "commit.signoff=true and --signoff omitted" '
+ echo 7 >positive &&
+ git add positive &&
+ git -c commit.signoff=true commit -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ (
+ echo thank you
+ echo
+ git var GIT_COMMITTER_IDENT |
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ ) >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success "commit.signoff=true and --signoff" '
+ echo 8 >positive &&
+ git add positive &&
+ git -c commit.signoff=true commit --signoff -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ (
+ echo thank you
+ echo
+ git var GIT_COMMITTER_IDENT |
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ ) >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success "commit.signoff=true and --no-signoff" '
+ echo 9 >positive &&
+ git add positive &&
+ git -c commit.signoff=true commit --no-signoff -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ echo thank you >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success "commit.signoff=false and --signoff omitted" '
+ echo 10 >positive &&
+ git add positive &&
+ git -c commit.signoff=false commit -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ echo thank you >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success "commit.signoff=false and --signoff" '
+ echo 11 >positive &&
+ git add positive &&
+ git -c commit.signoff=false commit --signoff -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ (
+ echo thank you
+ echo
+ git var GIT_COMMITTER_IDENT |
+ sed -e "s/>.*/>/" -e "s/^/Signed-off-by: /"
+ ) >expected &&
+ test_cmp expected actual
+'
+
+test_expect_success "commit.signoff=false and --no-signoff" '
+ echo 12 >positive &&
+ git add positive &&
+ git -c commit.signoff=false commit --no-signoff -m "thank you" &&
+ git cat-file commit HEAD | sed -e "1,/^\$/d" >actual &&
+ echo thank you >expected &&
+ test_cmp expected actual
+'
+
test_expect_success 'multiple -m' '
>negative &&
--
2.16.1.70.g5ccd54536
next reply other threads:[~2018-02-04 2:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-04 2:03 Chen Jingpiao [this message]
2018-02-04 11:31 ` [GSoC][PATCH] commit: add a commit.signOff config variable Eric Sunshine
2018-02-04 18:59 ` Ævar Arnfjörð Bjarmason
2018-02-05 21:50 ` Stefan Beller
2018-02-06 7:01 ` Chen Jingpiao
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=20180204020318.4363-1-chenjingpiao@gmail.com \
--to=chenjingpiao@gmail.com \
--cc=git@vger.kernel.org \
/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).