|
27 | 27 | #include "resolve-undo.h" |
28 | 28 | #include "remote.h" |
29 | 29 | #include "fmt-merge-msg.h" |
| 30 | +#include "gpg-interface.h" |
30 | 31 |
|
31 | 32 | #define DEFAULT_TWOHEAD (1<<0) |
32 | 33 | #define DEFAULT_OCTOPUS (1<<1) |
@@ -64,6 +65,7 @@ static int allow_rerere_auto; |
64 | 65 | static int abort_current_merge; |
65 | 66 | static int show_progress = -1; |
66 | 67 | static int default_to_upstream; |
| 68 | +static const char *sign_commit; |
67 | 69 |
|
68 | 70 | static struct strategy all_strategy[] = { |
69 | 71 | { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL }, |
@@ -209,6 +211,8 @@ static struct option builtin_merge_options[] = { |
209 | 211 | OPT_BOOLEAN(0, "abort", &abort_current_merge, |
210 | 212 | "abort the current in-progress merge"), |
211 | 213 | OPT_SET_INT(0, "progress", &show_progress, "force progress reporting", 1), |
| 214 | + { OPTION_STRING, 'S', "gpg-sign", &sign_commit, "key id", |
| 215 | + "GPG sign commit", PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, |
212 | 216 | OPT_BOOLEAN(0, "overwrite-ignore", &overwrite_ignore, "update ignored files (default)"), |
213 | 217 | OPT_END() |
214 | 218 | }; |
@@ -571,7 +575,11 @@ static int git_merge_config(const char *k, const char *v, void *cb) |
571 | 575 | default_to_upstream = git_config_bool(k, v); |
572 | 576 | return 0; |
573 | 577 | } |
| 578 | + |
574 | 579 | status = fmt_merge_msg_config(k, v, cb); |
| 580 | + if (status) |
| 581 | + return status; |
| 582 | + status = git_gpg_config(k, v, NULL); |
575 | 583 | if (status) |
576 | 584 | return status; |
577 | 585 | return git_diff_ui_config(k, v, cb); |
@@ -910,7 +918,8 @@ static int merge_trivial(struct commit *head) |
910 | 918 | parent->next->item = remoteheads->item; |
911 | 919 | parent->next->next = NULL; |
912 | 920 | prepare_to_commit(); |
913 | | - if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL)) |
| 921 | + if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL, |
| 922 | + sign_commit)) |
914 | 923 | die(_("failed to write commit object")); |
915 | 924 | finish(head, result_commit, "In-index merge"); |
916 | 925 | drop_save(); |
@@ -942,7 +951,8 @@ static int finish_automerge(struct commit *head, |
942 | 951 | strbuf_addch(&merge_msg, '\n'); |
943 | 952 | prepare_to_commit(); |
944 | 953 | free_commit_list(remoteheads); |
945 | | - if (commit_tree(&merge_msg, result_tree, parents, result_commit, NULL)) |
| 954 | + if (commit_tree(&merge_msg, result_tree, parents, result_commit, |
| 955 | + NULL, sign_commit)) |
946 | 956 | die(_("failed to write commit object")); |
947 | 957 | strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy); |
948 | 958 | finish(head, result_commit, buf.buf); |
|
0 commit comments