@matheusbsbs / matheus-bagliano / commits / 20ff06805c
Fork 0

format-patch: resurrect extra headers from config

Once again, if you have [format] headers = "Origamization: EvilEmpire\n" format-patch will add these headers just after the "Subject:" line. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Jun 2, 2006 at 15:21 UTC 20ff06805c66826404b154b9309a8581449af2b0
3 files changed +26 -3
builtin-log.c
+20
@@ -85,6 +85,23 @@ static int istitlechar(char c)
85 (c >= '0' && c <= '9') || c == '.' || c == '_';
86 }
87
88 +static char *extra_headers = NULL;
89 +static int extra_headers_size = 0;
90 +
91 +static int git_format_config(const char *var, const char *value)
92 +{
93 + if (!strcmp(var, "format.headers")) {
94 + int len = strlen(value);
95 + extra_headers_size += len + 1;
96 + extra_headers = realloc(extra_headers, extra_headers_size);
97 + extra_headers[extra_headers_size - len - 1] = 0;
98 + strcat(extra_headers, value);
99 + return 0;
100 + }
101 + return git_default_config(var, value);
102 +}
103 +
104 +
105 static FILE *realstdout = NULL;
106 static char *output_directory = NULL;
107
@@ -162,6 +179,9 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
179 rev.ignore_merges = 1;
180 rev.diffopt.output_format = DIFF_FORMAT_PATCH;
181
182 + git_config(git_format_config);
183 + rev.extra_headers = extra_headers;
184 +
185 /*
186 * Parse the arguments before setup_revisions(), or something
187 * like "git fmt-patch -o a123 HEAD^.." may fail; a123 is
log-tree.c
+5 -3
@@ -51,7 +51,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
51 int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
52 const char *extra;
53 int len;
54 - char *subject = NULL, *after_subject = NULL;
54 + const char *subject = NULL, *extra_headers = opt->extra_headers;
55
56 opt->loginfo = NULL;
57 if (!opt->verbose_header) {
@@ -100,6 +100,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
100 static char subject_buffer[1024];
101 static char buffer[1024];
102 snprintf(subject_buffer, sizeof(subject_buffer) - 1,
103 + "%s"
104 "MIME-Version: 1.0\n"
105 "Content-Type: multipart/mixed;\n"
106 " boundary=\"%s%s\"\n"
@@ -110,9 +111,10 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
111 "Content-Type: text/plain; "
112 "charset=UTF-8; format=fixed\n"
113 "Content-Transfer-Encoding: 8bit\n\n",
114 + extra_headers ? extra_headers : "",
115 mime_boundary_leader, opt->mime_boundary,
116 mime_boundary_leader, opt->mime_boundary);
115 - after_subject = subject_buffer;
117 + extra_headers = subject_buffer;
118
119 snprintf(buffer, sizeof(buffer) - 1,
120 "--%s%s\n"
@@ -141,7 +143,7 @@ void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
143 /*
144 * And then the pretty-printed message itself
145 */
144 - len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, after_subject);
146 + len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev, subject, extra_headers);
147
148 if (opt->add_signoff)
149 len = append_signoff(this_header, sizeof(this_header), len,
revision.h
+1
@@ -61,6 +61,7 @@ struct rev_info {
61 int nr, total;
62 const char *mime_boundary;
63 const char *add_signoff;
64 + const char *extra_headers;
65
66 /* special limits */
67 int max_count;