]> git.ipfire.org Git - thirdparty/git.git/commit
unpack-trees: compare sparse directories correctly
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 14 Jul 2021 13:12:31 +0000 (13:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2021 20:42:48 +0000 (13:42 -0700)
commitcd807a5cdabe5720071d91801dbc76faa8a643ba
tree68f9a867fd32a22c1a47c9bd1347342c6252fb5b
parent17a1bb570bcd165a3dc1c28c441bee45a941bb12
unpack-trees: compare sparse directories correctly

As we further integrate the sparse-index into unpack-trees, we need to
ensure that we compare sparse directory entries correctly with other
entries. This affects searching for an exact path as well as sorting
index entries.

Sparse directory entries contain the trailing directory separator. This
is important for the sorting, in particular. Thus, within
do_compare_entry() we stop using S_IFREG in all cases, since sparse
directories should use S_IFDIR to indicate that the comparison should
treat the entry name as a dirctory.

Within compare_entry(), it first calls do_compare_entry() to check the
leading portion of the name. When the input path is a directory name, we
could match exactly already. Thus, we should return 0 if we have an
exact string match on a sparse directory entry. The final check is a
length comparison between the strings.

Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
unpack-trees.c