git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] format-patch: document and exercise that -o does only create the trailing directory

From
Bert Wesarg <bert.wesarg@googlemail.com>
Date
Oct 2, 2019, 21:26 UTC
Message-ID
<1aeacd8af4b83142f160c63be4746554e823cfc3.1570051490.git.bert.wesarg@googlemail.com>
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
 Documentation/config/format.txt    |  3 ++-
 Documentation/git-format-patch.txt |  4 +++-
 t/t4014-format-patch.sh            | 16 ++++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/Documentation/config/format.txt b/Documentation/config/format.txt
index 414a5a8a9d..e17c5d6b0f 100644
--- a/Documentation/config/format.txt
+++ b/Documentation/config/format.txt
@@ -80,7 +80,8 @@ format.coverLetter::
 
 format.outputDirectory::
 	Set a custom directory to store the resulting files instead of the
-	current working directory.
+	current working directory. Only the trailing directory will be created
+	though.
 
 format.useAutoBase::
 	A boolean value which lets you enable the `--base=auto` option of
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index b9b97e63ae..fe7492353e 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -66,7 +66,9 @@ 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 .`.
+`format.outputDirectory` points elsewhere, use `-o .`. Note that only
+the trailing directory will be created by Git, leading directories must
+already exists.
 
 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
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index ca7debf1d4..bf2715a503 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1632,6 +1632,22 @@ test_expect_success 'From line has expected format' '
 	test_cmp from filtered
 '
 
+test_expect_success 'format-patch -o with no leading directories' '
+	rm -fr patches &&
+	git format-patch -o patches master..side &&
+	test $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)
+'
+
+test_expect_success 'format-patch -o with leading existing directories' '
+	git format-patch -o patches/side master..side &&
+	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' '
+	rm -fr patches &&
+	git format-patch -o patches/side master..side
+'
+
 test_expect_success 'format-patch format.outputDirectory option' '
 	test_config format.outputDirectory patches &&
 	rm -fr patches &&
-- 
2.23.0.11.g242cf7f110
Next: Bert Wesarg
Message 1 of 7 in “format-patch: document and exercise that -o does only create the trailing directory”
  1. 1/3 format-patch: document and exercise that -o does only create the trailing directoryBert Wesarg, Oct 2, 2019
  2. 2/3 format-patch: create output directory including leading componentsBert Wesarg, Oct 2, 2019
  3. Junio C HamanoOct 3, 2019
  4. 3/3 format-patch: use a command to generate the output directory nameBert Wesarg, Oct 2, 2019
  5. Junio C HamanoOct 3, 2019
  6. Denton LiuOct 2, 2019
  7. Bert WesargOct 3, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.