René Scharfe <l.s.r@xxxxxx> writes: > 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@xxxxxx> > --- > archive.c | 2 +- > t/t5001-archive-attr.sh | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) This seems to break t/t5004-archive-corner-cases.sh though... expecting success: git archive --format=tar $root_tree -- sub >subtree-path.tar && make_dir extract && "$TAR" xf subtree-path.tar -C extract && check_dir extract sub --- expect 2017-08-19 16:56:49.761513537 +0000 +++ actual 2017-08-19 16:56:49.769513535 +0000 @@ -1,2 +1 @@ extract -extract/sub not ok 10 - archive empty subtree by direct pathspec > 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' '