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>
This commit is contained in:
Stephen Boyd
2009-03-22 19:14:05 -07:00
committed by Junio C Hamano
parent 6fa8e6278b
commit 108dab2811
14 changed files with 112 additions and 44 deletions

View File

@ -607,7 +607,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
int nr, struct commit **list, struct commit *head)
{
const char *committer;
char *head_sha1;
const char *subject_start = NULL;
const char *body = "*** SUBJECT HERE ***\n\n*** BLURB HERE ***\n";
const char *msg;
@ -624,7 +623,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
die("Cover letter needs email format");
committer = git_committer_info(0);
head_sha1 = sha1_to_hex(head->object.sha1);
if (!numbered_files) {
/*
@ -639,7 +637,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
"author %s\n"
"committer %s\n\n"
"cover letter\n",
head_sha1, committer, committer);
sha1_to_hex(head->object.sha1), committer, committer);
}
if (!use_stdout && reopen_stdout(commit, rev))
@ -651,7 +649,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
free(commit);
}
log_write_email_headers(rev, head_sha1, &subject_start, &extra_headers,
log_write_email_headers(rev, head, &subject_start, &extra_headers,
&need_8bit_cte);
msg = body;
@ -1011,6 +1009,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
const char *msgid = clean_message_id(in_reply_to);
string_list_append(msgid, rev.ref_message_ids);
}
rev.numbered_files = numbered_files;
rev.patch_suffix = fmt_patch_suffix;
if (cover_letter) {
if (thread)
gen_message_id(&rev, "cover");