{"thread":{"id":"51960","subject":"[PATCH 1/3] format-patch: document and exercise that -o does only create the trailing directory","startedAt":"2019-10-02T21:26:18Z","lastAt":"2019-10-03T16:35:11Z","messageCount":7,"participants":["Bert Wesarg","Denton Liu","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"383308","messageId":"1aeacd8af4b83142f160c63be4746554e823cfc3.1570051490.git.bert.wesarg@googlemail.com","threadId":"51960","inReplyTo":null,"subject":"[PATCH 1/3] format-patch: document and exercise that -o does only create the trailing directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-10-02T21:26:11Z","receivedAt":"2019-10-02T21:26:18Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n Documentation/config/format.txt    |  3 ++-\n Documentation/git-format-patch.txt |  4 +++-\n t/t4014-format-patch.sh            | 16 ++++++++++++++++\n 3 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex 414a5a8a9d..e17c5d6b0f 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -80,7 +80,8 @@ format.coverLetter::\n \n format.outputDirectory::\n \tSet a custom directory to store the resulting files instead of the\n-\tcurrent working directory.\n+\tcurrent working directory. Only the trailing directory will be created\n+\tthough.\n \n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex b9b97e63ae..fe7492353e 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -66,7 +66,9 @@ 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+`format.outputDirectory` points elsewhere, use `-o .`. Note that only\n+the trailing directory will be created by Git, leading directories must\n+already exists.\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/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex ca7debf1d4..bf2715a503 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1632,6 +1632,22 @@ test_expect_success 'From line has expected format' '\n \ttest_cmp from filtered\n '\n \n+test_expect_success 'format-patch -o with no leading directories' '\n+\trm -fr patches &&\n+\tgit format-patch -o patches 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 with leading existing directories' '\n+\tgit format-patch -o patches/side master..side &&\n+\ttest $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)\n+'\n+\n+test_expect_failure 'format-patch -o with leading non-existing directories' '\n+\trm -fr patches &&\n+\tgit format-patch -o patches/side master..side\n+'\n+\n test_expect_success 'format-patch format.outputDirectory option' '\n \ttest_config format.outputDirectory patches &&\n \trm -fr patches &&\n-- \n2.23.0.11.g242cf7f110\n\n"},{"id":"383309","messageId":"d959e78af1cb7ef49bca970643b2136c436cd57d.1570051490.git.bert.wesarg@googlemail.com","threadId":"51960","inReplyTo":"1aeacd8af4b83142f160c63be4746554e823cfc3.1570051490.git.bert.wesarg@googlemail.com","subject":"[PATCH 2/3] format-patch: create output directory including leading components","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-10-02T21:26:12Z","receivedAt":"2019-10-02T21:26:21Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n Documentation/config/format.txt    | 3 +--\n Documentation/git-format-patch.txt | 5 ++---\n builtin/log.c                      | 8 ++++++++\n t/t4014-format-patch.sh            | 5 +++--\n 4 files changed, 14 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex e17c5d6b0f..b6c96ece04 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -80,8 +80,7 @@ format.coverLetter::\n \n format.outputDirectory::\n \tSet a custom directory to store the resulting files instead of the\n-\tcurrent working directory. Only the trailing directory will be created\n-\tthough.\n+\tcurrent working directory. All directory components will be created.\n \n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex fe7492353e..f418f490aa 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -66,9 +66,8 @@ 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 .`. Note that only\n-the trailing directory will be created by Git, leading directories must\n-already exists.\n+`format.outputDirectory` points elsewhere, use `-o .`. All directory\n+components will be created.\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 44b10b3415..1ab9eb6b78 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1769,6 +1769,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\trev.diffopt.use_color = GIT_COLOR_NEVER;\n \t\tif (use_stdout)\n \t\t\tdie(_(\"standard output, or directory, which one?\"));\n+\t\tswitch (safe_create_leading_directories_const(output_directory)) {\n+\t\tcase SCLD_OK:\n+\t\tcase SCLD_EXISTS:\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tdie(_(\"could not create leading directories \"\n+\t\t\t      \"of '%s'\"), output_directory);\n+\t\t}\n \t\tif (mkdir(output_directory, 0777) < 0 && errno != EEXIST)\n \t\t\tdie_errno(_(\"could not create directory '%s'\"),\n \t\t\t\t  output_directory);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex bf2715a503..43d608aa94 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1643,9 +1643,10 @@ test_expect_success 'format-patch -o with leading existing directories' '\n \ttest $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)\n '\n \n-test_expect_failure 'format-patch -o with leading non-existing directories' '\n+test_expect_success 'format-patch -o with leading non-existing directories' '\n \trm -fr patches &&\n-\tgit format-patch -o patches/side master..side\n+\tgit format-patch -o patches/side master..side &&\n+\ttest $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)\n '\n \n test_expect_success 'format-patch format.outputDirectory option' '\n-- \n2.23.0.11.g242cf7f110\n\n"},{"id":"383310","messageId":"431f8a4e372feccf240b9c66c91248a6f53eab47.1570051490.git.bert.wesarg@googlemail.com","threadId":"51960","inReplyTo":"1aeacd8af4b83142f160c63be4746554e823cfc3.1570051490.git.bert.wesarg@googlemail.com","subject":"[RFC PATCH 3/3] format-patch: use a command to generate the output directory name","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-10-02T21:26:13Z","receivedAt":"2019-10-02T21:26:22Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Having 'format.outputDirectory' is convenient, but being able to process\nall produced patches via a wildcard command is even more so. I.e.,\nusing an argument like '<dir>/*'. Neither '-o' nor\n'format.outputDirectory' can be parameterized to produce a new unique\ndirectory. Thus provide the new 'format.outputDirectoryCmd' configuration\nto specify a command which does the job and puts the name to standard\noutput.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n\n---\nCc: Alexander Kuleshov <kuleshovmail@gmail.com>\nCc: Eric Sunshine <sunshine@sunshineco.com>\n---\n Documentation/config/format.txt    |  5 +++++\n Documentation/git-format-patch.txt |  6 +++++-\n builtin/log.c                      | 24 +++++++++++++++++++++++-\n t/t4014-format-patch.sh            | 24 ++++++++++++++++++++++++\n 4 files changed, 57 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\nindex b6c96ece04..dcce2c67ef 100644\n--- a/Documentation/config/format.txt\n+++ b/Documentation/config/format.txt\n@@ -82,6 +82,11 @@ format.outputDirectory::\n \tSet a custom directory to store the resulting files instead of the\n \tcurrent working directory. All directory components will be created.\n \n+format.outputDirectoryCmd::\n+\tThe command which is used to name a custom directory to store the\n+\tresulting files instead of the current working directory. All directory\n+\tcomponents will be created.\n+\n format.useAutoBase::\n \tA boolean value which lets you enable the `--base=auto` option of\n \tformat-patch by default.\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex f418f490aa..0da904255b 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -67,7 +67,11 @@ 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 .`. All directory\n-components will be created.\n+components will be created. The 'format.outputDirectoryCmd' configuration can\n+be used to name a command to produce the directory name programmatically. The\n+command should produce the name to its standard output. The\n+`format.outputDirectory` configuration takes precedence over\n+`format.outputDirectoryCmd`.\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 1ab9eb6b78..b102e86bea 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -774,6 +774,7 @@ 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+static const char *config_output_directory_cmd;\n \n enum {\n \tCOVER_UNSET,\n@@ -856,6 +857,8 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"format.outputdirectory\"))\n \t\treturn git_config_string(&config_output_directory, var, value);\n+\tif (!strcmp(var, \"format.outputdirectorycmd\"))\n+\t\treturn git_config_string(&config_output_directory_cmd, var, value);\n \tif (!strcmp(var, \"format.useautobase\")) {\n \t\tbase_auto = git_config_bool(var, value);\n \t\treturn 0;\n@@ -1756,8 +1759,27 @@ 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+\tif (!output_directory && !use_stdout) {\n+\t\t// outputDirectoryCmd can be preceeded by outputDirectory\n+\t\tif (!config_output_directory && config_output_directory_cmd) {\n+\t\t\tstruct child_process cp = CHILD_PROCESS_INIT;\n+\t\t\tconst char *argv[1];\n+\t\t\tstruct strbuf buf = STRBUF_INIT;\n+\t\t\tint rc;\n+\n+\t\t\targv[0] = config_output_directory_cmd;\n+\t\t\tcp.argv = argv;\n+\t\t\tcp.use_shell = 1;\n+\t\t\trc = capture_command(&cp, &buf, PATH_MAX);\n+\t\t\tif (rc)\n+\t\t\t\tdie(_(\"outputDirectoryCmd command failed: \"\n+\t\t\t\t      \"'%s'\"), config_output_directory_cmd);\n+\t\t\tstrbuf_setlen(&buf, strcspn(buf.buf, \"\\r\\n\"));\n+\t\t\tconfig_output_directory = strbuf_detach(&buf, NULL);\n+\t\t}\n+\n \t\toutput_directory = config_output_directory;\n+\t}\n \n \tif (!use_stdout)\n \t\toutput_directory = set_outdir(prefix, output_directory);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 43d608aa94..bf2547ce87 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1664,6 +1664,30 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '\n \ttest_path_is_dir patchset\n '\n \n+test_expect_success 'format-patch format.outputDirectoryCmd option' '\n+\ttest_config format.outputDirectoryCmd \"echo 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 format.outputDirectory overrides format.outputDirectoryCmd' '\n+\ttest_config format.outputDirectoryCmd \"echo patches\" &&\n+\ttest_config format.outputDirectory patchset &&\n+\trm -fr patches patchset &&\n+\tgit format-patch master..side &&\n+\ttest_path_is_missing patches &&\n+\ttest_path_is_dir patchset\n+'\n+\n+test_expect_success 'format-patch -o overrides format.outputDirectoryCmd' '\n+\ttest_config format.outputDirectoryCmd \"echo patches\" &&\n+\trm -fr patches patchset &&\n+\tgit format-patch -o patchset master..side &&\n+\ttest_path_is_missing patches &&\n+\ttest_path_is_dir patchset\n+'\n+\n test_expect_success 'format-patch --base' '\n \tgit checkout patchid &&\n \tgit format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual1 &&\n-- \n2.23.0.11.g242cf7f110\n\n"},{"id":"383311","messageId":"20191002214709.GA51809@generichostname","threadId":"51960","inReplyTo":"1aeacd8af4b83142f160c63be4746554e823cfc3.1570051490.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 1/3] format-patch: document and exercise that -o does only create the trailing directory","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-10-02T21:47:09Z","receivedAt":"2019-10-02T21:47:15Z","isPatch":true,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Bert,\n\n> Subject: format-patch: document and exercise that -o does only create the trailing directory\n\ns/does only create/only creates/ ?\n\nAnyway, as a prepatory patch, I don't think that it's necessary. Maybe\nit's just me but I assume that most tools create at most one directory\ndeep. Even mkdir won't created nested dirs unless you pass `-p`. I\ndunno.\n\nOn Wed, Oct 02, 2019 at 11:26:11PM +0200, Bert Wesarg wrote:\n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n>  Documentation/config/format.txt    |  3 ++-\n>  Documentation/git-format-patch.txt |  4 +++-\n>  t/t4014-format-patch.sh            | 16 ++++++++++++++++\n>  3 files changed, 21 insertions(+), 2 deletions(-)\n> \n> diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n> index 414a5a8a9d..e17c5d6b0f 100644\n> --- a/Documentation/config/format.txt\n> +++ b/Documentation/config/format.txt\n> @@ -80,7 +80,8 @@ format.coverLetter::\n>  \n>  format.outputDirectory::\n>  \tSet a custom directory to store the resulting files instead of the\n> -\tcurrent working directory.\n> +\tcurrent working directory. Only the trailing directory will be created\n> +\tthough.\n>  \n>  format.useAutoBase::\n>  \tA boolean value which lets you enable the `--base=auto` option of\n> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> index b9b97e63ae..fe7492353e 100644\n> --- a/Documentation/git-format-patch.txt\n> +++ b/Documentation/git-format-patch.txt\n> @@ -66,7 +66,9 @@ 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> +`format.outputDirectory` points elsewhere, use `-o .`. Note that only\n> +the trailing directory will be created by Git, leading directories must\n> +already exists.\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/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> index ca7debf1d4..bf2715a503 100755\n> --- a/t/t4014-format-patch.sh\n> +++ b/t/t4014-format-patch.sh\n> @@ -1632,6 +1632,22 @@ test_expect_success 'From line has expected format' '\n>  \ttest_cmp from filtered\n>  '\n>  \n> +test_expect_success 'format-patch -o with no leading directories' '\n> +\trm -fr patches &&\n> +\tgit format-patch -o patches master..side &&\n> +\ttest $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n\nFor test case you write, please use the following pattern:\n\n\tgit rev-list master..side >list &&\n\ttest_line_count = $(ls patches | wc -l) list\n\nThe first benefit is that we get to take advantage of the\ntest_line_count function that's already written for us. The second is\nthat when we write tests, we shouldn't put Git commands in the upstream\nof a pipe because if they fail, their return codes will be lost and we\nwon't be able to fail the test properly.\n\n> +'\n> +\n> +test_expect_success 'format-patch -o with leading existing directories' '\n> +\tgit format-patch -o patches/side master..side &&\n> +\ttest $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)\n> +'\n> +\n> +test_expect_failure 'format-patch -o with leading non-existing directories' '\n> +\trm -fr patches &&\n> +\tgit format-patch -o patches/side master..side\n> +'\n\nAs above, I wouldn't really call this a bug in Git. I think we should\nleave this test case off until the next patch.\n\n> +\n>  test_expect_success 'format-patch format.outputDirectory option' '\n>  \ttest_config format.outputDirectory patches &&\n>  \trm -fr patches &&\n> -- \n> 2.23.0.11.g242cf7f110\n> \n"},{"id":"383319","messageId":"xmqqimp6d4xv.fsf@gitster-ct.c.googlers.com","threadId":"51960","inReplyTo":"d959e78af1cb7ef49bca970643b2136c436cd57d.1570051490.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 2/3] format-patch: create output directory including leading components","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-03T00:54:20Z","receivedAt":"2019-10-03T00:54:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n\nSquash these two into a single step.  If \"-o <output directory>\"\nforgets to create necessary leading directories, it is just a bug.\n\nThanks.\n"},{"id":"383320","messageId":"xmqqeezud4ss.fsf@gitster-ct.c.googlers.com","threadId":"51960","inReplyTo":"431f8a4e372feccf240b9c66c91248a6f53eab47.1570051490.git.bert.wesarg@googlemail.com","subject":"Re: [RFC PATCH 3/3] format-patch: use a command to generate the output directory name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-03T00:57:23Z","receivedAt":"2019-10-03T00:57:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bert Wesarg <bert.wesarg@googlemail.com> writes:\n\n> Having 'format.outputDirectory' is convenient, but being able to process\n> all produced patches via a wildcard command is even more so. I.e.,\n> using an argument like '<dir>/*'. Neither '-o' nor\n> 'format.outputDirectory' can be parameterized to produce a new unique\n> directory. Thus provide the new 'format.outputDirectoryCmd' configuration\n> to specify a command which does the job and puts the name to standard\n> output.\n>\n\nThe above does not interest me (a reader) enough, without the log\nmessage explaining why\n\n\tgit format-patch -o \"$(outdircmd)\"\n\nis not sufficient.\n\nThanks.\n"},{"id":"383333","messageId":"CAKPyHN0xqis9_Apwi4LmNuhO9aGQdZ4qRs_hcm2YUVLK391W_Q@mail.gmail.com","threadId":"51960","inReplyTo":"20191002214709.GA51809@generichostname","subject":"Re: [PATCH 1/3] format-patch: document and exercise that -o does only create the trailing directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-10-03T16:34:57Z","receivedAt":"2019-10-03T16:35:11Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Denton,\n\nOn Wed, Oct 2, 2019 at 11:47 PM Denton Liu <liu.denton@gmail.com> wrote:\n>\n> Hi Bert,\n>\n> > Subject: format-patch: document and exercise that -o does only create the trailing directory\n>\n> s/does only create/only creates/ ?\n>\n> Anyway, as a prepatory patch, I don't think that it's necessary. Maybe\n> it's just me but I assume that most tools create at most one directory\n> deep. Even mkdir won't created nested dirs unless you pass `-p`. I\n> dunno.\n>\n> On Wed, Oct 02, 2019 at 11:26:11PM +0200, Bert Wesarg wrote:\n> > Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> > ---\n> >  Documentation/config/format.txt    |  3 ++-\n> >  Documentation/git-format-patch.txt |  4 +++-\n> >  t/t4014-format-patch.sh            | 16 ++++++++++++++++\n> >  3 files changed, 21 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt\n> > index 414a5a8a9d..e17c5d6b0f 100644\n> > --- a/Documentation/config/format.txt\n> > +++ b/Documentation/config/format.txt\n> > @@ -80,7 +80,8 @@ format.coverLetter::\n> >\n> >  format.outputDirectory::\n> >       Set a custom directory to store the resulting files instead of the\n> > -     current working directory.\n> > +     current working directory. Only the trailing directory will be created\n> > +     though.\n> >\n> >  format.useAutoBase::\n> >       A boolean value which lets you enable the `--base=auto` option of\n> > diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\n> > index b9b97e63ae..fe7492353e 100644\n> > --- a/Documentation/git-format-patch.txt\n> > +++ b/Documentation/git-format-patch.txt\n> > @@ -66,7 +66,9 @@ 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> > +`format.outputDirectory` points elsewhere, use `-o .`. Note that only\n> > +the trailing directory will be created by Git, leading directories must\n> > +already exists.\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/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\n> > index ca7debf1d4..bf2715a503 100755\n> > --- a/t/t4014-format-patch.sh\n> > +++ b/t/t4014-format-patch.sh\n> > @@ -1632,6 +1632,22 @@ test_expect_success 'From line has expected format' '\n> >       test_cmp from filtered\n> >  '\n> >\n> > +test_expect_success 'format-patch -o with no leading directories' '\n> > +     rm -fr patches &&\n> > +     git format-patch -o patches master..side &&\n> > +     test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n>\n> For test case you write, please use the following pattern:\n>\n>         git rev-list master..side >list &&\n>         test_line_count = $(ls patches | wc -l) list\n>\n> The first benefit is that we get to take advantage of the\n> test_line_count function that's already written for us. The second is\n> that when we write tests, we shouldn't put Git commands in the upstream\n> of a pipe because if they fail, their return codes will be lost and we\n> won't be able to fail the test properly.\n\nthanks. I will ensure, that this follows your\ndl/format-patch-doc-test-cleanup topic.\n\nBert\n\n>\n> > +'\n> > +\n> > +test_expect_success 'format-patch -o with leading existing directories' '\n> > +     git format-patch -o patches/side master..side &&\n> > +     test $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)\n> > +'\n> > +\n> > +test_expect_failure 'format-patch -o with leading non-existing directories' '\n> > +     rm -fr patches &&\n> > +     git format-patch -o patches/side master..side\n> > +'\n>\n> As above, I wouldn't really call this a bug in Git. I think we should\n> leave this test case off until the next patch.\n>\n> > +\n> >  test_expect_success 'format-patch format.outputDirectory option' '\n> >       test_config format.outputDirectory patches &&\n> >       rm -fr patches &&\n> > --\n> > 2.23.0.11.g242cf7f110\n> >\n"}]}