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

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

From
René Scharfe <l.s.r@web.de>
Date
Aug 19, 2017, 16:58 UTC
Message-ID
<798212ae-ffb8-2ffb-8b59-fa307424b48a@web.de>
In-Reply-To
<33fa4f08-8f06-5a98-e492-3f05cc742555@web.de>
Am 19.08.2017 um 18:53 schrieb René Scharfe:
Show 13 quoted lines
> Am 19.08.2017 um 07:33 schrieb René Scharfe:
>> 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.
> 
> This breaks the test "archive empty subtree with no pathspec" in t5004 by
No, it's "archive empty subtree by direct pathspec" that's broken.  Gah!
Show 42 quoted lines
> omitting the empty directory from the archive.  Sorry for missing that!
> 
> This is kind of a bonus patch, so please discard it for now; the first
> three are OK IMHO.
> 
> A better version of this patch would at least update t5004 as well, but
> there might be a better way.
> 
>>
>> 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' '
>>
Previous: René ScharfeNext: Junio C Hamano
Message 9 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.