{"thread":{"id":"39679","subject":"[PATCH v2] format-patch: introduce format.outputDirectory configuration","startedAt":"2015-06-19T18:28:39Z","lastAt":"2016-01-13T18:27:19Z","messageCount":14,"participants":["Alexander Kuleshov","Eric Sunshine","Junio C Hamano","Stephen P. Smith"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"264353","messageId":"1434738519-28093-1-git-send-email-kuleshovmail@gmail.com","threadId":"39679","inReplyTo":null,"subject":"[PATCH v2] format-patch: introduce format.outputDirectory configuration","fromName":"Alexander Kuleshov","fromEmail":"kuleshovmail@gmail.com","sentAt":"2015-06-19T18:28:39Z","receivedAt":"2015-06-19T18:28:39Z","isPatch":true,"sender":{"key":"kuleshovmail@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2699235?v=4"},"body":"We can pass -o/--output-directory to the format-patch command to\nstore patches not in the working directory. This patch introduces\nformat.outputDirectory configuration option for same purpose.\n\nThe case of usage of this configuration option can be convinience\nto not pass everytime -o/--output-directory if an user has pattern\nto store all patches in the /patches directory for example.\n\nThe format.outputDirectory has lower priority than command line\noption, so if user will set format.outputDirectory and pass the\ncommand line option, a result will be stored in a directory that\npassed to command line option.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n---\n Documentation/config.txt           |  4 ++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      |  8 ++++++++\n t/t4014-format-patch.sh            | 18 ++++++++++++++++++\n 4 files changed, 35 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex e159fe5..4f991b6 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1262,6 +1262,10 @@ format.coverLetter::\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+format.outputDirectory::\n+\tSet a custom directory to store the resulting files instead of the\n+\tcurrent working directory.\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 0dac4e9..38ddd76 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -57,7 +57,11 @@ The names of the output files are printed to standard\n output, unless the `--stdout` option is specified.\n \n If `-o` is specified, output files are created in <dir>.  Otherwise\n-they are created in the current working directory.\n+they are created in the current working directory. The default path\n+can be set with the seting 'format.outputDirectory' configuration option.\n+If `-o` is specified and 'format.outputDirectory' is set, output files\n+will be stored in a <dir> that passed to `-o`. When 'format.outputDirectory'\n+is set to get default behaviour back is to pass './' to the `-o`.\n \n By default, the subject of a single patch is \"[PATCH] \" followed by\n the concatenation of lines from the commit message up to the first blank\ndiff --git a/builtin/log.c b/builtin/log.c\nindex 78b3e2c..fc26360 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -688,6 +688,8 @@ enum {\n \tCOVER_AUTO\n };\n \n+static const char *config_output_directory = NULL;\n+\n static int git_format_config(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(var, \"format.headers\")) {\n@@ -758,6 +760,9 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.outputdirectory\")) {\n+\t\treturn git_config_string(&config_output_directory, var, value);\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1368,6 +1373,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\n \n+\tif (!output_directory && !use_stdout)\n+\t\toutput_directory = config_output_directory;\n+\n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n \telse\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 890db11..613e2cc 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -40,6 +40,24 @@ test_expect_success setup '\n \n '\n \n+test_expect_success \"format-patch format.outputDirectory option\" '\n+\tgit config format.outputDirectory \"patches/\" &&\n+\tgit format-patch master..side &&\n+\tcnt=$(ls | wc -l) &&\n+\ttest $cnt = 3 &&\n+\ttest_config format.outputDirectory \"patches/\" &&\n+\tgit config --unset format.outputDirectory\n+'\n+\n+test_expect_success \"format-patch format.outputDirectory overwritten with -o\" '\n+\trm -rf \"patches\" &&\n+\tgit config format.outputDirectory \"patches/\" &&\n+\tgit format-patch master..side -o \".\" &&\n+\ttest_must_fail ls patches/ &&\n+\ttest_config format.outputDirectory \"patches/\" &&\n+\tgit config --unset format.outputDirectory\n+'\n+\n test_expect_success \"format-patch --ignore-if-in-upstream\" '\n \n \tgit format-patch --stdout master..side >patch0 &&\n-- \n2.4.4.727.g5c3049e.dirty\n"},{"id":"264372","messageId":"CAPig+cTOG7QP25TyJbbm70NBXN6Z0nZPJyjxFp1y147WQmKEDg@mail.gmail.com","threadId":"39679","inReplyTo":"1434738519-28093-1-git-send-email-kuleshovmail@gmail.com","subject":"Re: [PATCH v2] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-06-19T20:34:47Z","receivedAt":"2015-06-19T20:34:47Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Jun 19, 2015 at 2:28 PM, Alexander Kuleshov\n<kuleshovmail@gmail.com> wrote:\n> We can pass -o/--output-directory to the format-patch command to\n> store patches not in the working directory. This patch introduces\n> format.outputDirectory configuration option for same purpose.\n>\n> The case of usage of this configuration option can be convinience\n\ns/convinience/convenience/\n\n> to not pass everytime -o/--output-directory if an user has pattern\n\ns/everytime/every time/\n\n> to store all patches in the /patches directory for example.\n>\n> The format.outputDirectory has lower priority than command line\n> option, so if user will set format.outputDirectory and pass the\n> command line option, a result will be stored in a directory that\n> passed to command line option.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> ---\n> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> index 0dac4e9..38ddd76 100644\n> --- a/Documentation/git-format-patch.txt\n> +++ b/Documentation/git-format-patch.txt\n> @@ -57,7 +57,11 @@ The names of the output files are printed to standard\n>  output, unless the `--stdout` option is specified.\n>\n>  If `-o` is specified, output files are created in <dir>.  Otherwise\n> -they are created in the current working directory.\n> +they are created in the current working directory. The default path\n> +can be set with the seting 'format.outputDirectory' configuration option.\n\ns/seting/setting/ or s/seting//\n\n> +If `-o` is specified and 'format.outputDirectory' is set, output files\n> +will be stored in a <dir> that passed to `-o`. When 'format.outputDirectory'\n> +is set to get default behaviour back is to pass './' to the `-o`.\n\ns/set/set,/\n\n>  By default, the subject of a single patch is \"[PATCH] \" followed by\n>  the concatenation of lines from the commit message up to the first blank\n> diff --git a/builtin/log.c b/builtin/log.c\n> index 78b3e2c..fc26360 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -688,6 +688,8 @@ enum {\n>         COVER_AUTO\n>  };\n>\n> +static const char *config_output_directory = NULL;\n> +\n>  static int git_format_config(const char *var, const char *value, void *cb)\n>  {\n>         if (!strcmp(var, \"format.headers\")) {\n> @@ -758,6 +760,9 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>                 config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n>                 return 0;\n>         }\n> +       if (!strcmp(var, \"format.outputdirectory\")) {\n> +               return git_config_string(&config_output_directory, var, value);\n> +       }\n\nStyle: Unnecessary braces.\n\n>         return git_log_config(var, value, cb);\n>  }\n> @@ -1368,6 +1373,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>         if (rev.show_notes)\n>                 init_display_notes(&rev.notes_opt);\n>\n> +       if (!output_directory && !use_stdout)\n> +               output_directory = config_output_directory;\n> +\n>         if (!use_stdout)\n>                 output_directory = set_outdir(prefix, output_directory);\n>         else\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index 890db11..613e2cc 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -40,6 +40,24 @@ test_expect_success setup '\n>\n>  '\n>\n> +test_expect_success \"format-patch format.outputDirectory option\" '\n> +       git config format.outputDirectory \"patches/\" &&\n\nIf you're using test_config (which you do below), then drop the above\nline and replace it with the test_config line.\n\n> +       git format-patch master..side &&\n> +       cnt=$(ls | wc -l) &&\n> +       test $cnt = 3 &&\n> +       test_config format.outputDirectory \"patches/\" &&\n> +       git config --unset format.outputDirectory\n\nMove the test_config line to the top of the test and get rid of the\n'git config --unset' line since test_config will unset the\nconfiguration automatically.\n\n> +'\n> +\n> +test_expect_success \"format-patch format.outputDirectory overwritten with -o\" '\n> +       rm -rf \"patches\" &&\n> +       git config format.outputDirectory \"patches/\" &&\n\nDitto: Place test_config line here and get rid of above line.\n\n> +       git format-patch master..side -o \".\" &&\n> +       test_must_fail ls patches/ &&\n\nDon't use test_must_fail for non-git commands. Instead, use '!'.\nHowever, in this case, using:\n\n    test_path_is_missing patches &&\n\nwould make the intent more clear.\n\n> +       test_config format.outputDirectory \"patches/\" &&\n> +       git config --unset format.outputDirectory\n\nDitto: Move test_config higher and drop 'git config --unset'.\n\n> +'\n> +\n>  test_expect_success \"format-patch --ignore-if-in-upstream\" '\n>\n>         git format-patch --stdout master..side >patch0 &&\n> --\n> 2.4.4.727.g5c3049e.dirty\n"},{"id":"270447","messageId":"xmqqk2rj8kf5.fsf@gitster.mtv.corp.google.com","threadId":"39679","inReplyTo":"CAPig+cTOG7QP25TyJbbm70NBXN6Z0nZPJyjxFp1y147WQmKEDg@mail.gmail.com","subject":"Re: [PATCH v2] format-patch: introduce format.outputDirectory configuration","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-21T22:41:34Z","receivedAt":"2015-09-21T22:41:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n> On Fri, Jun 19, 2015 at 2:28 PM, Alexander Kuleshov\n> <kuleshovmail@gmail.com> wrote:\n>> We can pass -o/--output-directory to the format-patch command to\n>> store patches not in the working directory. This patch introduces\n>> format.outputDirectory configuration option for same purpose.\n>>\n>> The case of usage of this configuration option can be convinience\n>\n> s/convinience/convenience/\n>\n>> to not pass everytime -o/--output-directory if an user has pattern\n>\n> s/everytime/every time/\n>\n>> to store all patches in the /patches directory for example.\n>>\n>> The format.outputDirectory has lower priority than command line\n>> option, so if user will set format.outputDirectory and pass the\n>> command line option, a result will be stored in a directory that\n>> passed to command line option.\n>>\n>> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n>> ---\n\nLooks like there were mostly editorial niggles and no fundamental\nflaws in the design of the patch; it is somewhat a shame to make all\nthe efforts go to waste.  Will we be seeing an update soon?\n\nWe are deep in the pre-release feature freeze, so unless you are\nparticipating in regression fixes it is a good time to plan for the\nnext cycle.\n\nThanks.\n\n>> +static const char *config_output_directory = NULL;\n\ns/ = NULL;/;/ (do rely on BSS clearing the static variables).\n"},{"id":"270458","messageId":"CAPig+cQsfTz7UzVcB1D8iu5on0o7E9nOv=WtzrR-GBmm=cdEpw@mail.gmail.com","threadId":"39679","inReplyTo":"xmqqk2rj8kf5.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2015-09-22T00:05:00Z","receivedAt":"2015-09-22T00:05:00Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Sep 21, 2015 at 6:41 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Eric Sunshine <sunshine@sunshineco.com> writes:\n>> On Fri, Jun 19, 2015 at 2:28 PM, Alexander Kuleshov\n>> <kuleshovmail@gmail.com> wrote:\n>>> We can pass -o/--output-directory to the format-patch command to\n>>> store patches not in the working directory. This patch introduces\n>>> format.outputDirectory configuration option for same purpose.\n>>>\n>>> The case of usage of this configuration option can be convinience\n>>\n>> s/convinience/convenience/\n>>\n>>> to not pass everytime -o/--output-directory if an user has pattern\n>>\n>> s/everytime/every time/\n>>\n>>> to store all patches in the /patches directory for example.\n>>>\n>>> The format.outputDirectory has lower priority than command line\n>>> option, so if user will set format.outputDirectory and pass the\n>>> command line option, a result will be stored in a directory that\n>>> passed to command line option.\n>>>\n>>> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n>>> ---\n>\n> Looks like there were mostly editorial niggles and no fundamental\n> flaws in the design of the patch; it is somewhat a shame to make all\n> the efforts go to waste.  Will we be seeing an update soon?\n\nLooking at the new test a bit more closely...\n\n    test_expect_success \"format-patch format.outputDirectory option\" '\n        git config format.outputDirectory \"patches/\" &&\n        git format-patch master..side &&\n        cnt=$(ls | wc -l) &&\n        test $cnt = 3 &&\n        test_config format.outputDirectory \"patches/\" &&\n        git config --unset format.outputDirectory\n    '\n\nI'm wondering what it's really testing. I presume that it wanted to\ncount the number of files in the 'patches/' directory, however, the\n'ls' is being invoked in the test trash directory instead. It turns\nout that the trash directory has three entries at this point, so the\ntest succeeds, but entirely by accident.\n"},{"id":"272429","messageId":"xmqqziz2kh68.fsf@gitster.mtv.corp.google.com","threadId":"39679","inReplyTo":"xmqqk2rj8kf5.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2] format-patch: introduce format.outputDirectory configuration","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-10-28T17:59:43Z","receivedAt":"2015-10-28T17:59:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Looks like there were mostly editorial niggles and no fundamental\n> flaws in the design of the patch; it is somewhat a shame to make all\n> the efforts go to waste.  Will we be seeing an update soon?\n\nSecond ping as I am going through the what's cooking reports and\ntrying to decide which topics listed in [Stalled] state need to be\ndiscarded from my tree.\n\nNot that my dropping a topic from 'pu' means very much (a dropped\ntopic can still be submitted and requeued after all), even if you\nare no longer interested on the topic, hearing from you would help\nothers who may be interested in helping the topic to completion.\n\nThanks.\n"},{"id":"275604","messageId":"1452393019-2852-1-git-send-email-ischis2@cox.net","threadId":"39679","inReplyTo":"CAPig+cTOG7QP25TyJbbm70NBXN6Z0nZPJyjxFp1y147WQmKEDg@mail.gmail.com","subject":"[PATCH v3] format-patch: introduce format.outputDirectory configuration","fromName":"Stephen P. Smith","fromEmail":"ischis2@cox.net","sentAt":"2016-01-10T02:30:19Z","receivedAt":"2016-01-10T02:30:19Z","isPatch":true,"sender":{"key":"ishchis2@gmail.com","avatar":null},"body":"From: Alexander Kuleshov <kuleshovmail@gmail.com>\n\nWe can pass -o/--output-directory to the format-patch command to\nstore patches not in the working directory. This patch introduces\nformat.outputDirectory configuration option for same purpose.\n\nThe case of usage of this configuration option can be convinience\nto not pass everytime -o/--output-directory if an user has pattern\nto store all patches in the /patches directory for example.\n\nThe format.outputDirectory has lower priority than command line\noption, so if user will set format.outputDirectory and pass the\ncommand line option, a result will be stored in a directory that\npassed to command line option.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\nSigned-off-by: Stephen P. Smith <ischis2@cox.net>\n---\n\nNotes:\n    Re-rolled patch by following review comments in:\n    \n    http://article.gmane.org/gmane.comp.version-control.git/272199\n    http://article.gmane.org/gmane.comp.version-control.git/278354\n    http://article.gmane.org/gmane.comp.version-control.git/278365\n    \n    Changes include:\n    * Specifying the patches directory as an argument to ls\n    * Not initialize config_output_directory  to NULL\n    * Grammar fixes in documentation\n    * Use test_config rather than git config\n\n Documentation/config.txt           |  4 ++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      |  7 +++++++\n t/t4014-format-patch.sh            | 13 +++++++++++++\n 4 files changed, 29 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f617886..e92a0ee 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,10 @@ format.coverLetter::\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+format.outputDirectory::\n+\tSet a custom directory to store the resulting files instead of the\n+\tcurrent working directory.\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 e3cdaeb..7a76594 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -57,7 +57,11 @@ The names of the output files are printed to standard\n output, unless the `--stdout` option is specified.\n \n If `-o` is specified, output files are created in <dir>.  Otherwise\n-they are created in the current working directory.\n+they are created in the current working directory. The default path\n+can be set with the setting 'format.outputDirectory' configuration option.\n+If `-o` is specified and 'format.outputDirectory' is set, output files\n+will be stored in a <dir> that passed to `-o`. When 'format.outputDirectory'\n+is set, to get default behaviour back is to pass './' to the `-o`.\n \n By default, the subject of a single patch is \"[PATCH] \" followed by\n the concatenation of lines from the commit message up to the first blank\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e00cea7..679ff76 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -707,6 +707,8 @@ enum {\n \tCOVER_AUTO\n };\n \n+static const char *config_output_directory;\n+\n static int git_format_config(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(var, \"format.headers\")) {\n@@ -777,6 +779,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.outputdirectory\"))\n+\t\treturn git_config_string(&config_output_directory, var, value);\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1391,6 +1395,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\n \n+\tif (!output_directory && !use_stdout)\n+\t\toutput_directory = config_output_directory;\n+\n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n \telse\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 646c475..5c6f128 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -40,6 +40,19 @@ test_expect_success setup '\n \n '\n \n+test_expect_success \"format-patch format.outputDirectory option\" '\n+\ttest_config format.outputDirectory \"patches/\" &&\n+\tgit format-patch master..side &&\n+\tcnt=$(ls patches | wc -l) &&\n+\ttest $cnt = 3\n+'\n+\n+test_expect_success \"format-patch format.outputDirectory overwritten with -o\" '\n+\ttest_config format.outputDirectory \"patches/\" &&\n+\tgit format-patch master..side -o \".\" &&\n+\ttest_path_is_missing patches/\n+'\n+\n test_expect_success \"format-patch --ignore-if-in-upstream\" '\n \n \tgit format-patch --stdout master..side >patch0 &&\n-- \n2.7.0-rc2\n"},{"id":"275605","messageId":"CAPig+cQ9kObgd5-OGRZH-YuZVnBX72ukS=kKD8OfTN51dQ0SRA@mail.gmail.com","threadId":"39679","inReplyTo":"1452393019-2852-1-git-send-email-ischis2@cox.net","subject":"Re: [PATCH v3] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-01-10T03:47:26Z","receivedAt":"2016-01-10T03:47:26Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"Thanks for reviving this abandoned patch. Please see review comments\nbelow, some of which repeat comments from the previous attempt[1], and\nsome of which are new. Most of the new ones are minor, although there\nis at least one major problem.\n\nOn Sat, Jan 9, 2016 at 9:30 PM, Stephen P. Smith <ischis2@cox.net> wrote:\n> From: Alexander Kuleshov <kuleshovmail@gmail.com>\n>\n> We can pass -o/--output-directory to the format-patch command to\n> store patches not in the working directory. This patch introduces\n\ns/not in/in some place other than/\n\n> format.outputDirectory configuration option for same purpose.\n>\n> The case of usage of this configuration option can be convinience\n\n>From [1]: s/convinience/convenience/\n\n> to not pass everytime -o/--output-directory if an user has pattern\n\nAlso[1]: s/everytime/every time/\nor: s/everytime/each time/\n\n> to store all patches in the /patches directory for example.\n>\n> The format.outputDirectory has lower priority than command line\n> option, so if user will set format.outputDirectory and pass the\n> command line option, a result will be stored in a directory that\n> passed to command line option.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> Signed-off-by: Stephen P. Smith <ischis2@cox.net>\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/272199\n\n> ---\n> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> @@ -57,7 +57,11 @@ The names of the output files are printed to standard\n>  output, unless the `--stdout` option is specified.\n>\n>  If `-o` is specified, output files are created in <dir>.  Otherwise\n> -they are created in the current working directory.\n> +they are created in the current working directory. The default path\n> +can be set with the setting 'format.outputDirectory' configuration option.\n\ns/setting//\n\n> +If `-o` is specified and 'format.outputDirectory' is set, output files\n> +will be stored in a <dir> that passed to `-o`. When 'format.outputDirectory'\n> +is set, to get default behaviour back is to pass './' to the `-o`.\n\nThis is difficult to read. How about replacing these two sentences\nwith something like this:\n\n    The `-o` option takes precedence over `format.outputDirectory`.\n    To store patches in the current working directory even when\n    `format.outputDirectory` points elsewhere, use `-o .`.\n\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> @@ -40,6 +40,19 @@ test_expect_success setup '\n\nRather than adding new tests at the very top of the script, it's more\ncommon to add them to the bottom or at least to insert them after\nother similar tests.\n\n> +test_expect_success \"format-patch format.outputDirectory option\" '\n\nUse single- rather than double-quotes: s/\"/'/\n\n> +       test_config format.outputDirectory \"patches/\" &&\n\nWe can drop the unnecessary quotes around \"patches\".\nAlso, can we drop the unnecessary \"/\"?\n\n> +       git format-patch master..side &&\n\nSince this test is about verifying that the \"patches\" directory got\ncreated and used, you want to be more careful about ensuring that\ndetritus from preceding tests won't muck up your results; for\ninstance, if an earlier test had also used a directory named \"patches\"\nand had dumped 42 files there instead of the 3 expected by this test.\nTherefore, you should insert \"rm -fr patches &&\" before the\ngit-format-patch invocation.\n\n> +       cnt=$(ls patches | wc -l) &&\n> +       test $cnt = 3\n\nPeriodically, we have trouble with the output of \"wc -l\" on Mac OS X\nsince the output has leading spaces. This code doesn't trip over that\nproblem since it doesn't quote the output, but it still feels fragile\nto be comparing the it against a number using the string equality test\n'='. How about using the '-eq' numeric equality test instead?\n\nMoreover, there is no need for the temporary 'cnt' variable. Instead:\n\n    test $(ls patches | wc -l) -eq 3 &&\n\nDepending upon taste, you might alternately use:\n\n    ls patches >actual &&\n    test_line_count = 3 actual\n\nwhich would give you more useful debugging output upon failure.\n\n> +'\n> +\n> +test_expect_success \"format-patch format.outputDirectory overwritten with -o\" '\n\nUse single- rather than double-qoutes: s/\"/'/\nAlso, how about rewording it?\n\n    'format-patch -o overrides format.outputDirectory'\n\n> +       test_config format.outputDirectory \"patches/\" &&\n\nStyle: drop unnecessary quotes around \"patches\"\nStyle: drop unnecessary \"/\"\n\n> +       git format-patch master..side -o \".\" &&\n\nStyle: drop unnecessary quotes around \".\"\n\n> +       test_path_is_missing patches/\n\nStyle: drop unnecessary \"/\"\n\nThere is a rather severe problem with this test in that it fails\nunconditionally. It wants to verify that -o takes precedence over\nformat.outputDirectory by checking that the directory \"patches\" did\nnot get created by git-format-patch, however, that directory already\nexists since it was created by the previous test, thus\ntest_path_is_missing() fails. Therefore, you should insert \"rm -fr\npatches &&\" before the git-format-patch invocation.\n\nIt also might not hurt to make the test a bit more robust by verifying\nnot only that the directory specified by format.outputDirectory did\nnot get created, but that the directory named by -o did get created,\nwhich means giving -o an argument other than \".\". So, the final test\nmight look like this:\n\n    test_config format.outputDirectory patches &&\n    rm -fr patches patchset &&\n    git format-patch master..side -o patchset &&\n    test_path_is_missing patches &&\n    test_path_is_dir patchset\n\n> +'\n> --\n> 2.7.0-rc2\n"},{"id":"275620","messageId":"1452472227-9684-1-git-send-email-ischis2@cox.net","threadId":"39679","inReplyTo":"CAPig+cQ9kObgd5-OGRZH-YuZVnBX72ukS=kKD8OfTN51dQ0SRA@mail.gmail.com","subject":"[PATCH v4] format-patch: introduce format.outputDirectory configuration","fromName":"Stephen P. Smith","fromEmail":"ischis2@cox.net","sentAt":"2016-01-11T00:30:27Z","receivedAt":"2016-01-11T00:30:27Z","isPatch":true,"sender":{"key":"ishchis2@gmail.com","avatar":null},"body":"From: Alexander Kuleshov <kuleshovmail@gmail.com>\n\nWe can pass -o/--output-directory to the format-patch command to store\npatches in some place other than the working directory. This patch\nintroduces format.outputDirectory configuration option for same\npurpose.\n\nThe case of usage of this configuration option can be convinience\nto not pass every time -o/--output-directory if an user has pattern\nto store all patches in the /patches directory for example.\n\nThe format.outputDirectory has lower priority than command line\noption, so if user will set format.outputDirectory and pass the\ncommand line option, a result will be stored in a directory that\npassed to command line option.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\nSigned-off-by: Stephen P. Smith <ischis2@cox.net>\n---\n\nNotes:\n    Updated based on http://article.gmane.org/gmane.comp.version-control.git/283613\n    \n    Commit message changes:\n      s/not in/in some place other than/.\n      s/everytime/every time/.\n    \n    git-format-patch.txt change:\n      s/setting//.\n      applied the two sentence wording change.\n    \n    t4014-format-patch.sh:\n      moved tests to the end of the test suite.\n      added rm commands to remove directory prior to testing.\n      changed directory name style issues.\n\n Documentation/config.txt           |  4 ++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      |  7 +++++++\n t/t4014-format-patch.sh            | 16 ++++++++++++++++\n 4 files changed, 32 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f617886..e92a0ee 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,10 @@ format.coverLetter::\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+format.outputDirectory::\n+\tSet a custom directory to store the resulting files instead of the\n+\tcurrent working directory.\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 e3cdaeb..64c2803 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -57,7 +57,11 @@ The names of the output files are printed to standard\n output, unless the `--stdout` option is specified.\n \n If `-o` is specified, output files are created in <dir>.  Otherwise\n-they are created in the current working directory.\n+they are created in the current working directory. The default path\n+can be set with the 'format.outputDirectory' configuration option.\n+The `-o` option takes precedence over `format.outputDirectory`.\n+To store patches in the current working directory even when\n+`format.outputDirectory` points elsewhere, use `-o .`.\n \n By default, the subject of a single patch is \"[PATCH] \" followed by\n the concatenation of lines from the commit message up to the first blank\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e00cea7..679ff76 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -707,6 +707,8 @@ enum {\n \tCOVER_AUTO\n };\n \n+static const char *config_output_directory;\n+\n static int git_format_config(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(var, \"format.headers\")) {\n@@ -777,6 +779,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.outputdirectory\"))\n+\t\treturn git_config_string(&config_output_directory, var, value);\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1391,6 +1395,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\n \n+\tif (!output_directory && !use_stdout)\n+\t\toutput_directory = config_output_directory;\n+\n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n \telse\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 646c475..a662cb2 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1445,4 +1445,20 @@ test_expect_success 'From line has expected format' '\n \ttest_cmp from filtered\n '\n \n+test_expect_success 'format-patch format.outputDirectory option' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches &&\n+\tgit format-patch master..side &&\n+\tls patches >actual &&\n+\ttest_line_count = 3 actual\n+'\n+\n+test_expect_success 'format-patch -o overrides format.outputDirectory' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches patchset &&\n+\tgit format-patch master..side -o patchset &&\n+\ttest_path_is_missing patches &&\n+\ttest_path_is_dir patchset\n+'\n+\n test_done\n-- \n2.7.0-rc2\n"},{"id":"275623","messageId":"CAPig+cSoEYof0quiG=P4SRiOb7FeNDnVsGdzGoxO=oLcgfGBUA@mail.gmail.com","threadId":"39679","inReplyTo":"1452472227-9684-1-git-send-email-ischis2@cox.net","subject":"Re: [PATCH v4] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-01-11T03:55:18Z","receivedAt":"2016-01-11T03:55:18Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jan 10, 2016 at 7:30 PM, Stephen P. Smith <ischis2@cox.net> wrote:\n> We can pass -o/--output-directory to the format-patch command to store\n> patches in some place other than the working directory. This patch\n> introduces format.outputDirectory configuration option for same\n> purpose.\n>\n> The case of usage of this configuration option can be convinience\n> to not pass every time -o/--output-directory if an user has pattern\n> to store all patches in the /patches directory for example.\n>\n> The format.outputDirectory has lower priority than command line\n> option, so if user will set format.outputDirectory and pass the\n> command line option, a result will be stored in a directory that\n> passed to command line option.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> Signed-off-by: Stephen P. Smith <ischis2@cox.net>\n> ---\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> @@ -1445,4 +1445,20 @@ test_expect_success 'From line has expected format' '\n> +test_expect_success 'format-patch format.outputDirectory option' '\n> +       test_config format.outputDirectory patches &&\n> +       rm -fr patches &&\n> +       git format-patch master..side &&\n> +       ls patches >actual &&\n> +       test_line_count = 3 actual\n> +'\n\nNow that you've moved the new tests to the bottom of the script, this\ntest fails. This is because, at this point, there are 18 commits in\nthe range 'master..side', not 3 as when the test was at the top of the\nscript. You could change the 3 to an 18, however, that would be\nfragile: if someone inserts or modifies tests above this one, then a\nhard-coded 18 might become stale. One possible fix would be:\n\n    test $(git rev-list master..side | wc -l) -eq $(ls patches)\n\nYou could also take the stance that you're not so much interested in\nthe number of patches in the range 'master..side' but rather you\nmerely care about the fact that the \"patches\" directory got created\nand some patches were deposited there. In that case, you might do this\ninstead:\n\n    git format-patch -3 side &&\n    ls patches >actual &&\n    test_line_count = 3 actual\n\nI don't feel strongly about it either way, but whichever approach you\nchoose, please do build the project and run this test script to ensure\nthat it succeeds before submitting v5. Thanks.\n\n> +test_expect_success 'format-patch -o overrides format.outputDirectory' '\n> +       test_config format.outputDirectory patches &&\n> +       rm -fr patches patchset &&\n> +       git format-patch master..side -o patchset &&\n> +       test_path_is_missing patches &&\n> +       test_path_is_dir patchset\n> +'\n"},{"id":"275624","messageId":"CAPig+cRjBockaXKacYA-pxWQe_gzAAvjAwonQKn1kSANHORt1A@mail.gmail.com","threadId":"39679","inReplyTo":"CAPig+cSoEYof0quiG=P4SRiOb7FeNDnVsGdzGoxO=oLcgfGBUA@mail.gmail.com","subject":"Re: [PATCH v4] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-01-11T04:00:59Z","receivedAt":"2016-01-11T04:00:59Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Jan 10, 2016 at 10:55 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Sun, Jan 10, 2016 at 7:30 PM, Stephen P. Smith <ischis2@cox.net> wrote:\n>> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n>> @@ -1445,4 +1445,20 @@ test_expect_success 'From line has expected format' '\n>> +test_expect_success 'format-patch format.outputDirectory option' '\n>> +       test_config format.outputDirectory patches &&\n>> +       rm -fr patches &&\n>> +       git format-patch master..side &&\n>> +       ls patches >actual &&\n>> +       test_line_count = 3 actual\n>> +'\n>\n> Now that you've moved the new tests to the bottom of the script, this\n> test fails. This is because, at this point, there are 18 commits in\n> the range 'master..side', not 3 as when the test was at the top of the\n> script. You could change the 3 to an 18, however, that would be\n> fragile: if someone inserts or modifies tests above this one, then a\n> hard-coded 18 might become stale. One possible fix would be:\n>\n>     test $(git rev-list master..side | wc -l) -eq $(ls patches)\n\nThat would be $(ls patches | wc -l), of course.\n"},{"id":"275865","messageId":"1452660493-5430-1-git-send-email-ischis2@cox.net","threadId":"39679","inReplyTo":"CAPig+cRjBockaXKacYA-pxWQe_gzAAvjAwonQKn1kSANHORt1A@mail.gmail.com","subject":"[PATCH v5] format-patch: introduce format.outputDirectory configuration","fromName":"Stephen P. Smith","fromEmail":"ischis2@cox.net","sentAt":"2016-01-13T04:48:13Z","receivedAt":"2016-01-13T04:48:13Z","isPatch":true,"sender":{"key":"ishchis2@gmail.com","avatar":null},"body":"From: Alexander Kuleshov <kuleshovmail@gmail.com>\n\nWe can pass -o/--output-directory to the format-patch command to store\npatches in some place other than the working directory. This patch\nintroduces format.outputDirectory configuration option for same\npurpose.\n\nThe case of usage of this configuration option can be convinience\nto not pass every time -o/--output-directory if an user has pattern\nto store all patches in the /patches directory for example.\n\nThe format.outputDirectory has lower priority than command line\noption, so if user will set format.outputDirectory and pass the\ncommand line option, a result will be stored in a directory that\npassed to command line option.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\nSigned-off-by: Stephen P. Smith <ischis2@cox.net>\n---\n\nNotes:\n    Fixed bug which was found when moving the tests to the end of the \n    script by removing the hardcoded expected count and replacing with a \n    computation of the number of actual patches.\n\n    Mailing list web interface is again not working; therefore, I don't \n    have URLs for the earlier review comments.\n    \n Documentation/config.txt           |  4 ++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      |  7 +++++++\n t/t4014-format-patch.sh            | 15 +++++++++++++++\n 4 files changed, 31 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f617886..e92a0ee 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,10 @@ format.coverLetter::\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+format.outputDirectory::\n+\tSet a custom directory to store the resulting files instead of the\n+\tcurrent working directory.\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 e3cdaeb..64c2803 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -57,7 +57,11 @@ The names of the output files are printed to standard\n output, unless the `--stdout` option is specified.\n \n If `-o` is specified, output files are created in <dir>.  Otherwise\n-they are created in the current working directory.\n+they are created in the current working directory. The default path\n+can be set with the 'format.outputDirectory' configuration option.\n+The `-o` option takes precedence over `format.outputDirectory`.\n+To store patches in the current working directory even when\n+`format.outputDirectory` points elsewhere, use `-o .`.\n \n By default, the subject of a single patch is \"[PATCH] \" followed by\n the concatenation of lines from the commit message up to the first blank\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e00cea7..679ff76 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -707,6 +707,8 @@ enum {\n \tCOVER_AUTO\n };\n \n+static const char *config_output_directory;\n+\n static int git_format_config(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(var, \"format.headers\")) {\n@@ -777,6 +779,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.outputdirectory\"))\n+\t\treturn git_config_string(&config_output_directory, var, value);\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1391,6 +1395,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\n \n+\tif (!output_directory && !use_stdout)\n+\t\toutput_directory = config_output_directory;\n+\n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n \telse\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 646c475..3b99434 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1445,4 +1445,19 @@ test_expect_success 'From line has expected format' '\n \ttest_cmp from filtered\n '\n \n+test_expect_success 'format-patch format.outputDirectory option' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches &&\n+\tgit format-patch master..side &&\n+\ttest $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n+'\n+\n+test_expect_success 'format-patch -o overrides format.outputDirectory' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches patchset &&\n+\tgit format-patch master..side -o patchset &&\n+\ttest_path_is_missing patches &&\n+\ttest_path_is_dir patchset\n+'\n+\n test_done\n-- \n2.7.0-rc2\n"},{"id":"275872","messageId":"CAPig+cTCRq9VCT7t8E9yjk4QcHYB2_qeBwGB_31keB4nTjkLkA@mail.gmail.com","threadId":"39679","inReplyTo":"1452660493-5430-1-git-send-email-ischis2@cox.net","subject":"Re: [PATCH v5] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-01-13T06:52:11Z","receivedAt":"2016-01-13T06:52:11Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jan 12, 2016 at 11:48 PM, Stephen P. Smith <ischis2@cox.net> wrote:\n> From: Alexander Kuleshov <kuleshovmail@gmail.com>\n>\n> We can pass -o/--output-directory to the format-patch command to store\n> patches in some place other than the working directory. This patch\n> introduces format.outputDirectory configuration option for same\n> purpose.\n>\n> The case of usage of this configuration option can be convinience\n\nMentioned several times already: s/convinience/convenience/\n\n> to not pass every time -o/--output-directory if an user has pattern\n> to store all patches in the /patches directory for example.\n>\n> The format.outputDirectory has lower priority than command line\n> option, so if user will set format.outputDirectory and pass the\n> command line option, a result will be stored in a directory that\n> passed to command line option.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> Signed-off-by: Stephen P. Smith <ischis2@cox.net>\n> ---\n> Notes:\n>     Fixed bug which was found when moving the tests to the end of the\n>     script by removing the hardcoded expected count and replacing with a\n>     computation of the number of actual patches.\n\nThanks, this version looks better. Aside from the misspelling above\nand a minor comment below, this version is:\n\nReviewed-by: Eric Sunshine <sunshine@sunshineco.com>\n\n>     Mailing list web interface is again not working; therefore, I don't\n>     have URLs for the earlier review comments.\n\nThe full set of attempts is here [1].\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/272180\n\n> diff --git a/builtin/log.c b/builtin/log.c\n> @@ -707,6 +707,8 @@ enum {\n>         COVER_AUTO\n>  };\n>\n> +static const char *config_output_directory;\n\nI don't care strongly, but I wonder why this new variable is placed\nbelow the enum rather than being grouped with other similar variables\njust above this enum. (Probably not worth a re-roll, though.)\n\n>  static int git_format_config(const char *var, const char *value, void *cb)\n>  {\n>         if (!strcmp(var, \"format.headers\")) {\n"},{"id":"275902","messageId":"1452691211-15347-1-git-send-email-ischis2@cox.net","threadId":"39679","inReplyTo":"CAPig+cTCRq9VCT7t8E9yjk4QcHYB2_qeBwGB_31keB4nTjkLkA@mail.gmail.com","subject":"[PATCH v6] format-patch: introduce format.outputDirectory configuration","fromName":"Stephen P. Smith","fromEmail":"ischis2@cox.net","sentAt":"2016-01-13T13:20:11Z","receivedAt":"2016-01-13T13:20:11Z","isPatch":true,"sender":{"key":"ishchis2@gmail.com","avatar":null},"body":"From: Alexander Kuleshov <kuleshovmail@gmail.com>\n\nWe can pass -o/--output-directory to the format-patch command to store\npatches in some place other than the working directory. This patch\nintroduces format.outputDirectory configuration option for same\npurpose.\n\nThe case of usage of this configuration option can be convenience\nto not pass every time -o/--output-directory if an user has pattern\nto store all patches in the /patches directory for example.\n\nThe format.outputDirectory has lower priority than command line\noption, so if user will set format.outputDirectory and pass the\ncommand line option, a result will be stored in a directory that\npassed to command line option.\n\nSigned-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\nSigned-off-by: Stephen P. Smith <ischis2@cox.net>\n---\n\nNotes:\n    Fixed s/convinience/convenience/\n    \n    Moved 'static const char *config_output_directory;' to be with othe\n    similarly typed variables.\n    \n    The full set of attempts is here [1].\n    \n    [1]: http://thread.gmane.org/gmane.comp.version-control.git/272180\n\n Documentation/config.txt           |  4 ++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      |  6 ++++++\n t/t4014-format-patch.sh            | 15 +++++++++++++++\n 4 files changed, 30 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f617886..e92a0ee 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,10 @@ format.coverLetter::\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+format.outputDirectory::\n+\tSet a custom directory to store the resulting files instead of the\n+\tcurrent working directory.\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 e3cdaeb..64c2803 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -57,7 +57,11 @@ The names of the output files are printed to standard\n output, unless the `--stdout` option is specified.\n \n If `-o` is specified, output files are created in <dir>.  Otherwise\n-they are created in the current working directory.\n+they are created in the current working directory. The default path\n+can be set with the 'format.outputDirectory' configuration option.\n+The `-o` option takes precedence over `format.outputDirectory`.\n+To store patches in the current working directory even when\n+`format.outputDirectory` points elsewhere, use `-o .`.\n \n By default, the subject of a single patch is \"[PATCH] \" followed by\n the concatenation of lines from the commit message up to the first blank\ndiff --git a/builtin/log.c b/builtin/log.c\nindex e00cea7..0d738d6 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -699,6 +699,7 @@ static int do_signoff;\n static const char *signature = git_version_string;\n static const char *signature_file;\n static int config_cover_letter;\n+static const char *config_output_directory;\n \n enum {\n \tCOVER_UNSET,\n@@ -777,6 +778,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t\tconfig_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(var, \"format.outputdirectory\"))\n+\t\treturn git_config_string(&config_output_directory, var, value);\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1391,6 +1394,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tif (rev.show_notes)\n \t\tinit_display_notes(&rev.notes_opt);\n \n+\tif (!output_directory && !use_stdout)\n+\t\toutput_directory = config_output_directory;\n+\n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\n \telse\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 646c475..3b99434 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1445,4 +1445,19 @@ test_expect_success 'From line has expected format' '\n \ttest_cmp from filtered\n '\n \n+test_expect_success 'format-patch format.outputDirectory option' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches &&\n+\tgit format-patch master..side &&\n+\ttest $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n+'\n+\n+test_expect_success 'format-patch -o overrides format.outputDirectory' '\n+\ttest_config format.outputDirectory patches &&\n+\trm -fr patches patchset &&\n+\tgit format-patch master..side -o patchset &&\n+\ttest_path_is_missing patches &&\n+\ttest_path_is_dir patchset\n+'\n+\n test_done\n-- \n2.7.0-rc2\n"},{"id":"275952","messageId":"CAPig+cSxVdZN_wr3XuqDGuKn14J3B7s=S8OoH19v+AjMvcX6+Q@mail.gmail.com","threadId":"39679","inReplyTo":"1452691211-15347-1-git-send-email-ischis2@cox.net","subject":"Re: [PATCH v6] format-patch: introduce format.outputDirectory configuration","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-01-13T18:27:19Z","receivedAt":"2016-01-13T18:27:19Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, Jan 13, 2016 at 8:20 AM, Stephen P. Smith <ischis2@cox.net> wrote:\n> From: Alexander Kuleshov <kuleshovmail@gmail.com>\n>\n> We can pass -o/--output-directory to the format-patch command to store\n> patches in some place other than the working directory. This patch\n> introduces format.outputDirectory configuration option for same\n> purpose.\n>\n> The case of usage of this configuration option can be convenience\n> to not pass every time -o/--output-directory if an user has pattern\n> to store all patches in the /patches directory for example.\n>\n> The format.outputDirectory has lower priority than command line\n> option, so if user will set format.outputDirectory and pass the\n> command line option, a result will be stored in a directory that\n> passed to command line option.\n>\n> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>\n> Signed-off-by: Stephen P. Smith <ischis2@cox.net>\n> ---\n> Notes:\n>     Fixed s/convinience/convenience/\n>\n>     Moved 'static const char *config_output_directory;' to be with othe\n>     similarly typed variables.\n\nThanks. This version is also:\n\nReviewed-by: Eric Sunshine <sunshine@sunshineco.com>\n\n(A note for future submissions of other patches: Once a person has\ngiven a Reviewed-by:, you're welcome to include the Reviewed-by: in a\nre-roll provided that the re-roll doesn't change anything which would\nobviously invalidate the Reviewed-by:. In this particular case, for\ninstance, v6 merely fixed a couple very minor nits mentioned in my v5\nreview, so it would have been perfectly acceptable to include my\nReviewed-by: in v6.)\n\n>  Documentation/config.txt           |  4 ++++\n>  Documentation/git-format-patch.txt |  6 +++++-\n>  builtin/log.c                      |  6 ++++++\n>  t/t4014-format-patch.sh            | 15 +++++++++++++++\n>  4 files changed, 30 insertions(+), 1 deletion(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index f617886..e92a0ee 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -1243,6 +1243,10 @@ format.coverLetter::\n>         format-patch is invoked, but in addition can be set to \"auto\", to\n>         generate a cover-letter only when there's more than one patch.\n>\n> +format.outputDirectory::\n> +       Set a custom directory to store the resulting files instead of the\n> +       current working directory.\n> +\n>  filter.<driver>.clean::\n>         The command which is used to convert the content of a worktree\n>         file to a blob upon checkin.  See linkgit:gitattributes[5] for\n> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> index e3cdaeb..64c2803 100644\n> --- a/Documentation/git-format-patch.txt\n> +++ b/Documentation/git-format-patch.txt\n> @@ -57,7 +57,11 @@ The names of the output files are printed to standard\n>  output, unless the `--stdout` option is specified.\n>\n>  If `-o` is specified, output files are created in <dir>.  Otherwise\n> -they are created in the current working directory.\n> +they are created in the current working directory. The default path\n> +can be set with the 'format.outputDirectory' configuration option.\n> +The `-o` option takes precedence over `format.outputDirectory`.\n> +To store patches in the current working directory even when\n> +`format.outputDirectory` points elsewhere, use `-o .`.\n>\n>  By default, the subject of a single patch is \"[PATCH] \" followed by\n>  the concatenation of lines from the commit message up to the first blank\n> diff --git a/builtin/log.c b/builtin/log.c\n> index e00cea7..0d738d6 100644\n> --- a/builtin/log.c\n> +++ b/builtin/log.c\n> @@ -699,6 +699,7 @@ static int do_signoff;\n>  static const char *signature = git_version_string;\n>  static const char *signature_file;\n>  static int config_cover_letter;\n> +static const char *config_output_directory;\n>\n>  enum {\n>         COVER_UNSET,\n> @@ -777,6 +778,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n>                 config_cover_letter = git_config_bool(var, value) ? COVER_ON : COVER_OFF;\n>                 return 0;\n>         }\n> +       if (!strcmp(var, \"format.outputdirectory\"))\n> +               return git_config_string(&config_output_directory, var, value);\n>\n>         return git_log_config(var, value, cb);\n>  }\n> @@ -1391,6 +1394,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n>         if (rev.show_notes)\n>                 init_display_notes(&rev.notes_opt);\n>\n> +       if (!output_directory && !use_stdout)\n> +               output_directory = config_output_directory;\n> +\n>         if (!use_stdout)\n>                 output_directory = set_outdir(prefix, output_directory);\n>         else\n> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index 646c475..3b99434 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -1445,4 +1445,19 @@ test_expect_success 'From line has expected format' '\n>         test_cmp from filtered\n>  '\n>\n> +test_expect_success 'format-patch format.outputDirectory option' '\n> +       test_config format.outputDirectory patches &&\n> +       rm -fr patches &&\n> +       git format-patch master..side &&\n> +       test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n> +'\n> +\n> +test_expect_success 'format-patch -o overrides format.outputDirectory' '\n> +       test_config format.outputDirectory patches &&\n> +       rm -fr patches patchset &&\n> +       git format-patch master..side -o patchset &&\n> +       test_path_is_missing patches &&\n> +       test_path_is_dir patchset\n> +'\n> +\n>  test_done\n> --\n> 2.7.0-rc2\n"}]}