@matheusbsbs / matheus-bagliano / commits / b079c50e03
Fork 0

format-patch: track several references

Currently, format-patch can only track a single reference (the In-Reply-To:) for each mail. To ensure proper threading, we should list all known references for every mail. Change the rev_info.ref_message_id field to a string_list, so that we can append references at will, and change the output formatting routines to print all of them in the References: header. The last entry in the list is implicitly assumed to be the In-Reply-To:, which gives output consistent with RFC 2822: The "References:" field will contain the contents of the parent's "References:" field (if any) followed by the contents of the parent's "Message-ID:" field (if any). Note that this is just preparatory work; nothing uses it yet, so all "References:" fields in the output are still only one deep. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Feb 19, 2009 at 22:26 UTC b079c50e03a812f5c8197b8f38e0a5fe6dd31321
3 files changed +19 -8
builtin-log.c
+10 -4
@@ -17,6 +17,7 @@
17 #include "run-command.h"
18 #include "shortlog.h"
19 #include "remote.h"
20 +#include "string-list.h"
21
22 /* Set a default date-time format for git log ("log.date" config variable) */
23 static const char *default_date_mode = NULL;
@@ -1011,8 +1012,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1012 numbered = 1;
1013 if (numbered)
1014 rev.total = total + start_number - 1;
1014 - if (in_reply_to)
1015 - rev.ref_message_id = clean_message_id(in_reply_to);
1015 + if (in_reply_to || thread || cover_letter)
1016 + rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
1017 + if (in_reply_to) {
1018 + const char *msgid = clean_message_id(in_reply_to);
1019 + string_list_append(msgid, rev.ref_message_ids);
1020 + }
1021 if (cover_letter) {
1022 if (thread)
1023 gen_message_id(&rev, "cover");
@@ -1036,10 +1041,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1041 * otherwise, make everything a reply
1042 * to that.
1043 */
1039 - if (rev.ref_message_id)
1044 + if (rev.ref_message_ids->nr > 0)
1045 free(rev.message_id);
1046 else
1042 - rev.ref_message_id = rev.message_id;
1047 + string_list_append(rev.message_id,
1048 + rev.ref_message_ids);
1049 }
1050 gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
1051 }
log-tree.c
+8 -3
@@ -6,6 +6,7 @@
6 #include "log-tree.h"
7 #include "reflog-walk.h"
8 #include "refs.h"
9 +#include "string-list.h"
10
11 struct decoration name_decoration = { "object names" };
12
@@ -211,9 +212,13 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
212 printf("Message-Id: <%s>\n", opt->message_id);
213 graph_show_oneline(opt->graph);
214 }
214 - if (opt->ref_message_id) {
215 - printf("In-Reply-To: <%s>\nReferences: <%s>\n",
216 - opt->ref_message_id, opt->ref_message_id);
215 + if (opt->ref_message_ids && opt->ref_message_ids->nr > 0) {
216 + int i, n;
217 + n = opt->ref_message_ids->nr;
218 + printf("In-Reply-To: <%s>\n", opt->ref_message_ids->items[n-1].string);
219 + for (i = 0; i < n; i++)
220 + printf("%s<%s>\n", (i > 0 ? "\t" : "References: "),
221 + opt->ref_message_ids->items[i].string);
222 graph_show_oneline(opt->graph);
223 }
224 if (opt->mime_boundary) {
revision.h
+1 -1
@@ -89,7 +89,7 @@ struct rev_info {
89 int nr, total;
90 const char *mime_boundary;
91 char *message_id;
92 - const char *ref_message_id;
92 + struct string_list *ref_message_ids;
93 const char *add_signoff;
94 const char *extra_headers;
95 const char *log_reencode;