summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorStephen Boyd <bebarino@gmail.com>2009-03-22 19:14:05 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-22 21:45:19 -0700
commit108dab2811701c20d6d6e8d9fe8af88e41d65d77 (patch)
tree7f421f58447ff79392778c433f061d7fcbb91f2a /log-tree.c
parent6fa8e6278b210bfa56fcb54ed38d2b485350e7c6 (diff)
downloadgit-108dab2811701c20d6d6e8d9fe8af88e41d65d77.tar.gz
format-patch: --attach/inline uses filename instead of SHA1
Currently when format-patch is used with --attach or --inline the patch attachment has the SHA1 of the commit for its filename. This replaces the SHA1 with the filename used by format-patch when outputting to files. Fix tests relying on the SHA1 output and add a test showing how the --suffix option affects the attachment filename output. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/log-tree.c b/log-tree.c
index aee9995531..56a3488592 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -201,13 +201,14 @@ void get_patch_filename(struct commit *commit, int nr, const char *suffix,
}
}
-void log_write_email_headers(struct rev_info *opt, const char *name,
+void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **subject_p,
const char **extra_headers_p,
int *need_8bit_cte_p)
{
const char *subject = NULL;
const char *extra_headers = opt->extra_headers;
+ const char *name = sha1_to_hex(commit->object.sha1);
*need_8bit_cte_p = 0; /* unknown */
if (opt->total > 0) {
@@ -246,6 +247,7 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
if (opt->mime_boundary) {
static char subject_buffer[1024];
static char buffer[1024];
+ struct strbuf filename = STRBUF_INIT;
*need_8bit_cte_p = -1; /* NEVER */
snprintf(subject_buffer, sizeof(subject_buffer) - 1,
"%s"
@@ -264,18 +266,21 @@ void log_write_email_headers(struct rev_info *opt, const char *name,
mime_boundary_leader, opt->mime_boundary);
extra_headers = subject_buffer;
+ get_patch_filename(opt->numbered_files ? NULL : commit, opt->nr,
+ opt->patch_suffix, &filename);
snprintf(buffer, sizeof(buffer) - 1,
"\n--%s%s\n"
"Content-Type: text/x-patch;"
- " name=\"%s.diff\"\n"
+ " name=\"%s\"\n"
"Content-Transfer-Encoding: 8bit\n"
"Content-Disposition: %s;"
- " filename=\"%s.diff\"\n\n",
+ " filename=\"%s\"\n\n",
mime_boundary_leader, opt->mime_boundary,
- name,
+ filename.buf,
opt->no_inline ? "attachment" : "inline",
- name);
+ filename.buf);
opt->diffopt.stat_sep = buffer;
+ strbuf_release(&filename);
}
*subject_p = subject;
*extra_headers_p = extra_headers;
@@ -355,8 +360,7 @@ void show_log(struct rev_info *opt)
*/
if (opt->commit_format == CMIT_FMT_EMAIL) {
- log_write_email_headers(opt, sha1_to_hex(commit->object.sha1),
- &subject, &extra_headers,
+ log_write_email_headers(opt, commit, &subject, &extra_headers,
&need_8bit_cte);
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);