]> git.ipfire.org Git - thirdparty/git.git/commit
read-cache: expand on query into sparse-directory entry
authorDerrick Stolee <dstolee@microsoft.com>
Thu, 1 Apr 2021 01:49:40 +0000 (01:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Apr 2021 20:46:30 +0000 (13:46 -0700)
commit95e0321c4dbb81eca5dc1c6f96b176b00a0368d7
treee4865809318fdd60f9777006278ccdb635e1327d
parent847a9e5d4f876646e128c89f0818b1a8ce792509
read-cache: expand on query into sparse-directory entry

Callers to index_name_pos() or index_name_stage_pos() have a specific
path in mind. If that happens to be a path with an ancestor being a
sparse-directory entry, it can lead to unexpected results.

In the case that we did not find the requested path, check to see if the
position _before_ the inserted position is a sparse directory entry that
matches the initial segment of the input path (including the directory
separator at the end of the directory name). If so, then expand the
index to be a full index and search again. This expansion will only
happen once per index read.

Future enhancements could be more careful to expand only the necessary
sparse directory entry, but then we would have a special "not fully
sparse, but also not fully expanded" mode that could affect writing the
index to file. Since this only occurs if a specific file is requested
outside of the sparse checkout definition, this is unlikely to be a
common situation.

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