{"thread":{"id":"4373","subject":"[PATCH] format-patch: resurrect extra headers from config","startedAt":"2006-06-02T13:21:17Z","lastAt":"2006-06-02T13:21:17Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21098","messageId":"Pine.LNX.4.63.0606021520240.4608@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"4373","inReplyTo":null,"subject":"[PATCH] format-patch: resurrect extra headers from config","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-06-02T13:21:17Z","receivedAt":"2006-06-02T13:21:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nOnce again, if you have\n\n\t[format]\n\t\theaders = \"Origamization: EvilEmpire\\n\"\n\nformat-patch will add these headers just after the \"Subject:\" line.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n---\n builtin-log.c |   20 ++++++++++++++++++++\n log-tree.c    |    8 +++++---\n revision.h    |    1 +\n 3 files changed, 26 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex ac4822d..6612f4c 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -85,6 +85,23 @@ static int istitlechar(char c)\n \t\t(c >= '0' && c <= '9') || c == '.' || c == '_';\n }\n \n+static char *extra_headers = NULL;\n+static int extra_headers_size = 0;\n+\n+static int git_format_config(const char *var, const char *value)\n+{\n+\tif (!strcmp(var, \"format.headers\")) {\n+\t\tint len = strlen(value);\n+\t\textra_headers_size += len + 1;\n+\t\textra_headers = realloc(extra_headers, extra_headers_size);\n+\t\textra_headers[extra_headers_size - len - 1] = 0;\n+\t\tstrcat(extra_headers, value);\n+\t\treturn 0;\n+\t}\n+\treturn git_default_config(var, value);\n+}\n+\n+\n static FILE *realstdout = NULL;\n static char *output_directory = NULL;\n \n@@ -162,6 +179,9 @@ int cmd_format_patch(int argc, const cha\n \trev.ignore_merges = 1;\n \trev.diffopt.output_format = DIFF_FORMAT_PATCH;\n \n+\tgit_config(git_format_config);\n+\trev.extra_headers = extra_headers;\n+\n \t/*\n \t * Parse the arguments before setup_revisions(), or something\n \t * like \"git fmt-patch -o a123 HEAD^..\" may fail; a123 is\ndiff --git a/log-tree.c b/log-tree.c\nindex e86e16b..ebb49f2 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -51,7 +51,7 @@ void show_log(struct rev_info *opt, stru\n \tint abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;\n \tconst char *extra;\n \tint len;\n-\tchar *subject = NULL, *after_subject = NULL;\n+\tconst char *subject = NULL, *extra_headers = opt->extra_headers;\n \n \topt->loginfo = NULL;\n \tif (!opt->verbose_header) {\n@@ -100,6 +100,7 @@ void show_log(struct rev_info *opt, stru\n \t\t\tstatic char subject_buffer[1024];\n \t\t\tstatic char buffer[1024];\n \t\t\tsnprintf(subject_buffer, sizeof(subject_buffer) - 1,\n+\t\t\t\t \"%s\"\n \t\t\t\t \"MIME-Version: 1.0\\n\"\n \t\t\t\t \"Content-Type: multipart/mixed;\\n\"\n \t\t\t\t \" boundary=\\\"%s%s\\\"\\n\"\n@@ -110,9 +111,10 @@ void show_log(struct rev_info *opt, stru\n \t\t\t\t \"Content-Type: text/plain; \"\n \t\t\t\t \"charset=UTF-8; format=fixed\\n\"\n \t\t\t\t \"Content-Transfer-Encoding: 8bit\\n\\n\",\n+\t\t\t\t extra_headers ? extra_headers : \"\",\n \t\t\t\t mime_boundary_leader, opt->mime_boundary,\n \t\t\t\t mime_boundary_leader, opt->mime_boundary);\n-\t\t\tafter_subject = subject_buffer;\n+\t\t\textra_headers = subject_buffer;\n \n \t\t\tsnprintf(buffer, sizeof(buffer) - 1,\n \t\t\t\t \"--%s%s\\n\"\n@@ -141,7 +143,7 @@ void show_log(struct rev_info *opt, stru\n \t/*\n \t * And then the pretty-printed message itself\n \t */\n-\tlen = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, after_subject);\n+\tlen = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, extra_headers);\n \n \tif (opt->add_signoff)\n \t\tlen = append_signoff(this_header, sizeof(this_header), len,\ndiff --git a/revision.h b/revision.h\nindex 75796bc..7d85b0f 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -61,6 +61,7 @@ struct rev_info {\n \tint\t\tnr, total;\n \tconst char\t*mime_boundary;\n \tconst char\t*add_signoff;\n+\tconst char\t*extra_headers;\n \n \t/* special limits */\n \tint max_count;\n-- \n1.3.3.g83f2b-dirty\n"}]}