diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-06-16 12:18:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-16 12:18:38 -0700 |
commit | f18871dcd487bd9391accaffb4e818d58f2d2720 (patch) | |
tree | af26a17cd6f080a2fd4fb427df674f2f330adceb /builtin/log.c | |
parent | 2075a0c27fa5cf4f9f03964d407dc015c1749a7e (diff) | |
parent | 7022650f61ff7d7c9297db4a04f4e93ae14e1750 (diff) | |
download | git-f18871dcd487bd9391accaffb4e818d58f2d2720.tar.gz |
Merge branch 'jm/format-patch-mail-sig'
* jm/format-patch-mail-sig:
format-patch: add "--signature-file=<file>" option
format-patch: make newline after signature conditional
Diffstat (limited to 'builtin/log.c')
-rw-r--r-- | builtin/log.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/builtin/log.c b/builtin/log.c index 3b6a6bbadd..83b6c489fc 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -669,6 +669,7 @@ static void add_header(const char *value) static int thread; static int do_signoff; static const char *signature = git_version_string; +static const char *signature_file; static int config_cover_letter; enum { @@ -738,6 +739,8 @@ static int git_format_config(const char *var, const char *value, void *cb) } if (!strcmp(var, "format.signature")) return git_config_string(&signature, var, value); + if (!strcmp(var, "format.signaturefile")) + return git_config_pathname(&signature_file, var, value); if (!strcmp(var, "format.coverletter")) { if (value && !strcasecmp(value, "auto")) { config_cover_letter = COVER_AUTO; @@ -840,8 +843,13 @@ static void gen_message_id(struct rev_info *info, char *base) static void print_signature(void) { - if (signature && *signature) - printf("-- \n%s\n\n", signature); + if (!signature || !*signature) + return; + + printf("-- \n%s", signature); + if (signature[strlen(signature)-1] != '\n') + putchar('\n'); + putchar('\n'); } static void add_branch_description(struct strbuf *buf, const char *branch_name) @@ -1226,6 +1234,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) PARSE_OPT_OPTARG, thread_callback }, OPT_STRING(0, "signature", &signature, N_("signature"), N_("add a signature")), + OPT_FILENAME(0, "signature-file", &signature_file, + N_("add a signature from a file")), OPT__QUIET(&quiet, N_("don't print the patch filenames")), OPT_END() }; @@ -1443,6 +1453,18 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) cover_letter = (config_cover_letter == COVER_ON); } + if (!signature) { + ; /* --no-signature inhibits all signatures */ + } else if (signature && signature != git_version_string) { + ; /* non-default signature already set */ + } else if (signature_file) { + struct strbuf buf = STRBUF_INIT; + + if (strbuf_read_file(&buf, signature_file, 128) < 0) + die_errno(_("unable to read signature file '%s'"), signature_file); + signature = strbuf_detach(&buf, NULL); + } + if (in_reply_to || thread || cover_letter) rev.ref_message_ids = xcalloc(1, sizeof(struct string_list)); if (in_reply_to) { |