]> git.ipfire.org Git - thirdparty/git.git/commit
archive: load index before pathspec checks
authorRené Scharfe <l.s.r@web.de>
Sat, 21 Sep 2024 20:23:39 +0000 (22:23 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Sep 2024 16:47:20 +0000 (09:47 -0700)
commit296743a7caf99f816cec4e6992690151fdfcdcd5
tree81c8fcd0cd785d63079e25c7a4284cc05f25756f
parent39bf06adf96da25b87c9aa7d35a32ef3683eb4a4
archive: load index before pathspec checks

git archive checks whether pathspec arguments match anything to avoid
surprises due to typos and later loads the index to get attributes.

This order was OK when these features were introduced by ba053ea96c
(archive: do not read .gitattributes in working directory, 2009-04-18)
and d5f53d6d6f (archive: complain about path specs that don't match
anything, 2009-12-12).

But when attribute matching was added to pathspec in b0db704652
(pathspec: allow querying for attributes, 2017-03-13), the pathspec
checker in git archive did not support it fully, because it lacks the
attributes from the index.

Load the index earlier, before the pathspec check, to support attr
pathspecs.

Reported-by: Ronan Pigott <ronan@rjp.ie>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
archive.c
t/t5000-tar-tree.sh