{"thread":{"id":"33421","subject":"[PATCH v4 0/6] send-email: configuration improvements","startedAt":"2013-04-07T17:46:18Z","lastAt":"2013-04-09T21:48:36Z","messageCount":13,"participants":["Felipe Contreras","Simon Ruderich","Jonathan Nieder","Jakub Narębski","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":6},"messages":[{"id":"213432","messageId":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":null,"subject":"[PATCH v4 0/6] send-email: configuration improvements","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:18Z","receivedAt":"2013-04-07T17:46:18Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nSome comments have been addressed, tests have been added, and a bug fixed.\nAlso, after the reshuffling of code, cleanup possibilities are realized.\n\nFelipe Contreras (6):\n  send-email: make annotate configurable\n  format-patch: improve head calculation for cover-letter\n  format-patch: refactor branch name calculation\n  log: update to OPT_BOOL\n  format-patch: add format.cover-letter configuration\n  format-patch: trivial cleanups\n\n Documentation/config.txt           |   6 ++\n Documentation/git-format-patch.txt |   5 +-\n Documentation/git-send-email.txt   |   5 +-\n builtin/log.c                      | 166 +++++++++++++++++++------------------\n git-send-email.perl                |   7 +-\n t/t4014-format-patch.sh            |  33 ++++++++\n 6 files changed, 134 insertions(+), 88 deletions(-)\n\n-- \n1.8.2\n"},{"id":"213433","messageId":"1365356784-24872-2-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 1/6] send-email: make annotate configurable","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:19Z","receivedAt":"2013-04-07T17:46:19Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Some people always do --annotate, lets not force them to always type\nthat.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/config.txt         | 1 +\n Documentation/git-send-email.txt | 5 +++--\n git-send-email.perl              | 7 ++++---\n 3 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex bbba728..c8e2178 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1994,6 +1994,7 @@ sendemail.<identity>.*::\n \n sendemail.aliasesfile::\n sendemail.aliasfiletype::\n+sendemail.annotate::\n sendemail.bcc::\n sendemail.cc::\n sendemail.cccmd::\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 44a1f7c..2facc18 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -45,8 +45,9 @@ Composing\n ~~~~~~~~~\n \n --annotate::\n-\tReview and edit each patch you're about to send. See the\n-\tCONFIGURATION section for 'sendemail.multiedit'.\n+\tReview and edit each patch you're about to send. Default is the value\n+\tof 'sendemail.annotate'. See the CONFIGURATION section for\n+\t'sendemail.multiedit'.\n \n --bcc=<address>::\n \tSpecify a \"Bcc:\" value for each email. Default is the value of\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex be809e5..e187b12 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -54,7 +54,7 @@ git send-email [options] <file | directory | rev-list options >\n     --[no-]bcc              <str>  * Email Bcc:\n     --subject               <str>  * Email \"Subject:\"\n     --in-reply-to           <str>  * Email \"In-Reply-To:\"\n-    --annotate                     * Review each patch that will be sent in an editor.\n+    --[no-]annotate                * Review each patch that will be sent in an editor.\n     --compose                      * Open an editor for introduction.\n     --compose-encoding      <str>  * Encoding to assume for introduction.\n     --8bit-encoding         <str>  * Encoding to assume 8bit mails if undeclared\n@@ -212,7 +212,8 @@ my %config_bool_settings = (\n     \"signedoffbycc\" => [\\$signed_off_by_cc, undef],\n     \"signedoffcc\" => [\\$signed_off_by_cc, undef],      # Deprecated\n     \"validate\" => [\\$validate, 1],\n-    \"multiedit\" => [\\$multiedit, undef]\n+    \"multiedit\" => [\\$multiedit, undef],\n+    \"annotate\" => [\\$annotate, undef]\n );\n \n my %config_settings = (\n@@ -304,7 +305,7 @@ my $rc = GetOptions(\"h\" => \\$help,\n \t\t    \"smtp-debug:i\" => \\$debug_net_smtp,\n \t\t    \"smtp-domain:s\" => \\$smtp_domain,\n \t\t    \"identity=s\" => \\$identity,\n-\t\t    \"annotate\" => \\$annotate,\n+\t\t    \"annotate!\" => \\$annotate,\n \t\t    \"compose\" => \\$compose,\n \t\t    \"quiet\" => \\$quiet,\n \t\t    \"cc-cmd=s\" => \\$cc_cmd,\n-- \n1.8.2\n"},{"id":"213434","messageId":"1365356784-24872-3-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 2/6] format-patch: improve head calculation for cover-letter","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:20Z","receivedAt":"2013-04-07T17:46:20Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"If we do it after the revision traversal we can be sure that this is\nindeed a commit that will be processed (i.e. not a merge) and it's the\ntop most one (thus removing the NEEDSWORK comment, at least we show the\nsame as 'git diff --stat').\n\nWhile we are at it, since we know there's nothing to generate, exit\nsooner in all cases, like --cover-letter currently does.\n\nAlso, if there's nothing to generate and cover-letter is specified, a\ndifferent code-path might be triggered that is not currently covered in\nthe test-case, so add a test for it.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/log.c           | 22 ++++------------------\n t/t4014-format-patch.sh |  5 +++++\n 2 files changed, 9 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 8f0b2e8..e0c8b6f 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1319,24 +1319,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \trev.show_root_diff = 1;\n \n \tif (cover_letter) {\n-\t\t/*\n-\t\t * NEEDSWORK:randomly pick one positive commit to show\n-\t\t * diffstat; this is often the tip and the command\n-\t\t * happens to do the right thing in most cases, but a\n-\t\t * complex command like \"--cover-letter a b c ^bottom\"\n-\t\t * picks \"c\" and shows diffstat between bottom..c\n-\t\t * which may not match what the series represents at\n-\t\t * all and totally broken.\n-\t\t */\n-\t\tint i;\n-\t\tfor (i = 0; i < rev.pending.nr; i++) {\n-\t\t\tstruct object *o = rev.pending.objects[i].item;\n-\t\t\tif (!(o->flags & UNINTERESTING))\n-\t\t\t\thead = (struct commit *)o;\n-\t\t}\n-\t\t/* There is nothing to show; it is not an error, though. */\n-\t\tif (!head)\n-\t\t\treturn 0;\n \t\tif (!branch_name)\n \t\t\tbranch_name = find_branch_name(&rev);\n \t}\n@@ -1372,6 +1354,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tlist = xrealloc(list, nr * sizeof(list[0]));\n \t\tlist[nr - 1] = commit;\n \t}\n+\tif (nr == 0)\n+\t\t/* nothing to do */\n+\t\treturn 0;\n+\thead = list[0];\n \ttotal = nr;\n \tif (!keep_subject && auto_number && total > 1)\n \t\tnumbered = 1;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 7fa3647..71b35e7 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1021,4 +1021,9 @@ test_expect_success 'cover letter using branch description (6)' '\n \tgrep hello actual >/dev/null\n '\n \n+test_expect_success 'cover letter with nothing' '\n+\tgit format-patch --stdout --cover-letter >actual &&\n+\ttest_line_count = 0 actual\n+'\n+\n test_done\n-- \n1.8.2\n"},{"id":"213436","messageId":"1365356784-24872-4-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 3/6] format-patch: refactor branch name calculation","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:21Z","receivedAt":"2013-04-07T17:46:21Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"By moving the part that relies on rev->pending earlier, where we are\nalready checking the special case where there's only one ref.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/log.c | 33 ++++++++++++++++-----------------\n 1 file changed, 16 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e0c8b6f..cd942ee 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1049,15 +1049,6 @@ static char *find_branch_name(struct rev_info *rev)\n \tif (0 <= positive) {\n \t\tref = rev->cmdline.rev[positive].name;\n \t\ttip_sha1 = rev->cmdline.rev[positive].item->sha1;\n-\t} else if (!rev->cmdline.nr && rev->pending.nr == 1 &&\n-\t\t   !strcmp(rev->pending.objects[0].name, \"HEAD\")) {\n-\t\t/*\n-\t\t * No actual ref from command line, but \"HEAD\" from\n-\t\t * rev->def was added in setup_revisions()\n-\t\t * e.g. format-patch --cover-letter -12\n-\t\t */\n-\t\tref = \"HEAD\";\n-\t\ttip_sha1 = rev->pending.objects[0].item->sha1;\n \t} else {\n \t\treturn NULL;\n \t}\n@@ -1288,28 +1279,36 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t}\n \n \tif (rev.pending.nr == 1) {\n+\t\tint check_head = 0;\n+\n \t\tif (rev.max_count < 0 && !rev.show_root_diff) {\n \t\t\t/*\n \t\t\t * This is traditional behaviour of \"git format-patch\n \t\t\t * origin\" that prepares what the origin side still\n \t\t\t * does not have.\n \t\t\t */\n-\t\t\tunsigned char sha1[20];\n-\t\t\tconst char *ref;\n-\n \t\t\trev.pending.objects[0].item->flags |= UNINTERESTING;\n \t\t\tadd_head_to_pending(&rev);\n-\t\t\tref = resolve_ref_unsafe(\"HEAD\", sha1, 1, NULL);\n-\t\t\tif (ref && !prefixcmp(ref, \"refs/heads/\"))\n-\t\t\t\tbranch_name = xstrdup(ref + strlen(\"refs/heads/\"));\n-\t\t\telse\n-\t\t\t\tbranch_name = xstrdup(\"\"); /* no branch */\n+\t\t\tcheck_head = 1;\n \t\t}\n \t\t/*\n \t\t * Otherwise, it is \"format-patch -22 HEAD\", and/or\n \t\t * \"format-patch --root HEAD\".  The user wants\n \t\t * get_revision() to do the usual traversal.\n \t\t */\n+\n+\t\tif (!strcmp(rev.pending.objects[0].name, \"HEAD\"))\n+\t\t\tcheck_head = 1;\n+\n+\t\tif (check_head) {\n+\t\t\tunsigned char sha1[20];\n+\t\t\tconst char *ref;\n+\t\t\tref = resolve_ref_unsafe(\"HEAD\", sha1, 1, NULL);\n+\t\t\tif (ref && !prefixcmp(ref, \"refs/heads/\"))\n+\t\t\t\tbranch_name = xstrdup(ref + strlen(\"refs/heads/\"));\n+\t\t\telse\n+\t\t\t\tbranch_name = xstrdup(\"\"); /* no branch */\n+\t\t}\n \t}\n \n \t/*\n-- \n1.8.2\n"},{"id":"213437","messageId":"1365356784-24872-5-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 4/6] log: update to OPT_BOOL","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:22Z","receivedAt":"2013-04-07T17:46:22Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"OPT_BOOLEAN is deprecated, and this is what we want.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/log.c | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex cd942ee..488a254 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -99,9 +99,9 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,\n \tint quiet = 0, source = 0, mailmap = 0;\n \n \tconst struct option builtin_log_options[] = {\n-\t\tOPT_BOOLEAN(0, \"quiet\", &quiet, N_(\"suppress diff output\")),\n-\t\tOPT_BOOLEAN(0, \"source\", &source, N_(\"show source\")),\n-\t\tOPT_BOOLEAN(0, \"use-mailmap\", &mailmap, N_(\"Use mail map file\")),\n+\t\tOPT_BOOL(0, \"quiet\", &quiet, N_(\"suppress diff output\")),\n+\t\tOPT_BOOL(0, \"source\", &source, N_(\"show source\")),\n+\t\tOPT_BOOL(0, \"use-mailmap\", &mailmap, N_(\"Use mail map file\")),\n \t\t{ OPTION_CALLBACK, 0, \"decorate\", NULL, NULL, N_(\"decorate options\"),\n \t\t  PARSE_OPT_OPTARG, decorate_callback},\n \t\tOPT_END()\n@@ -1090,12 +1090,12 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_CALLBACK, 'N', \"no-numbered\", &numbered, NULL,\n \t\t\t    N_(\"use [PATCH] even with multiple patches\"),\n \t\t\t    PARSE_OPT_NOARG, no_numbered_callback },\n-\t\tOPT_BOOLEAN('s', \"signoff\", &do_signoff, N_(\"add Signed-off-by:\")),\n-\t\tOPT_BOOLEAN(0, \"stdout\", &use_stdout,\n+\t\tOPT_BOOL('s', \"signoff\", &do_signoff, N_(\"add Signed-off-by:\")),\n+\t\tOPT_BOOL(0, \"stdout\", &use_stdout,\n \t\t\t    N_(\"print patches to standard out\")),\n-\t\tOPT_BOOLEAN(0, \"cover-letter\", &cover_letter,\n+\t\tOPT_BOOL(0, \"cover-letter\", &cover_letter,\n \t\t\t    N_(\"generate a cover letter\")),\n-\t\tOPT_BOOLEAN(0, \"numbered-files\", &just_numbers,\n+\t\tOPT_BOOL(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-- \n1.8.2\n"},{"id":"213439","messageId":"1365356784-24872-6-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 5/6] format-patch: add format.cover-letter configuration","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:23Z","receivedAt":"2013-04-07T17:46:23Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Also, add a new option: 'auto', so if there's more than one patch, the\ncover letter is generated, otherwise it's not.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n Documentation/config.txt           |  5 +++++\n Documentation/git-format-patch.txt |  5 +++--\n builtin/log.c                      | 32 ++++++++++++++++++++++++++------\n t/t4014-format-patch.sh            | 28 ++++++++++++++++++++++++++++\n 4 files changed, 62 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex c8e2178..670094f 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1092,6 +1092,11 @@ format.signoff::\n     the rights to submit this work under the same open source license.\n     Please see the 'SubmittingPatches' document for further discussion.\n \n+format.coverLetter::\n+\tA boolean that controls whether to generate a cover-letter when\n+\tformat-patch is invoked, but in addition can be set to \"auto\", to\n+\tgenerate a cover-letter only when there's more than one patch.\n+\n filter.<driver>.clean::\n \tThe command which is used to convert the content of a worktree\n \tfile to a blob upon checkin.  See linkgit:gitattributes[5] for\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 3a62f50..3911877 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -20,7 +20,7 @@ SYNOPSIS\n \t\t   [--ignore-if-in-upstream]\n \t\t   [--subject-prefix=Subject-Prefix] [(--reroll-count|-v) <n>]\n \t\t   [--to=<email>] [--cc=<email>]\n-\t\t   [--cover-letter] [--quiet] [--notes[=<ref>]]\n+\t\t   [--[no-]cover-letter] [--quiet] [--notes[=<ref>]]\n \t\t   [<common diff options>]\n \t\t   [ <since> | <revision range> ]\n \n@@ -195,7 +195,7 @@ will want to ensure that threading is disabled for `git send-email`.\n \t`Cc:`, and custom) headers added so far from config or command\n \tline.\n \n---cover-letter::\n+--[no-]cover-letter::\n \tIn addition to the patches, generate a cover letter file\n \tcontaining the shortlog and the overall diffstat.  You can\n \tfill in a description in the file before sending it out.\n@@ -260,6 +260,7 @@ attachments, and sign off patches with configuration variables.\n \tcc = <email>\n \tattach [ = mime-boundary-string ]\n \tsignoff = true\n+\tcoverletter = auto\n ------------\n \n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex 488a254..cf09a81 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -619,6 +619,14 @@ static void add_header(const char *value)\n static int thread;\n static int do_signoff;\n static const char *signature = git_version_string;\n+static int config_cover_letter;\n+\n+enum {\n+\tCOVER_UNSET,\n+\tCOVER_OFF,\n+\tCOVER_ON,\n+\tCOVER_AUTO\n+};\n \n static int git_format_config(const char *var, const char *value, void *cb)\n {\n@@ -680,6 +688,14 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"format.signature\"))\n \t\treturn git_config_string(&signature, var, value);\n+\tif (!strcmp(var, \"format.coverletter\")) {\n+\t\tif (value && !strcasecmp(value, \"auto\")) {\n+\t\t\tconfig_cover_letter = COVER_AUTO;\n+\t\t\treturn 0;\n+\t\t}\n+\t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n+\t\treturn 0;\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1071,7 +1087,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tint start_number = -1;\n \tint just_numbers = 0;\n \tint ignore_if_in_upstream = 0;\n-\tint cover_letter = 0;\n+\tint cover_letter = -1;\n \tint boundary_count = 0;\n \tint no_binary_diff = 0;\n \tstruct commit *origin = NULL, *head = NULL;\n@@ -1317,11 +1333,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t */\n \trev.show_root_diff = 1;\n \n-\tif (cover_letter) {\n-\t\tif (!branch_name)\n-\t\t\tbranch_name = find_branch_name(&rev);\n-\t}\n-\n \tif (ignore_if_in_upstream) {\n \t\t/* Don't say anything if head and upstream are the same. */\n \t\tif (rev.pending.nr == 2) {\n@@ -1362,6 +1373,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tnumbered = 1;\n \tif (numbered)\n \t\trev.total = total + start_number - 1;\n+\tif (cover_letter == -1) {\n+\t\tif (config_cover_letter == COVER_AUTO)\n+\t\t\tcover_letter = (total > 1);\n+\t\telse\n+\t\t\tcover_letter = (config_cover_letter == COVER_ON);\n+\t}\n+\n \tif (in_reply_to || thread || cover_letter)\n \t\trev.ref_message_ids = xcalloc(1, sizeof(struct string_list));\n \tif (in_reply_to) {\n@@ -1373,6 +1391,8 @@ 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\tif (!branch_name)\n+\t\t\tbranch_name = find_branch_name(&rev);\n \t\tmake_cover_letter(&rev, use_stdout,\n \t\t\t\t  origin, nr, list, head, branch_name, quiet);\n \t\ttotal++;\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 71b35e7..01c2a47 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1026,4 +1026,32 @@ test_expect_success 'cover letter with nothing' '\n \ttest_line_count = 0 actual\n '\n \n+test_expect_success 'cover letter auto' '\n+\tmkdir -p tmp &&\n+\ttest_when_finished \"rm -rf tmp;\n+\t\tgit config --unset format.coverletter\" &&\n+\n+\tgit config format.coverletter auto &&\n+\tgit format-patch -o tmp -1 >list &&\n+\ttest_line_count = 1 list &&\n+\tgit format-patch -o tmp -2 >list &&\n+\ttest_line_count = 3 list\n+'\n+\n+test_expect_success 'cover letter auto user override' '\n+\tmkdir -p tmp &&\n+\ttest_when_finished \"rm -rf tmp;\n+\t\tgit config --unset format.coverletter\" &&\n+\n+\tgit config format.coverletter auto &&\n+\tgit format-patch -o tmp --cover-letter -1 >list &&\n+\ttest_line_count = 2 list &&\n+\tgit format-patch -o tmp --cover-letter -2 >list &&\n+\ttest_line_count = 3 list &&\n+\tgit format-patch -o tmp --no-cover-letter -1 >list &&\n+\ttest_line_count = 1 list &&\n+\tgit format-patch -o tmp --no-cover-letter -2 >list &&\n+\ttest_line_count = 2 list\n+'\n+\n test_done\n-- \n1.8.2\n"},{"id":"213438","messageId":"1365356784-24872-7-git-send-email-felipe.contreras@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v4 6/6] format-patch: trivial cleanups","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-04-07T17:46:24Z","receivedAt":"2013-04-07T17:46:24Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Now that the cover-letter code has been shuffled, we can do some\ncleanups.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n builtin/log.c | 71 +++++++++++++++++++++++++++++------------------------------\n 1 file changed, 35 insertions(+), 36 deletions(-)\n\ndiff --git a/builtin/log.c b/builtin/log.c\nindex cf09a81..bbfe6bc 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -807,9 +807,37 @@ static void add_branch_description(struct strbuf *buf, const char *branch_name)\n \t}\n }\n \n+static char *find_branch_name(struct rev_info *rev)\n+{\n+\tint i, positive = -1;\n+\tunsigned char branch_sha1[20];\n+\tconst unsigned char *tip_sha1;\n+\tconst char *ref;\n+\tchar *full_ref, *branch = NULL;\n+\n+\tfor (i = 0; i < rev->cmdline.nr; i++) {\n+\t\tif (rev->cmdline.rev[i].flags & UNINTERESTING)\n+\t\t\tcontinue;\n+\t\tif (positive < 0)\n+\t\t\tpositive = i;\n+\t\telse\n+\t\t\treturn NULL;\n+\t}\n+\tif (positive < 0)\n+\t\treturn NULL;\n+\tref = rev->cmdline.rev[positive].name;\n+\ttip_sha1 = rev->cmdline.rev[positive].item->sha1;\n+\tif (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&\n+\t    !prefixcmp(full_ref, \"refs/heads/\") &&\n+\t    !hashcmp(tip_sha1, branch_sha1))\n+\t\tbranch = xstrdup(full_ref + strlen(\"refs/heads/\"));\n+\tfree(full_ref);\n+\treturn branch;\n+}\n+\n static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \t\t\t      struct commit *origin,\n-\t\t\t      int nr, struct commit **list, struct commit *head,\n+\t\t\t      int nr, struct commit **list,\n \t\t\t      const char *branch_name,\n \t\t\t      int quiet)\n {\n@@ -823,6 +851,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \tstruct diff_options opts;\n \tint need_8bit_cte = 0;\n \tstruct pretty_print_context pp = {0};\n+\tstruct commit *head = list[0];\n \n \tif (rev->commit_format != CMIT_FMT_EMAIL)\n \t\tdie(_(\"Cover letter needs email format\"));\n@@ -840,6 +869,9 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,\n \t\tif (has_non_ascii(list[i]->buffer))\n \t\t\tneed_8bit_cte = 1;\n \n+\tif (!branch_name)\n+\t\tbranch_name = find_branch_name(rev);\n+\n \tmsg = body;\n \tpp.fmt = CMIT_FMT_EMAIL;\n \tpp.date_mode = DATE_RFC2822;\n@@ -1046,36 +1078,6 @@ static int cc_callback(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n-static char *find_branch_name(struct rev_info *rev)\n-{\n-\tint i, positive = -1;\n-\tunsigned char branch_sha1[20];\n-\tconst unsigned char *tip_sha1;\n-\tconst char *ref;\n-\tchar *full_ref, *branch = NULL;\n-\n-\tfor (i = 0; i < rev->cmdline.nr; i++) {\n-\t\tif (rev->cmdline.rev[i].flags & UNINTERESTING)\n-\t\t\tcontinue;\n-\t\tif (positive < 0)\n-\t\t\tpositive = i;\n-\t\telse\n-\t\t\treturn NULL;\n-\t}\n-\tif (0 <= positive) {\n-\t\tref = rev->cmdline.rev[positive].name;\n-\t\ttip_sha1 = rev->cmdline.rev[positive].item->sha1;\n-\t} else {\n-\t\treturn NULL;\n-\t}\n-\tif (dwim_ref(ref, strlen(ref), branch_sha1, &full_ref) &&\n-\t    !prefixcmp(full_ref, \"refs/heads/\") &&\n-\t    !hashcmp(tip_sha1, branch_sha1))\n-\t\tbranch = xstrdup(full_ref + strlen(\"refs/heads/\"));\n-\tfree(full_ref);\n-\treturn branch;\n-}\n-\n int cmd_format_patch(int argc, const char **argv, const char *prefix)\n {\n \tstruct commit *commit;\n@@ -1090,7 +1092,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tint cover_letter = -1;\n \tint boundary_count = 0;\n \tint no_binary_diff = 0;\n-\tstruct commit *origin = NULL, *head = NULL;\n+\tstruct commit *origin = NULL;\n \tconst char *in_reply_to = NULL;\n \tstruct patch_ids ids;\n \tchar *add_signoff = NULL;\n@@ -1367,7 +1369,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (nr == 0)\n \t\t/* nothing to do */\n \t\treturn 0;\n-\thead = list[0];\n \ttotal = nr;\n \tif (!keep_subject && auto_number && total > 1)\n \t\tnumbered = 1;\n@@ -1391,10 +1392,8 @@ 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\tif (!branch_name)\n-\t\t\tbranch_name = find_branch_name(&rev);\n \t\tmake_cover_letter(&rev, use_stdout,\n-\t\t\t\t  origin, nr, list, head, branch_name, quiet);\n+\t\t\t\t  origin, nr, list, branch_name, quiet);\n \t\ttotal++;\n \t\tstart_number--;\n \t}\n-- \n1.8.2\n"},{"id":"213464","messageId":"20130407193415.GB13708@ruderich.org","threadId":"33421","inReplyTo":"1365356784-24872-6-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v4 5/6] format-patch: add format.cover-letter configuration","fromName":"Simon Ruderich","fromEmail":"simon@ruderich.org","sentAt":"2013-04-07T19:34:16Z","receivedAt":"2013-04-07T19:34:16Z","isPatch":true,"sender":{"key":"simon@ruderich.org","avatar":"https://avatars.githubusercontent.com/u/390994?v=4"},"body":"On Sun, Apr 07, 2013 at 12:46:23PM -0500, Felipe Contreras wrote:\n> [snip]\n>\n> +test_expect_success 'cover letter auto' '\n> +\tmkdir -p tmp &&\n> +\ttest_when_finished \"rm -rf tmp;\n> +\t\tgit config --unset format.coverletter\" &&\n> +\n> +\tgit config format.coverletter auto &&\n\n    test_config format.coverletter auto &&\n\ntakes automatically care of the git config --unset cleanup.\n\nI'm not sure if it's better to use test_when_finished with rm or\njust && rm -rf tmp at the end of the test in case someone wants\nto look at the output.\n\nRegards\nSimon\n-- \n+ privacy is necessary\n+ using gnupg http://gnupg.org\n+ public key id: 0x92FEFDB7E44C32F9\n"},{"id":"213477","messageId":"20130407223200.GF19857@elie.Belkin","threadId":"33421","inReplyTo":"20130407193415.GB13708@ruderich.org","subject":"Re: [PATCH v4 5/6] format-patch: add format.cover-letter configuration","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2013-04-07T22:32:00Z","receivedAt":"2013-04-07T22:32:00Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nSimon Ruderich wrote:\n> On Sun, Apr 07, 2013 at 12:46:23PM -0500, Felipe Contreras wrote:\n\n>> +test_expect_success 'cover letter auto' '\n>> +\tmkdir -p tmp &&\n>> +\ttest_when_finished \"rm -rf tmp;\n[...]\n> I'm not sure if it's better to use test_when_finished with rm or\n> just && rm -rf tmp at the end of the test in case someone wants\n> to look at the output.\n\ntest_when_finished is better here, since it means later tests can\nrun and provide useful information about how bad a regression is.\nCleanup commands requested using test_when_finished are not run when a\ntest being run with --immediate fails, so you can still inspect output\nafter a failed test.\n\nThanks and hope that helps,\nJonathan\n"},{"id":"213656","messageId":"20130409131802.GA25673@ruderich.org","threadId":"33421","inReplyTo":"20130407223200.GF19857@elie.Belkin","subject":"[PATCH] t/README: --immediate skips cleanup commands for failed tests","fromName":"Simon Ruderich","fromEmail":"simon@ruderich.org","sentAt":"2013-04-09T13:18:02Z","receivedAt":"2013-04-09T13:18:02Z","isPatch":true,"sender":{"key":"simon@ruderich.org","avatar":"https://avatars.githubusercontent.com/u/390994?v=4"},"body":"On Sun, Apr 07, 2013 at 03:32:00PM -0700, Jonathan Nieder wrote:\n>> I'm not sure if it's better to use test_when_finished with rm or\n>> just && rm -rf tmp at the end of the test in case someone wants\n>> to look at the output.\n>\n> test_when_finished is better here, since it means later tests can\n> run and provide useful information about how bad a regression is.\n> Cleanup commands requested using test_when_finished are not run when a\n> test being run with --immediate fails, so you can still inspect output\n> after a failed test.\n\nHello Jonathan,\n\nThanks for the explanation.\n\nI couldn't find this documented in t/README, the following patch\nadds it.\n\n-- 8< --\nSubject: [PATCH] t/README: --immediate skips cleanup commands for failed tests\n\n---\n t/README | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/t/README b/t/README\nindex 9b41fe7..e5e7d37 100644\n--- a/t/README\n+++ b/t/README\n@@ -86,7 +86,8 @@ appropriately before running \"make\".\n \n --immediate::\n \tThis causes the test to immediately exit upon the first\n-\tfailed test.\n+\tfailed test. Cleanup commands requested with\n+\ttest_when_finished are not executed if the test failed.\n \n --long-tests::\n \tThis causes additional long-running tests to be run (where\n-- \n1.8.2.481.g0d034d4\n\n-- 8< --\n\nRegards\nSimon\n-- \n+ privacy is necessary\n+ using gnupg http://gnupg.org\n+ public key id: 0x92FEFDB7E44C32F9\n"},{"id":"213658","messageId":"51641CE8.4000704@gmail.com","threadId":"33421","inReplyTo":"1365356784-24872-2-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v4 1/6] send-email: make annotate configurable","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2013-04-09T13:51:36Z","receivedAt":"2013-04-09T13:51:36Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 07.04.2013 19:46, Felipe Contreras pisze:\n> @@ -212,7 +212,8 @@ my %config_bool_settings = (\n>      \"signedoffbycc\" => [\\$signed_off_by_cc, undef],\n>      \"signedoffcc\" => [\\$signed_off_by_cc, undef],      # Deprecated\n>      \"validate\" => [\\$validate, 1],\n> -    \"multiedit\" => [\\$multiedit, undef]\n> +    \"multiedit\" => [\\$multiedit, undef],\n> +    \"annotate\" => [\\$annotate, undef]\n>  );\n\nWhy not leave hanging \",\" to make it easier on future changes,\ni.e.:\n\n  -    \"multiedit\" => [\\$multiedit, undef]\n  +    \"multiedit\" => [\\$multiedit, undef],\n  +    \"annotate\" => [\\$annotate, undef],\n\n-- \nJakub Narębski\n"},{"id":"213705","messageId":"7vli8rqztj.fsf@alter.siamese.dyndns.org","threadId":"33421","inReplyTo":"20130409131802.GA25673@ruderich.org","subject":"Re: [PATCH] t/README: --immediate skips cleanup commands for failed tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-04-09T19:16:56Z","receivedAt":"2013-04-09T19:16:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Simon Ruderich <simon@ruderich.org> writes:\n\n> On Sun, Apr 07, 2013 at 03:32:00PM -0700, Jonathan Nieder wrote:\n>>> I'm not sure if it's better to use test_when_finished with rm or\n>>> just && rm -rf tmp at the end of the test in case someone wants\n>>> to look at the output.\n>>\n>> test_when_finished is better here, since it means later tests can\n>> run and provide useful information about how bad a regression is.\n>> Cleanup commands requested using test_when_finished are not run when a\n>> test being run with --immediate fails, so you can still inspect output\n>> after a failed test.\n>\n> Hello Jonathan,\n>\n> Thanks for the explanation.\n>\n> I couldn't find this documented in t/README, the following patch\n> adds it.\n>\n> -- 8< --\n> Subject: [PATCH] t/README: --immediate skips cleanup commands for failed tests\n>\n> ---\n\nSign-off?\n\n>  t/README | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/README b/t/README\n> index 9b41fe7..e5e7d37 100644\n> --- a/t/README\n> +++ b/t/README\n> @@ -86,7 +86,8 @@ appropriately before running \"make\".\n>  \n>  --immediate::\n>  \tThis causes the test to immediately exit upon the first\n> -\tfailed test.\n> +\tfailed test. Cleanup commands requested with\n> +\ttest_when_finished are not executed if the test failed.\n\nPerhaps adding \"... to keep the state for inspection by the tester\nto diagnose the bug\" or something is in order?\n\n>  \n>  --long-tests::\n>  \tThis causes additional long-running tests to be run (where\n> -- \n> 1.8.2.481.g0d034d4\n>\n> -- 8< --\n>\n> Regards\n> Simon\n"},{"id":"213725","messageId":"20130409214836.GA29630@ruderich.org","threadId":"33421","inReplyTo":"7vli8rqztj.fsf@alter.siamese.dyndns.org","subject":"[PATCH v2] t/README: --immediate skips cleanup commands for failed tests","fromName":"Simon Ruderich","fromEmail":"simon@ruderich.org","sentAt":"2013-04-09T21:48:36Z","receivedAt":"2013-04-09T21:48:36Z","isPatch":true,"sender":{"key":"simon@ruderich.org","avatar":"https://avatars.githubusercontent.com/u/390994?v=4"},"body":"Signed-off-by: Simon Ruderich <simon@ruderich.org>\n---\nOn Tue, Apr 09, 2013 at 12:16:56PM -0700, Junio C Hamano wrote:\n> Sign-off?\n\nSorry, forgot it.\n\n> Perhaps adding \"... to keep the state for inspection by the tester\n> to diagnose the bug\" or something is in order?\n\nGood idea.\n\nRevised patch is attached.\n\nRegards\nSimon\n\n t/README | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/t/README b/t/README\nindex 9b41fe7..e6c060e 100644\n--- a/t/README\n+++ b/t/README\n@@ -86,7 +86,10 @@ appropriately before running \"make\".\n \n --immediate::\n \tThis causes the test to immediately exit upon the first\n-\tfailed test.\n+\tfailed test. Cleanup commands requested with\n+\ttest_when_finished are not executed if the test failed to\n+\tkeep the state for inspection by the tester to diagnose\n+\tthe bug.\n \n --long-tests::\n \tThis causes additional long-running tests to be run (where\n-- \n1.8.2.481.g0d034d4\n\n-- \n+ privacy is necessary\n+ using gnupg http://gnupg.org\n+ public key id: 0x92FEFDB7E44C32F9\n"}]}