{"thread":{"id":"32441","subject":"[PATCH 0/7] format-patch --reroll-count","startedAt":"2012-12-22T08:33:25Z","lastAt":"2013-01-01T03:04:36Z","messageCount":9,"participants":["Junio C Hamano","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"205398","messageId":"1356165212-5611-1-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":null,"subject":"[PATCH 0/7] format-patch --reroll-count","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:25Z","receivedAt":"2012-12-22T08:33:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The --reroll-count=$N option, when given a positive integer:\n\n - Adds \" v$N\" to the subject prefix specified.  As the default\n   subject prefix string is \"PATCH\", --reroll-count=2 makes it\n   \"PATCH v2\".\n\n - Prefixes \"v$N-\" to the names used for output files.  The cover\n   letter, whose name is usually 0000-cover-letter.patch, becomes\n   v2-0000-cover-letter.patch when given --reroll-count=2.\n\nThis allows users to use the same --output-directory for multiple\niterations of the same series, without letting the output for a\nnewer round overwrite output files from the earlier rounds.  The\nuser can incorporate materials from earlier rounds to update the\nnewly minted iteration, and use \"send-email v2-*.patch\" to send out\nthe patches belonging to the second iteration easily.\n\nThe early patches of this series are all preparatory clean-ups. I\nthink reopen_stdout() also can be cleaned up, but I'll leave it to\na future reroll.\n\nJunio C Hamano (7):\n  builtin/log.c: drop unused \"numbered\" parameter from\n    make_cover_letter()\n  builtin/log.c: drop redundant \"numbered_files\" parameter from\n    make_cover_letter()\n  builtin/log.c: stop using global patch_suffix\n  get_patch_filename(): simplify function signature\n  get_patch_filename(): drop \"just-numbers\" hack\n  get_patch_filename(): split into two functions\n  format-patch: add --reroll-count=$N option\n\n builtin/log.c | 33 ++++++++++++++++++++++++---------\n log-tree.c    | 52 +++++++++++++++++++++++++++++++---------------------\n log-tree.h    |  4 ++--\n revision.h    |  1 +\n 4 files changed, 58 insertions(+), 32 deletions(-)\n\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205399","messageId":"1356165212-5611-2-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 1/7] builtin/log.c: drop unused \"numbered\" parameter from make_cover_letter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:26Z","receivedAt":"2012-12-22T08:33:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Signed-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 09cf43e..28d9063 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -768,7 +768,7 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n }\n \n static void make_cover_letter(struct rev_info *rev, int use_stdout,\n-\t\t\t      int numbered, int numbered_files,\n+\t\t\t      int numbered_files,\n \t\t\t      struct commit *origin,\n \t\t\t      int nr, struct commit **list, struct commit *head,\n \t\t\t      const char *branch_name,\n@@ -1343,7 +1343,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (cover_letter) {\n \t\tif (thread)\n \t\t\tgen_message_id(&rev, \"cover\");\n-\t\tmake_cover_letter(&rev, use_stdout, numbered, numbered_files,\n+\t\tmake_cover_letter(&rev, use_stdout, numbered_files,\n \t\t\t\t  origin, nr, list, head, branch_name, quiet);\n \t\ttotal++;\n \t\tstart_number--;\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205401","messageId":"1356165212-5611-3-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 2/7] builtin/log.c: drop redundant \"numbered_files\" parameter from make_cover_letter()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:27Z","receivedAt":"2012-12-22T08:33:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Signed-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 28d9063..f1d086e 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -768,7 +768,6 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n }\n \n static void make_cover_letter(struct rev_info *rev, int use_stdout,\n-\t\t\t      int numbered_files,\n \t\t\t      struct commit *origin,\n \t\t\t      int nr, struct commit **list, struct commit *head,\n \t\t\t      const char *branch_name,\n@@ -791,7 +790,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \tcommitter = git_committer_info(0);\n \n \tif (!use_stdout &&\n-\t    reopen_stdout(NULL, numbered_files ? NULL : \"cover-letter\", rev, quiet))\n+\t    reopen_stdout(NULL, rev->numbered_files ? NULL : \"cover-letter\", rev, quiet))\n \t\treturn;\n \n \tlog_write_email_headers(rev, head, &pp.subject, &pp.after_subject,\n@@ -1045,7 +1044,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tint nr = 0, total, i;\n \tint use_stdout = 0;\n \tint start_number = -1;\n-\tint numbered_files = 0;\t\t/* _just_ numbers */\n+\tint just_numbers = 0;\n \tint ignore_if_in_upstream = 0;\n \tint cover_letter = 0;\n \tint boundary_count = 0;\n@@ -1070,7 +1069,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"print patches to standard out\")),\n \t\tOPT_BOOLEAN(0, \"cover-letter\", &cover_letter,\n \t\t\t    N_(\"generate a cover letter\")),\n-\t\tOPT_BOOLEAN(0, \"numbered-files\", &numbered_files,\n+\t\tOPT_BOOLEAN(0, \"numbered-files\", &just_numbers,\n \t\t\t    N_(\"use simple number sequence for output file names\")),\n \t\tOPT_STRING(0, \"suffix\", &fmt_patch_suffix, N_(\"sfx\"),\n \t\t\t    N_(\"use <sfx> instead of '.patch'\")),\n@@ -1338,12 +1337,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tconst char *msgid = clean_message_id(in_reply_to);\n \t\tstring_list_append(rev.ref_message_ids, msgid);\n \t}\n-\trev.numbered_files = numbered_files;\n+\trev.numbered_files = just_numbers;\n \trev.patch_suffix = fmt_patch_suffix;\n \tif (cover_letter) {\n \t\tif (thread)\n \t\t\tgen_message_id(&rev, \"cover\");\n-\t\tmake_cover_letter(&rev, use_stdout, numbered_files,\n+\t\tmake_cover_letter(&rev, use_stdout,\n \t\t\t\t  origin, nr, list, head, branch_name, quiet);\n \t\ttotal++;\n \t\tstart_number--;\n@@ -1390,7 +1389,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t}\n \n \t\tif (!use_stdout &&\n-\t\t    reopen_stdout(numbered_files ? NULL : commit, NULL, &rev, quiet))\n+\t\t    reopen_stdout(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))\n \t\t\tdie(_(\"Failed to create output files\"));\n \t\tshown = log_tree_commit(&rev, commit);\n \t\tfree(commit->buffer);\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205404","messageId":"1356165212-5611-4-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 3/7] builtin/log.c: stop using global patch_suffix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:28Z","receivedAt":"2012-12-22T08:33:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The suffix for the output filename is found in rev->patch_suffix; do\nnot keep using the global that is only used to parse the command\nline and configuration.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex f1d086e..7cf157e 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -673,7 +673,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,\n \t\t\t struct rev_info *rev, int quiet)\n {\n \tstruct strbuf filename = STRBUF_INIT;\n-\tint suffix_len = strlen(fmt_patch_suffix) + 1;\n+\tint suffix_len = strlen(rev->patch_suffix) + 1;\n \n \tif (output_directory) {\n \t\tstrbuf_addstr(&filename, output_directory);\n@@ -684,7 +684,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,\n \t\t\tstrbuf_addch(&filename, '/');\n \t}\n \n-\tget_patch_filename(commit, subject, rev->nr, fmt_patch_suffix, &filename);\n+\tget_patch_filename(commit, subject, rev->nr, rev->patch_suffix, &filename);\n \n \tif (!quiet)\n \t\tfprintf(realstdout, \"%s\\n\", filename.buf + outdir_offset);\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205400","messageId":"1356165212-5611-5-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 4/7] get_patch_filename(): simplify function signature","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:29Z","receivedAt":"2012-12-22T08:33:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Most functions that emit to a strbuf take the strbuf as their first\nparameter; make this function follow suit.\n\nThe serial number of the patch being emitted (nr) and suffix used\nfor patch filename (suffix) are both recorded in rev_info; drop\nthese separate parameters and pass the rev_info directly.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c |  2 +-\n log-tree.c    | 12 ++++++++----\n log-tree.h    |  5 +++--\n 3 files changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 7cf157e..d9946ec 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -684,7 +684,7 @@ static int reopen_stdout(struct commit *commit, const char *subject,\n \t\t\tstrbuf_addch(&filename, '/');\n \t}\n \n-\tget_patch_filename(commit, subject, rev->nr, rev->patch_suffix, &filename);\n+\tget_patch_filename(&filename, commit, subject, rev);\n \n \tif (!quiet)\n \t\tfprintf(realstdout, \"%s\\n\", filename.buf + outdir_offset);\ndiff --git a/log-tree.c b/log-tree.c\nindex c894930..ceed6b6 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -299,9 +299,12 @@ static unsigned int digits_in_number(unsigned int number)\n \treturn result;\n }\n \n-void get_patch_filename(struct commit *commit, const char *subject, int nr,\n-\t\t\tconst char *suffix, struct strbuf *buf)\n+void get_patch_filename(struct strbuf *buf,\n+\t\t\tstruct commit *commit, const char *subject,\n+\t\t\tstruct rev_info *info)\n {\n+\tconst char *suffix = info->patch_suffix;\n+\tint nr = info->nr;\n \tint suffix_len = strlen(suffix) + 1;\n \tint start_len = buf->len;\n \n@@ -387,8 +390,9 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\t\t mime_boundary_leader, opt->mime_boundary);\n \t\textra_headers = subject_buffer;\n \n-\t\tget_patch_filename(opt->numbered_files ? NULL : commit, NULL,\n-\t\t\t\t   opt->nr, opt->patch_suffix, &filename);\n+\t\tget_patch_filename(&filename,\n+\t\t\t\t   opt->numbered_files ? NULL : commit, NULL,\n+\t\t\t\t   opt);\n \t\tsnprintf(buffer, sizeof(buffer) - 1,\n \t\t\t \"\\n--%s%s\\n\"\n \t\t\t \"Content-Type: text/x-patch;\"\ndiff --git a/log-tree.h b/log-tree.h\nindex f5ac238..c6a944a 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -21,7 +21,8 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n void load_ref_decorations(int flags);\n \n #define FORMAT_PATCH_NAME_MAX 64\n-void get_patch_filename(struct commit *commit, const char *subject, int nr,\n-\t\t\tconst char *suffix, struct strbuf *buf);\n+void get_patch_filename(struct strbuf *buf,\n+\t\t\tstruct commit *commit, const char *subject,\n+\t\t\tstruct rev_info *);\n \n #endif\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205405","messageId":"1356165212-5611-6-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 5/7] get_patch_filename(): drop \"just-numbers\" hack","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:30Z","receivedAt":"2012-12-22T08:33:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The function chooses from three operating modes (format using the\nsubject, the commit, or just number) based on NULL-ness of two of\nits parameters, which is an ugly hack for sharing only a bit of\ncode.\n\nSeparate out the \"just numbers\" part out to the callers.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c |  5 ++++-\n log-tree.c    | 29 ++++++++++++++---------------\n 2 files changed, 18 insertions(+), 16 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex d9946ec..3c6f20a 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -684,7 +684,10 @@ static int reopen_stdout(struct commit *commit, const char *subject,\n \t\t\tstrbuf_addch(&filename, '/');\n \t}\n \n-\tget_patch_filename(&filename, commit, subject, rev);\n+\tif (rev->numbered_files)\n+\t\tstrbuf_addf(&filename, \"%d\", rev->nr);\n+\telse\n+\t\tget_patch_filename(&filename, commit, subject, rev);\n \n \tif (!quiet)\n \t\tfprintf(realstdout, \"%s\\n\", filename.buf + outdir_offset);\ndiff --git a/log-tree.c b/log-tree.c\nindex ceed6b6..d9f86ce 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -307,21 +307,18 @@ void get_patch_filename(struct strbuf *buf,\n \tint nr = info->nr;\n \tint suffix_len = strlen(suffix) + 1;\n \tint start_len = buf->len;\n+\tint max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;\n \n-\tstrbuf_addf(buf, commit || subject ? \"%04d-\" : \"%d\", nr);\n-\tif (commit || subject) {\n-\t\tint max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;\n+\tstrbuf_addf(buf, \"%04d-\", nr);\n+\tif (subject)\n+\t\tstrbuf_addstr(buf, subject);\n+\telse if (commit) {\n \t\tstruct pretty_print_context ctx = {0};\n-\n-\t\tif (subject)\n-\t\t\tstrbuf_addstr(buf, subject);\n-\t\telse if (commit)\n-\t\t\tformat_commit_message(commit, \"%f\", buf, &ctx);\n-\n-\t\tif (max_len < buf->len)\n-\t\t\tstrbuf_setlen(buf, max_len);\n-\t\tstrbuf_addstr(buf, suffix);\n+\t\tformat_commit_message(commit, \"%f\", buf, &ctx);\n \t}\n+\tif (max_len < buf->len)\n+\t\tstrbuf_setlen(buf, max_len);\n+\tstrbuf_addstr(buf, suffix);\n }\n \n void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n@@ -390,9 +387,11 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\t\t mime_boundary_leader, opt->mime_boundary);\n \t\textra_headers = subject_buffer;\n \n-\t\tget_patch_filename(&filename,\n-\t\t\t\t   opt->numbered_files ? NULL : commit, NULL,\n-\t\t\t\t   opt);\n+\t\tif (opt->numbered_files)\n+\t\t\tstrbuf_addf(&filename, \"%d\", opt->nr);\n+\t\telse\n+\t\t\tget_patch_filename(&filename, commit, NULL,\n+\t\t\t\t\t   opt);\n \t\tsnprintf(buffer, sizeof(buffer) - 1,\n \t\t\t \"\\n--%s%s\\n\"\n \t\t\t \"Content-Type: text/x-patch;\"\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205403","messageId":"1356165212-5611-7-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 6/7] get_patch_filename(): split into two functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:31Z","receivedAt":"2012-12-22T08:33:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The function switched between two operating modes depending on the\nNULL-ness of its two parameters, as a hacky way to share small part\nof implementation, sacrificing cleanliness of the API.\n\nImplement \"fmt_output_subject()\" function that takes a subject\nstring and gives the name for the output file, and on top of it,\nimplement \"fmt_output_commit()\" function that takes a commit and\ngives the name for the output file.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c |  4 +++-\n log-tree.c    | 41 +++++++++++++++++++++++------------------\n log-tree.h    |  5 ++---\n 3 files changed, 28 insertions(+), 22 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 3c6f20a..8cfb4da 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -686,8 +686,10 @@ static int reopen_stdout(struct commit *commit, const char *subject,\n \n \tif (rev->numbered_files)\n \t\tstrbuf_addf(&filename, \"%d\", rev->nr);\n+\telse if (commit)\n+\t\tfmt_output_commit(&filename, commit, rev);\n \telse\n-\t\tget_patch_filename(&filename, commit, subject, rev);\n+\t\tfmt_output_subject(&filename, subject, rev);\n \n \tif (!quiet)\n \t\tfprintf(realstdout, \"%s\\n\", filename.buf + outdir_offset);\ndiff --git a/log-tree.c b/log-tree.c\nindex d9f86ce..670beae 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -299,26 +299,32 @@ static unsigned int digits_in_number(unsigned int number)\n \treturn result;\n }\n \n-void get_patch_filename(struct strbuf *buf,\n-\t\t\tstruct commit *commit, const char *subject,\n+void fmt_output_subject(struct strbuf *filename,\n+\t\t\tconst char *subject,\n \t\t\tstruct rev_info *info)\n {\n \tconst char *suffix = info->patch_suffix;\n \tint nr = info->nr;\n-\tint suffix_len = strlen(suffix) + 1;\n-\tint start_len = buf->len;\n-\tint max_len = start_len + FORMAT_PATCH_NAME_MAX - suffix_len;\n-\n-\tstrbuf_addf(buf, \"%04d-\", nr);\n-\tif (subject)\n-\t\tstrbuf_addstr(buf, subject);\n-\telse if (commit) {\n-\t\tstruct pretty_print_context ctx = {0};\n-\t\tformat_commit_message(commit, \"%f\", buf, &ctx);\n-\t}\n-\tif (max_len < buf->len)\n-\t\tstrbuf_setlen(buf, max_len);\n-\tstrbuf_addstr(buf, suffix);\n+\tint start_len = filename->len;\n+\tint max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);\n+\n+\tstrbuf_addf(filename, \"%04d-%s\", nr, subject);\n+\n+\tif (max_len < filename->len)\n+\t\tstrbuf_setlen(filename, max_len);\n+\tstrbuf_addstr(filename, suffix);\n+}\n+\n+void fmt_output_commit(struct strbuf *filename,\n+\t\t       struct commit *commit,\n+\t\t       struct rev_info *info)\n+{\n+\tstruct pretty_print_context ctx = {0};\n+\tstruct strbuf subject = STRBUF_INIT;\n+\n+\tformat_commit_message(commit, \"%f\", &subject, &ctx);\n+\tfmt_output_subject(filename, subject.buf, info);\n+\tstrbuf_release(&subject);\n }\n \n void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n@@ -390,8 +396,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n \t\tif (opt->numbered_files)\n \t\t\tstrbuf_addf(&filename, \"%d\", opt->nr);\n \t\telse\n-\t\t\tget_patch_filename(&filename, commit, NULL,\n-\t\t\t\t\t   opt);\n+\t\t\tfmt_output_commit(&filename, commit, opt);\n \t\tsnprintf(buffer, sizeof(buffer) - 1,\n \t\t\t \"\\n--%s%s\\n\"\n \t\t\t \"Content-Type: text/x-patch;\"\ndiff --git a/log-tree.h b/log-tree.h\nindex c6a944a..9140f48 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -21,8 +21,7 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,\n void load_ref_decorations(int flags);\n \n #define FORMAT_PATCH_NAME_MAX 64\n-void get_patch_filename(struct strbuf *buf,\n-\t\t\tstruct commit *commit, const char *subject,\n-\t\t\tstruct rev_info *);\n+void fmt_output_commit(struct strbuf *, struct commit *, struct rev_info *);\n+void fmt_output_subject(struct strbuf *, const char *subject, struct rev_info *);\n \n #endif\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205402","messageId":"1356165212-5611-8-git-send-email-gitster@pobox.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"[PATCH 7/7] format-patch: add --reroll-count=$N option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-22T08:33:32Z","receivedAt":"2012-12-22T08:33:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The --reroll-count=$N option, when given a positive integer:\n\n - Adds \" v$N\" to the subject prefix specified.  As the default\n   subject prefix string is \"PATCH\", --reroll-count=2 makes it\n   \"PATCH v2\".\n\n - Prefixes \"v$N-\" to the names used for output files.  The cover\n   letter, whose name is usually 0000-cover-letter.patch, becomes\n   v2-0000-cover-letter.patch when given --reroll-count=2.\n\nThis allows users to use the same --output-directory for multiple\niterations of the same series, without letting the output for a\nnewer round overwrite output files from the earlier rounds.  The\nuser can incorporate materials from earlier rounds to update the\nnewly minted iteration, and use \"send-email v2-*.patch\" to send out\nthe patches belonging to the second iteration easily.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/log.c | 11 +++++++++++\n log-tree.c    |  2 ++\n revision.h    |  1 +\n 3 files changed, 14 insertions(+)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8cfb4da..e101498 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1061,6 +1061,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tstruct strbuf buf = STRBUF_INIT;\n \tint use_patch_format = 0;\n \tint quiet = 0;\n+\tint reroll_count = -1;\n \tchar *branch_name = NULL;\n \tconst struct option builtin_format_patch_options[] = {\n \t\t{ OPTION_CALLBACK, 'n', \"numbered\", &numbered, NULL,\n@@ -1080,6 +1081,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t    N_(\"use <sfx> instead of '.patch'\")),\n \t\tOPT_INTEGER(0, \"start-number\", &start_number,\n \t\t\t    N_(\"start numbering patches at <n> instead of 1\")),\n+\t\tOPT_INTEGER(0, \"reroll-count\", &reroll_count,\n+\t\t\t    N_(\"mark the series as Nth re-roll\")),\n \t\t{ OPTION_CALLBACK, 0, \"subject-prefix\", &rev, N_(\"prefix\"),\n \t\t\t    N_(\"Use [<prefix>] instead of [PATCH]\"),\n \t\t\t    PARSE_OPT_NONEG, subject_prefix_callback },\n@@ -1152,6 +1155,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN |\n \t\t\t     PARSE_OPT_KEEP_DASHDASH);\n \n+\tif (0 < reroll_count) {\n+\t\tstruct strbuf sprefix = STRBUF_INIT;\n+\t\tstrbuf_addf(&sprefix, \"%s v%d\",\n+\t\t\t    rev.subject_prefix, reroll_count);\n+\t\trev.reroll_count = reroll_count;\n+\t\trev.subject_prefix = strbuf_detach(&sprefix, NULL);\n+\t}\n+\n \tif (do_signoff) {\n \t\tconst char *committer;\n \t\tconst char *endpos;\ndiff --git a/log-tree.c b/log-tree.c\nindex 670beae..5dc126b 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -308,6 +308,8 @@ void fmt_output_subject(struct strbuf *filename,\n \tint start_len = filename->len;\n \tint max_len = start_len + FORMAT_PATCH_NAME_MAX - (strlen(suffix) + 1);\n \n+\tif (0 < info->reroll_count)\n+\t\tstrbuf_addf(filename, \"v%d-\", info->reroll_count);\n \tstrbuf_addf(filename, \"%04d-%s\", nr, subject);\n \n \tif (max_len < filename->len)\ndiff --git a/revision.h b/revision.h\nindex a95bd0b..e4a912a 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -134,6 +134,7 @@ struct rev_info {\n \tconst char\t*mime_boundary;\n \tconst char\t*patch_suffix;\n \tint\t\tnumbered_files;\n+\tint\t\treroll_count;\n \tchar\t\t*message_id;\n \tstruct string_list *ref_message_ids;\n \tconst char\t*add_signoff;\n-- \n1.8.0.6.gd28b5d4.dirty\n"},{"id":"205740","messageId":"CACsJy8D5Ch2W-tfV6+UuyEzxtL_5E3rkffnZc5AO9yrMDJsaXQ@mail.gmail.com","threadId":"32441","inReplyTo":"1356165212-5611-1-git-send-email-gitster@pobox.com","subject":"Re: [PATCH 0/7] format-patch --reroll-count","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-01-01T03:04:36Z","receivedAt":"2013-01-01T03:04:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Dec 22, 2012 at 3:33 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> The --reroll-count=$N option, when given a positive integer:\n>\n>  - Adds \" v$N\" to the subject prefix specified.  As the default\n>    subject prefix string is \"PATCH\", --reroll-count=2 makes it\n>    \"PATCH v2\".\n>\n>  - Prefixes \"v$N-\" to the names used for output files.  The cover\n>    letter, whose name is usually 0000-cover-letter.patch, becomes\n>    v2-0000-cover-letter.patch when given --reroll-count=2.\n\nOn the same subject of format-patch improvements, perhaps we should also:\n\n   - Keep subject line in branch.%s.description too. No point in\n     keeping writing the subject on every reroll.\n\n   - Perhaps an option to save the current tip in reflog with reroll\n     count so one can easily diff between two rerolls.\n-- \nDuy\n"}]}