Merge branch 'jc/request-pull-match-tagname'
[gitweb.git] / builtin / log.c
index 690caa7830b2a4549012db5e46794118bc36e989..906dca475af0ed51d499cce4a7c0a34f038c5810 100644 (file)
@@ -663,7 +663,8 @@ static FILE *realstdout = NULL;
 static const char *output_directory = NULL;
 static int outdir_offset;
 
-static int reopen_stdout(struct commit *commit, struct rev_info *rev, int quiet)
+static int reopen_stdout(struct commit *commit, const char *subject,
+                        struct rev_info *rev, int quiet)
 {
        struct strbuf filename = STRBUF_INIT;
        int suffix_len = strlen(fmt_patch_suffix) + 1;
@@ -677,7 +678,7 @@ static int reopen_stdout(struct commit *commit, struct rev_info *rev, int quiet)
                        strbuf_addch(&filename, '/');
        }
 
-       get_patch_filename(commit, rev->nr, fmt_patch_suffix, &filename);
+       get_patch_filename(commit, subject, rev->nr, fmt_patch_suffix, &filename);
 
        if (!quiet)
                fprintf(realstdout, "%s\n", filename.buf + outdir_offset);
@@ -737,15 +738,10 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids, const cha
 
 static void gen_message_id(struct rev_info *info, char *base)
 {
-       const char *committer = git_committer_info(IDENT_WARN_ON_NO_NAME);
-       const char *email_start = strrchr(committer, '<');
-       const char *email_end = strrchr(committer, '>');
        struct strbuf buf = STRBUF_INIT;
-       if (!email_start || !email_end || email_start > email_end - 1)
-               die(_("Could not extract email from committer identity."));
-       strbuf_addf(&buf, "%s.%lu.git.%.*s", base,
+       strbuf_addf(&buf, "%s.%lu.git.%s", base,
                    (unsigned long) time(NULL),
-                   (int)(email_end - email_start - 1), email_start + 1);
+                   git_committer_info(IDENT_NO_NAME|IDENT_NO_DATE|IDENT_STRICT));
        info->message_id = strbuf_detach(&buf, NULL);
 }
 
@@ -784,7 +780,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
        const char *encoding = "UTF-8";
        struct diff_options opts;
        int need_8bit_cte = 0;
-       struct commit *commit = NULL;
        struct pretty_print_context pp = {0};
 
        if (rev->commit_format != CMIT_FMT_EMAIL)
@@ -792,31 +787,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
 
        committer = git_committer_info(0);
 
-       if (!numbered_files) {
-               /*
-                * We fake a commit for the cover letter so we get the filename
-                * desired.
-                */
-               commit = xcalloc(1, sizeof(*commit));
-               commit->buffer = xmalloc(400);
-               snprintf(commit->buffer, 400,
-                       "tree 0000000000000000000000000000000000000000\n"
-                       "parent %s\n"
-                       "author %s\n"
-                       "committer %s\n\n"
-                       "cover letter\n",
-                       sha1_to_hex(head->object.sha1), committer, committer);
-       }
-
-       if (!use_stdout && reopen_stdout(commit, rev, quiet))
+       if (!use_stdout &&
+           reopen_stdout(NULL, numbered_files ? NULL : "cover-letter", rev, quiet))
                return;
 
-       if (commit) {
-
-               free(commit->buffer);
-               free(commit);
-       }
-
        log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
                                &need_8bit_cte);
 
@@ -1173,7 +1147,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (do_signoff) {
                const char *committer;
                const char *endpos;
-               committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
+               committer = git_committer_info(IDENT_STRICT);
                endpos = strchr(committer, '>');
                if (!endpos)
                        die(_("bogus committer info %s"), committer);
@@ -1411,8 +1385,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        gen_message_id(&rev, sha1_to_hex(commit->object.sha1));
                }
 
-               if (!use_stdout && reopen_stdout(numbered_files ? NULL : commit,
-                                                &rev, quiet))
+               if (!use_stdout &&
+                   reopen_stdout(numbered_files ? NULL : commit, NULL, &rev, quiet))
                        die(_("Failed to create output files"));
                shown = log_tree_commit(&rev, commit);
                free(commit->buffer);