summaryrefslogtreecommitdiff
path: root/builtin-log.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-02-19 22:26:31 +0100
committerJunio C Hamano <gitster@pobox.com>2009-02-21 20:26:03 -0800
commitb079c50e03a812f5c8197b8f38e0a5fe6dd31321 (patch)
treebe6aa158cc92221b3db7df40aa792dfb904bdaca /builtin-log.c
parent484cf6c3f1169786c45ccda54c9961ef66465c03 (diff)
downloadgit-b079c50e03a812f5c8197b8f38e0a5fe6dd31321.tar.gz
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>
Diffstat (limited to 'builtin-log.c')
-rw-r--r--builtin-log.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/builtin-log.c b/builtin-log.c
index 2ae39afccd..59671139b8 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -17,6 +17,7 @@
#include "run-command.h"
#include "shortlog.h"
#include "remote.h"
+#include "string-list.h"
/* Set a default date-time format for git log ("log.date" config variable) */
static const char *default_date_mode = NULL;
@@ -1011,8 +1012,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
numbered = 1;
if (numbered)
rev.total = total + start_number - 1;
- if (in_reply_to)
- rev.ref_message_id = clean_message_id(in_reply_to);
+ if (in_reply_to || thread || cover_letter)
+ rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
+ if (in_reply_to) {
+ const char *msgid = clean_message_id(in_reply_to);
+ string_list_append(msgid, rev.ref_message_ids);
+ }
if (cover_letter) {
if (thread)
gen_message_id(&rev, "cover");
@@ -1036,10 +1041,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
* otherwise, make everything a reply
* to that.
*/
- if (rev.ref_message_id)
+ if (rev.ref_message_ids->nr > 0)
free(rev.message_id);
else
- rev.ref_message_id = rev.message_id;
+ string_list_append(rev.message_id,
+ rev.ref_message_ids);
}
gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
}