diff options
author | Paul Tan <pyokagan@gmail.com> | 2015-08-04 21:51:53 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-04 22:02:11 -0700 |
commit | 7e35dacbe392f0d5faf3c75e8964ae96aa4636a7 (patch) | |
tree | 14c0f5160cf75db570fda0a52855ccb5b78987bd | |
parent | builtin-am: implement --committer-date-is-author-date (diff) | |
download | tgif-7e35dacbe392f0d5faf3c75e8964ae96aa4636a7.tar.xz |
builtin-am: implement -S/--gpg-sign, commit.gpgsign
Since 3b4e395 (am: add the --gpg-sign option, 2014-02-01), git-am.sh
supported the --gpg-sign option, and would pass it to git-commit-tree,
thus GPG-signing the commit object.
Re-implement this option in builtin/am.c.
git-commit-tree would also sign the commit by default if the
commit.gpgsign setting is true. Since we do not run commit-tree, we
re-implement this behavior by handling the commit.gpgsign setting
ourselves.
Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/am.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin/am.c b/builtin/am.c index 1561580de4..18611fa0c3 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -110,6 +110,7 @@ struct am_state { const char *resolvemsg; int committer_date_is_author_date; int ignore_date; + const char *sign_commit; int rebasing; }; @@ -119,6 +120,8 @@ struct am_state { */ static void am_state_init(struct am_state *state, const char *dir) { + int gpgsign; + memset(state, 0, sizeof(*state)); assert(dir); @@ -133,6 +136,9 @@ static void am_state_init(struct am_state *state, const char *dir) state->scissors = SCISSORS_UNSET; argv_array_init(&state->git_apply_opts); + + if (!git_config_get_bool("commit.gpgsign", &gpgsign)) + state->sign_commit = gpgsign ? "" : NULL; } /** @@ -1227,7 +1233,7 @@ static void do_commit(const struct am_state *state) state->ignore_date ? "" : state->author_date, 1); if (commit_tree(state->msg, state->msg_len, tree, parents, commit, - author, NULL)) + author, state->sign_commit)) die(_("failed to write commit object")); reflog_msg = getenv("GIT_REFLOG_ACTION"); @@ -1673,6 +1679,9 @@ int cmd_am(int argc, const char **argv, const char *prefix) N_("lie about committer date")), OPT_BOOL(0, "ignore-date", &state.ignore_date, N_("use current timestamp for author date")), + { OPTION_STRING, 'S', "gpg-sign", &state.sign_commit, N_("key-id"), + N_("GPG-sign commits"), + PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_HIDDEN_BOOL(0, "rebasing", &state.rebasing, N_("(internal use for git-rebase)")), OPT_END() |