@@ -80,8 +80,7 @@ format.coverLetter::
format.outputDirectory::
Set a custom directory to store the resulting files instead of the
- current working directory. Only the trailing directory will be created
- though.
+ current working directory. All directory components will be created.
format.useAutoBase::
A boolean value which lets you enable the `--base=auto` option of
@@ -66,9 +66,8 @@ they are created in the current working directory. The default path
can be set with the `format.outputDirectory` configuration option.
The `-o` option takes precedence over `format.outputDirectory`.
To store patches in the current working directory even when
-`format.outputDirectory` points elsewhere, use `-o .`. Note that only
-the trailing directory will be created by Git, leading directories must
-already exists.
+`format.outputDirectory` points elsewhere, use `-o .`. All directory
+components will be created.
By default, the subject of a single patch is "[PATCH] " followed by
the concatenation of lines from the commit message up to the first blank
@@ -1769,6 +1769,14 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.diffopt.use_color = GIT_COLOR_NEVER;
if (use_stdout)
die(_("standard output, or directory, which one?"));
+ switch (safe_create_leading_directories_const(output_directory)) {
+ case SCLD_OK:
+ case SCLD_EXISTS:
+ break;
+ default:
+ die(_("could not create leading directories "
+ "of '%s'"), output_directory);
+ }
if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
die_errno(_("could not create directory '%s'"),
output_directory);
@@ -1643,9 +1643,10 @@ test_expect_success 'format-patch -o with leading existing directories' '
test $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)
'
-test_expect_failure 'format-patch -o with leading non-existing directories' '
+test_expect_success 'format-patch -o with leading non-existing directories' '
rm -fr patches &&
- git format-patch -o patches/side master..side
+ git format-patch -o patches/side master..side &&
+ test $(git rev-list master..side | wc -l) -eq $(ls patches/side | wc -l)
'
test_expect_success 'format-patch format.outputDirectory option' '
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> --- Documentation/config/format.txt | 3 +-- Documentation/git-format-patch.txt | 5 ++--- builtin/log.c | 8 ++++++++ t/t4014-format-patch.sh | 5 +++-- 4 files changed, 14 insertions(+), 7 deletions(-)