]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
read-tree: narrow scope of index expansion for '--prefix'
authorVictoria Dye <vdye@github.com>
Tue, 1 Mar 2022 20:24:29 +0000 (20:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Mar 2022 20:36:01 +0000 (12:36 -0800)
commit749703924121b9eb2750b4313b2c769113c8b310
tree203f2340d0d22de30932070c2b1a93ffcfcbf52a
parent2c66a7c8cefa27ef56efbc76bdfe13696b9dac3a
read-tree: narrow scope of index expansion for '--prefix'

When 'git read-tree' is provided with a prefix, expand the index only if the
prefix is equivalent to a sparse directory or contained within one. If the
index is not expanded in these cases, 'ce_in_traverse_path' will indicate
that the relevant sparse directory is not in the prefix/traverse path,
skipping past it and not unpacking the appropriate tree(s).

If the prefix is in-cone, its sparse subdirectories (if any) will be
traversed correctly without index expansion.

The behavior of 'git read-tree' with prefixes 1) inside of cone, 2) equal to
a sparse directory, and 3) inside a sparse directory are all tested as part
of the 't/t1092-sparse-checkout-compatibility.sh' test 'read-tree --prefix',
ensuring that the sparse index case works the way it did prior to this
change as well as matching non-sparse index sparse-checkout.

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/read-tree.c
t/t1092-sparse-checkout-compatibility.sh
unpack-trees.c