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

Add option to enable threading headers

Add a --thread option to enable generation of In-Reply-To and References headers, used to make the second and subsequent mails appear as replies to the first. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Josh Triplett committed Jul 14, 2006 at 17:49 UTC cc35de8470541e389b7d2bdda4c901574720fa81
2 files changed +22 -9
Documentation/git-format-patch.txt
+9 -1
@@ -9,7 +9,7 @@ git-format-patch - Prepare patches for e-mail submission
9 SYNOPSIS
10 --------
11 [verse]
12 -'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach]
12 +'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]
13 [-s | --signoff] [--diff-options] [--start-number <n>]
14 <since>[..<until>]
15
@@ -35,6 +35,10 @@ they are created in the current working directory.
35 If -n is specified, instead of "[PATCH] Subject", the first line
36 is formatted as "[PATCH n/m] Subject".
37
38 +If given --thread, git-format-patch will generate In-Reply-To and
39 +References headers to make the second and subsequent patch mails appear
40 +as replies to the first mail; this also generates a Message-Id header to
41 +reference.
42
43 OPTIONS
44 -------
@@ -63,6 +67,10 @@ OPTIONS
67 --attach::
68 Create attachments instead of inlining patches.
69
70 +--thread::
71 + Add In-Reply-To and References headers to make the second and
72 + subsequent mails appear as replies to the first. Also generates
73 + the Message-Id header to reference.
74
75 CONFIGURATION
76 -------------
builtin-log.c
+13 -8
@@ -248,6 +248,7 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
248 int start_number = -1;
249 int keep_subject = 0;
250 int ignore_if_in_upstream = 0;
251 + int thread = 0;
252 struct diff_options patch_id_opts;
253 char *add_signoff = NULL;
254 char message_id[1024];
@@ -317,6 +318,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
318 rev.mime_boundary = argv[i] + 9;
319 else if (!strcmp(argv[i], "--ignore-if-in-upstream"))
320 ignore_if_in_upstream = 1;
321 + else if (!strcmp(argv[i], "--thread"))
322 + thread = 1;
323 else
324 argv[j++] = argv[i];
325 }
@@ -379,15 +382,17 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
382 commit = list[nr];
383 rev.nr = total - nr + (start_number - 1);
384 /* Make the second and subsequent mails replies to the first */
382 - if (nr == (total - 2)) {
383 - strncpy(ref_message_id, message_id,
384 - sizeof(ref_message_id));
385 - ref_message_id[sizeof(ref_message_id)-1] = '\0';
386 - rev.ref_message_id = ref_message_id;
385 + if (thread) {
386 + if (nr == (total - 2)) {
387 + strncpy(ref_message_id, message_id,
388 + sizeof(ref_message_id));
389 + ref_message_id[sizeof(ref_message_id)-1]='\0';
390 + rev.ref_message_id = ref_message_id;
391 + }
392 + gen_message_id(message_id, sizeof(message_id),
393 + sha1_to_hex(commit->object.sha1));
394 + rev.message_id = message_id;
395 }
388 - gen_message_id(message_id, sizeof(message_id),
389 - sha1_to_hex(commit->object.sha1));
390 - rev.message_id = message_id;
396 if (!use_stdout)
397 reopen_stdout(commit, rev.nr, keep_subject);
398 shown = log_tree_commit(&rev, commit);