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 byba053ea96c
(archive: do not read .gitattributes in working directory, 2009-04-18) andd5f53d6d6f
(archive: complain about path specs that don't match anything, 2009-12-12). But when attribute matching was added to pathspec inb0db704652
(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>
This commit is contained in:

committed by
Junio C Hamano

parent
39bf06adf9
commit
296743a7ca
@ -136,6 +136,8 @@ test_expect_success 'end-of-options is correctly eaten' '
|
||||
|
||||
test_expect_success 'populate workdir' '
|
||||
mkdir a &&
|
||||
echo "a files_named_a" >.gitattributes &&
|
||||
git add .gitattributes &&
|
||||
echo simple textfile >a/a &&
|
||||
ten=0123456789 &&
|
||||
hundred="$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten" &&
|
||||
@ -449,6 +451,16 @@ test_expect_success 'allow pathspecs that resolve to the current directory' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'attr pathspec in bare repo' '
|
||||
test_expect_code 0 git --git-dir=bare.git archive -v HEAD \
|
||||
":(attr:files_named_a)" >/dev/null 2>actual &&
|
||||
cat >expect <<-\EOF &&
|
||||
a/
|
||||
a/a
|
||||
EOF
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
# Pull the size and date of each entry in a tarfile using the system tar.
|
||||
#
|
||||
# We'll pull out only the year from the date; that avoids any question of
|
||||
|
Reference in New Issue
Block a user