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. Signed-off-by: Eduardo Habkost <ehabkost@xxxxxxxxxx> --- Changes v1 -> v2: * Added documentation to Documentation/git-am.txt and Documentation/config.txt * Added test cases to t4150-am.sh --- Documentation/config.txt | 5 +++++ Documentation/git-am.txt | 6 ++++-- builtin/am.c | 2 ++ t/t4150-am.sh | 24 ++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 30cb94610..6b2990203 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -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 diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 12879e402..f22f10d40 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -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:: diff --git a/builtin/am.c b/builtin/am.c index 31fb60578..d2e02334f 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -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); diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 89a5bacac..41b5481c9 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -479,6 +479,30 @@ 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 $(git cat-file commit HEAD | grep -c "Signed-off-by:") -eq 0 +' + +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 && -- 2.11.0.259.g40922b1