aboutsummaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2006-05-20 15:40:29 +0200
committerJunio C Hamano <junkio@cox.net>2006-05-21 02:03:09 -0700
commit698ce6f87e0d6db380f7306e190e8586da184577 (patch)
tree14171dae273827471bea4021a325b4d4a6c2c7d4 /log-tree.c
parent328b710d800dc3786fe2b8595e5553dc4a4af424 (diff)
downloadgit-698ce6f87e0d6db380f7306e190e8586da184577.tar.gz
git-698ce6f87e0d6db380f7306e190e8586da184577.tar.xz
fmt-patch: Support --attach
This patch touches a couple of files, because it adds options to print a custom text just after the subject of a commit, and just after the diffstat. [jc: made "many dashes" used as the boundary leader into a single variable, to reduce the possibility of later tweaks to miscount the number of dashes to break it.] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/log-tree.c b/log-tree.c
index 526d578e9..7e23e4278 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -20,7 +20,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
const char *extra;
int len;
- char* subject = NULL;
+ char *subject = NULL, *after_subject = NULL;
opt->loginfo = NULL;
if (!opt->verbose_header) {
@@ -52,6 +52,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
+ char *sha1 = sha1_to_hex(commit->object.sha1);
if (opt->total > 0) {
static char buffer[64];
snprintf(buffer, sizeof(buffer),
@@ -63,8 +64,36 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
else
subject = "Subject: ";
- printf("From %s Thu Apr 7 15:13:13 2005\n",
- sha1_to_hex(commit->object.sha1));
+ printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
+ if (opt->mime_boundary) {
+ static char subject_buffer[1024];
+ static char buffer[1024];
+ snprintf(subject_buffer, sizeof(subject_buffer) - 1,
+ "MIME-Version: 1.0\n"
+ "Content-Type: multipart/mixed;\n"
+ " boundary=\"%s%s\"\n"
+ "\n"
+ "This is a multi-part message in MIME "
+ "format.\n"
+ "--%s%s\n"
+ "Content-Type: text/plain; "
+ "charset=UTF-8; format=fixed\n"
+ "Content-Transfer-Encoding: 8bit\n\n",
+ mime_boundary_leader, opt->mime_boundary,
+ mime_boundary_leader, opt->mime_boundary);
+ after_subject = subject_buffer;
+
+ snprintf(buffer, sizeof(buffer) - 1,
+ "--%s%s\n"
+ "Content-Type: text/x-patch;\n"
+ " name=\"%s.diff\"\n"
+ "Content-Transfer-Encoding: 8bit\n"
+ "Content-Disposition: inline;\n"
+ " filename=\"%s.diff\"\n\n",
+ mime_boundary_leader, opt->mime_boundary,
+ sha1, sha1);
+ opt->diffopt.stat_sep = buffer;
+ }
} else {
printf("%s%s",
opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
@@ -81,7 +110,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
/*
* And then the pretty-printed message itself
*/
- len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject);
+ len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, after_subject);
printf("%s%s%s", this_header, extra, sep);
}