am: add am.signoff add config variable
PATCH v3 1/1 am: add am.signoff add config variable
git-am has options to enable --message-id and --3way by default, but no option to enable --signoff by default. Add a "am.signoff" config option.
---
Changes v1 -> v2:
* Added documentation to Documentation/git-am.txt and Documentation/config.txt
* Added test cases to t4150-am.sh
Changes v2 -> v3:
* Fix doc to mention "--[no-]signoff" instead of "--[no]-signoff"
* Reported-by: Andreas Schwab <[email protected]>
* Add missing test_cmp line on test code
* Use "! grep" instead of "$(grep -c ...)" -eq 0
* Suggested-by: Stefan Beller <[email protected]>
--- Documentation/config.txt | 5 +++++ Documentation/git-am.txt | 6 ++++-- builtin/am.c | 2 ++ t/t4150-am.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-)
Documentation/config.txt +5 -0
@@ -822,6 +822,11 @@ am.keepcr:: by giving `--no-keep-cr` from the command line. See linkgit:git-am[1], linkgit:git-mailsplit[1]. +am.signoff:: + If true, git-am will add a `Signed-off-by:` line to the commit + message. See the signoff option in linkgit:git-commit[1] for + more information. + am.threeWay:: By default, `git am` will fail if the patch does not apply cleanly. When set to true, this setting tells `git am` to fall back on 3-way merge if
Documentation/git-am.txt +4 -2
@@ -9,7 +9,7 @@ git-am - Apply a series of patches from a mailbox SYNOPSIS -------- [verse] -'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] +'git am' [--[no-]signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]3way] [--interactive] [--committer-date-is-author-date] [--ignore-date] [--ignore-space-change | --ignore-whitespace] [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
@@ -32,10 +32,12 @@ OPTIONS If you supply directories, they will be treated as Maildirs. -s:: ---signoff:: +--[no-]-signoff:: Add a `Signed-off-by:` line to the commit message, using the committer identity of yourself. See the signoff option in linkgit:git-commit[1] for more information. + The `am.signoff` configuration variable can be used to specify the + default behaviour. `--no-signoff` is useful to override `am.signoff`. -k:: --keep::
builtin/am.c +2 -0
@@ -154,6 +154,8 @@ static void am_state_init(struct am_state *state, const char *dir)git_config_get_bool ("am.messageid" , &state->message_id); +git_config_get_bool ("am.signoff" , &state->signoff); + state->scissors =SCISSORS_UNSET ;argv_array_init (&state->git_apply_opts);
t/t4150-am.sh +26 -0
@@ -479,6 +479,32 @@ test_expect_success 'am --signoff adds Signed-off-by: line' ' test_cmp expected actual ' +test_expect_success '--no-signoff overrides am.signoff' ' + rm -fr .git/rebase-apply && + git reset --hard first && + test_config am.signoff true && + git am --no-signoff <patch2 && + printf "%s\n" "$signoff" >expected && + git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && + test_cmp expected actual && + git cat-file commit HEAD > actual && + ! grep -q "Signed-off-by:" actual +' + +test_expect_success 'am.signoff adds Signed-off-by: line' ' + rm -fr .git/rebase-apply && + git reset --hard first && + test_config am.signoff true && + git am <patch2 && + printf "%s\n" "$signoff" >expected && + echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected && + git cat-file commit HEAD^ | grep "Signed-off-by:" >actual && + test_cmp expected actual && + echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected && + git cat-file commit HEAD | grep "Signed-off-by:" >actual && + test_cmp expected actual +' + test_expect_success 'am stays in branch' ' echo refs/heads/master2 >expected && git symbolic-ref HEAD >actual &&
Signature · 1 line
2.11.0.259.g40922b1
Documentation/git-am.txt OPTIONS · line 35
Quoted 6 lines · Eduardo Habkost
Documentation/git-am.txt +1
-1@@ -32,10 +32,12 @@ OPTIONS If you supply directories, they will be treated as Maildirs. -s:: ---signoff:: +--[no-]-signoff::
That's one dash too much.
Andreas.
Signature · 3 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 10 lines · Andreas Schwab
Documentation/git-am.txt OPTIONS · line 35
Quoted 6 lines · Eduardo Habkost
Documentation/git-am.txt +1
-1@@ -32,10 +32,12 @@ OPTIONS If you supply directories, they will be treated as Maildirs. -s:: ---signoff:: +--[no-]-signoff::That's one dash too much.
Oops. I can fix it in v4, but I will first wait to see what others think about the legal implications of setting it by default (see point raised by Eric Wong on v1).
Signature · 1 line
Eduardo