summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a3e65d7)
raw | patch | inline | side by side (parent: a3e65d7)
author | Josh Triplett <josht@us.ibm.com> | |
Sat, 15 Jul 2006 00:48:51 +0000 (17:48 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 15 Jul 2006 03:41:36 +0000 (20:41 -0700) |
Add message_id and ref_message_id fields to struct rev_info, used in show_log
with CMIT_FMT_EMAIL to set Message-Id and In-Reply-To/References respectively.
Use these in git-format-patch to make the second and subsequent patch mails
replies to the first patch mail.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
with CMIT_FMT_EMAIL to set Message-Id and In-Reply-To/References respectively.
Use these in git-format-patch to make the second and subsequent patch mails
replies to the first patch mail.
Signed-off-by: Josh Triplett <josh@freedesktop.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-log.c | patch | blob | history | |
log-tree.c | patch | blob | history | |
revision.h | patch | blob | history |
diff --git a/builtin-log.c b/builtin-log.c
index 7e5cab15c106f59417804a25d094c94e78d64063..1f1074cec66d367d217fffc611dc45981ea67013 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
o2->flags = flags2;
}
+static void gen_message_id(char *dest, unsigned int length, char *base)
+{
+ const char *committer = git_committer_info(1);
+ const char *email_start = strrchr(committer, '<');
+ const char *email_end = strrchr(committer, '>');
+ if(!email_start || !email_end || email_start > email_end - 1)
+ die("Could not extract email from committer identity.");
+ snprintf(dest, length, "%s.%u.git.%.*s", base, time(NULL),
+ email_end - email_start - 1, email_start + 1);
+}
+
int cmd_format_patch(int argc, const char **argv, char **envp)
{
struct commit *commit;
int ignore_if_in_upstream = 0;
struct diff_options patch_id_opts;
char *add_signoff = NULL;
+ char message_id[1024];
+ char ref_message_id[1024];
git_config(git_format_config);
init_revisions(&rev);
int shown;
commit = list[nr];
rev.nr = total - nr + (start_number - 1);
+ /* Make the second and subsequent mails replies to the first */
+ if (nr == (total - 2)) {
+ strncpy(ref_message_id, message_id,
+ sizeof(ref_message_id));
+ ref_message_id[sizeof(ref_message_id)-1] = '\0';
+ rev.ref_message_id = ref_message_id;
+ }
+ gen_message_id(message_id, sizeof(message_id),
+ sha1_to_hex(commit->object.sha1));
+ rev.message_id = message_id;
if (!use_stdout)
reopen_stdout(commit, rev.nr, keep_subject);
shown = log_tree_commit(&rev, commit);
diff --git a/log-tree.c b/log-tree.c
index 9d8d46fa0038202bd49dee9cf5d1a60f781e5d7d..497198841736d11c178b0806747de5e70f20b588 100644 (file)
--- a/log-tree.c
+++ b/log-tree.c
subject = "Subject: ";
printf("From %s Mon Sep 17 00:00:00 2001\n", sha1);
+ if (opt->message_id)
+ printf("Message-Id: <%s>\n", opt->message_id);
+ if (opt->ref_message_id)
+ printf("In-Reply-To: <%s>\nReferences: <%s>\n",
+ opt->ref_message_id, opt->ref_message_id);
if (opt->mime_boundary) {
static char subject_buffer[1024];
static char buffer[1024];
diff --git a/revision.h b/revision.h
index c010a0811604e55f4e46d08d986ae62edfb192ee..e23ec8f45a3b635d83f662e4de5d671e41f37919 100644 (file)
--- a/revision.h
+++ b/revision.h
struct log_info *loginfo;
int nr, total;
const char *mime_boundary;
+ const char *message_id;
+ const char *ref_message_id;
const char *add_signoff;
const char *extra_headers;