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

[PATCH 4/4] archive: queue directories for all types of pathspecs

From
René Scharfe <l.s.r@web.de>
Date
Aug 19, 2017, 05:33 UTC
Message-ID
<0432c7cc-a2a5-12bd-bf65-a16186313d5b@web.de>
In-Reply-To
<887652a4-3f03-e2dd-2c68-cff4f7194898@web.de>

When read_tree_recursive() encounters a directory excluded by a pathspec then it enters it anyway because it might contain included entries. It calls the callback function before it is able to decide if the directory is actually needed.

For that reason git archive adds directories to a queue and writes entries for them only when it encounters the first child item -- but only if pathspecs with wildcards are used. Do the same for literal pathspecs as well, as the reasoning above applies to them, too. This prevents git archive from writing entries for excluded directories.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 archive.c               | 2 +-
 t/t5001-archive-attr.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/archive.c b/archive.c
index 1ab8d3a1d7..174c0555b6 100644
--- a/archive.c
+++ b/archive.c
@@ -123,7 +123,7 @@ static int check_attr_export_subst(const struct attr_check *check)
 
 static int should_queue_directories(const struct archiver_args *args)
 {
-	return args->pathspec.has_wildcard;
+	return args->pathspec.nr;
 }
 
 static int write_archive_entry(const unsigned char *sha1, const char *base,
diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh
index 897f6f06d5..e9aa97117a 100755
--- a/t/t5001-archive-attr.sh
+++ b/t/t5001-archive-attr.sh
@@ -73,7 +73,7 @@ test_expect_missing	archive-pathspec/ignored-by-tree
 test_expect_missing	archive-pathspec/ignored-by-tree.d
 test_expect_missing	archive-pathspec/ignored-by-tree.d/file
 test_expect_exists	archive-pathspec/ignored-by-worktree
-test_expect_missing	archive-pathspec/excluded-by-pathspec.d failure
+test_expect_missing	archive-pathspec/excluded-by-pathspec.d
 test_expect_missing	archive-pathspec/excluded-by-pathspec.d/file
 
 test_expect_success 'git archive with wildcard pathspec' '
-- 
2.14.1
Previous: René ScharfeNext: René Scharfe
Message 7 of 17 in “Bug?: git archive exclude pathspec and gitattributes export-ignore”
  1. David AdamAug 13, 2017
  2. René ScharfeAug 14, 2017
  3. David AdamAug 15, 2017
  4. René ScharfeAug 19, 2017
  5. 1/4 t5001: add tests for export-ignore attributes and exclude pathspecsRené Scharfe, Aug 19, 2017
  6. 2/4 archive: factor out helper functions for handling attributesRené Scharfe, Aug 19, 2017
  7. 4/4 archive: queue directories for all types of pathspecsRené Scharfe, Aug 19, 2017
  8. René ScharfeAug 19, 2017
  9. René ScharfeAug 19, 2017
  10. Junio C HamanoAug 19, 2017
  11. Jeff KingAug 20, 2017
  12. René ScharfeSep 12, 2017
  13. Jeff KingSep 13, 2017
  14. René ScharfeSep 13, 2017
  15. Stefan BellerAug 21, 2017
  16. Junio C HamanoAug 19, 2017
  17. 3/4 archive: don't queue excluded directoriesRené Scharfe, Aug 19, 2017

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.