{"thread":{"id":"4889","subject":"[PATCH] Add option to set initial In-Reply-To/References","startedAt":"2006-07-15T00:49:04Z","lastAt":"2006-07-15T00:49:08Z","messageCount":2,"participants":["Josh Triplett"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"23849","messageId":"1152924544.3148.2.camel@josh-work.beaverton.ibm.com","threadId":"4889","inReplyTo":"5b476cb7f1440875f348842a2ef581ab882e7d0d.1152924479.git.josh@freedesktop.org","subject":"[PATCH] Add option to enable threading headers","fromName":"Josh Triplett","fromEmail":"josht@us.ibm.com","sentAt":"2006-07-15T00:49:04Z","receivedAt":"2006-07-15T00:49:04Z","isPatch":true,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"Add a --thread option to enable generation of In-Reply-To and References\nheaders, used to make the second and subsequent mails appear as replies to the\nfirst.\n\nSigned-off-by: Josh Triplett <josh@freedesktop.org>\n---\n Documentation/git-format-patch.txt |   10 +++++++++-\n builtin-log.c                      |   21 +++++++++++++--------\n 2 files changed, 22 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 4ca0014..305bd79 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -9,7 +9,7 @@ git-format-patch - Prepare patches for e\n SYNOPSIS\n --------\n [verse]\n-'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach]\n+'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]\n \t           [-s | --signoff] [--diff-options] [--start-number <n>]\n \t\t   <since>[..<until>]\n \n@@ -35,6 +35,10 @@ they are created in the current working \n If -n is specified, instead of \"[PATCH] Subject\", the first line\n is formatted as \"[PATCH n/m] Subject\".\n \n+If given --thread, git-format-patch will generate In-Reply-To and\n+References headers to make the second and subsequent patch mails appear\n+as replies to the first mail; this also generates a Message-Id header to\n+reference.\n \n OPTIONS\n -------\n@@ -63,6 +67,10 @@ OPTIONS\n --attach::\n \tCreate attachments instead of inlining patches.\n \n+--thread::\n+\tAdd In-Reply-To and References headers to make the second and\n+\tsubsequent mails appear as replies to the first.  Also generates\n+\tthe Message-Id header to reference.\n \n CONFIGURATION\n -------------\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 9d0cae1..4572295 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -242,6 +242,7 @@ int cmd_format_patch(int argc, const cha\n \tint start_number = -1;\n \tint keep_subject = 0;\n \tint ignore_if_in_upstream = 0;\n+\tint thread = 0;\n \tstruct diff_options patch_id_opts;\n \tchar *add_signoff = NULL;\n \tchar message_id[1024];\n@@ -311,6 +312,8 @@ int cmd_format_patch(int argc, const cha\n \t\t\trev.mime_boundary = argv[i] + 9;\n \t\telse if (!strcmp(argv[i], \"--ignore-if-in-upstream\"))\n \t\t\tignore_if_in_upstream = 1;\n+\t\telse if (!strcmp(argv[i], \"--thread\"))\n+\t\t\tthread = 1;\n \t\telse\n \t\t\targv[j++] = argv[i];\n \t}\n@@ -373,15 +376,17 @@ int cmd_format_patch(int argc, const cha\n \t\tcommit = list[nr];\n \t\trev.nr = total - nr + (start_number - 1);\n \t\t/* Make the second and subsequent mails replies to the first */\n-\t\tif (nr == (total - 2)) {\n-\t\t\tstrncpy(ref_message_id, message_id,\n-\t\t\t\tsizeof(ref_message_id));\n-\t\t\tref_message_id[sizeof(ref_message_id)-1] = '\\0';\n-\t\t\trev.ref_message_id = ref_message_id;\n+\t\tif (thread) {\n+\t\t\tif (nr == (total - 2)) {\n+\t\t\t\tstrncpy(ref_message_id, message_id,\n+\t\t\t\t\tsizeof(ref_message_id));\n+\t\t\t\tref_message_id[sizeof(ref_message_id)-1]='\\0';\n+\t\t\t\trev.ref_message_id = ref_message_id;\n+\t\t\t}\n+\t\t\tgen_message_id(message_id, sizeof(message_id),\n+\t\t\t\t       sha1_to_hex(commit->object.sha1));\n+\t\t\trev.message_id = message_id;\n \t\t}\n-\t\tgen_message_id(message_id, sizeof(message_id),\n-\t\t\t       sha1_to_hex(commit->object.sha1));\n-\t\trev.message_id = message_id;\n \t\tif (!use_stdout)\n \t\t\treopen_stdout(commit, rev.nr, keep_subject);\n \t\tshown = log_tree_commit(&rev, commit);\n-- \n1.4.1.gd2cb0\n"},{"id":"23848","messageId":"1152924548.3148.4.camel@josh-work.beaverton.ibm.com","threadId":"4889","inReplyTo":"5b476cb7f1440875f348842a2ef581ab882e7d0d.1152924479.git.josh@freedesktop.org","subject":"[PATCH] Add option to set initial In-Reply-To/References","fromName":"Josh Triplett","fromEmail":"josht@us.ibm.com","sentAt":"2006-07-15T00:49:08Z","receivedAt":"2006-07-15T00:49:08Z","isPatch":true,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"Add the --in-reply-to option to provide a Message-Id for an initial\nIn-Reply-To/References header, useful for including a new patch series as part\nof an existing thread.\n\nSigned-off-by: Josh Triplett <josh@freedesktop.org>\n---\n Documentation/git-format-patch.txt |    6 ++++++\n builtin-log.c                      |   10 ++++++++++\n 2 files changed, 16 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 305bd79..67425dc 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -11,6 +11,7 @@ SYNOPSIS\n [verse]\n 'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]\n \t           [-s | --signoff] [--diff-options] [--start-number <n>]\n+\t\t   [--in-reply-to=Message-Id]\n \t\t   <since>[..<until>]\n \n DESCRIPTION\n@@ -72,6 +73,11 @@ OPTIONS\n \tsubsequent mails appear as replies to the first.  Also generates\n \tthe Message-Id header to reference.\n \n+--in-reply-to=Message-Id::\n+\tMake the first mail (or all the mails with --no-thread) appear as a\n+\treply to the given Message-Id, which avoids breaking threads to\n+\tprovide a new patch series.\n+\n CONFIGURATION\n -------------\n You can specify extra mail header lines to be added to each\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 4572295..3ef7b8e 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -243,6 +243,7 @@ int cmd_format_patch(int argc, const cha\n \tint keep_subject = 0;\n \tint ignore_if_in_upstream = 0;\n \tint thread = 0;\n+\tchar *in_reply_to = NULL;\n \tstruct diff_options patch_id_opts;\n \tchar *add_signoff = NULL;\n \tchar message_id[1024];\n@@ -314,6 +315,14 @@ int cmd_format_patch(int argc, const cha\n \t\t\tignore_if_in_upstream = 1;\n \t\telse if (!strcmp(argv[i], \"--thread\"))\n \t\t\tthread = 1;\n+\t\telse if (!strncmp(argv[i], \"--in-reply-to=\", 14))\n+\t\t\tin_reply_to = argv[i] + 14;\n+\t\telse if (!strcmp(argv[i], \"--in-reply-to\")) {\n+\t\t\ti++;\n+\t\t\tif (i == argc)\n+\t\t\t\tdie(\"Need a Message-Id for --in-reply-to\");\n+\t\t\tin_reply_to = argv[i];\n+\t\t}\n \t\telse\n \t\t\targv[j++] = argv[i];\n \t}\n@@ -371,6 +380,7 @@ int cmd_format_patch(int argc, const cha\n \tif (numbered)\n \t\trev.total = total + start_number - 1;\n \trev.add_signoff = add_signoff;\n+\trev.ref_message_id = in_reply_to;\n \twhile (0 <= --nr) {\n \t\tint shown;\n \t\tcommit = list[nr];\n-- \n1.4.1.gd2cb0\n"}]}