summaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorJosh Triplett <josht@us.ibm.com>2006-07-14 17:48:51 -0700
committerJunio C Hamano <junkio@cox.net>2006-07-14 20:41:36 -0700
commitd1566f7883f727f38bf442af3fdb69d36e6fcea2 (patch)
tree4ecb66358d83203fc1d811c4c2a5de9d1891fb7d /builtin-log.c
parenta3e65d74ee7ec9e6f49de7688a1cdac052910bd4 (diff)
downloadgit-d1566f7883f727f38bf442af3fdb69d36e6fcea2.tar.gz
git-format-patch: Make the second and subsequent mails replies to the first
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>
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 7e5cab15c1..1f1074cec6 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -226,6 +226,17 @@ static void get_patch_ids(struct rev_info *rev, struct diff_options *options)
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;
@@ -239,6 +250,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
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);
@@ -365,6 +378,16 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
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);