]> git.ipfire.org Git - thirdparty/git.git/commit - sparse-index.c
sparse-index: partially expand directories
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 23 May 2022 13:48:43 +0000 (13:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 May 2022 18:08:21 +0000 (11:08 -0700)
commit0243930af40f1ede50598c7de0965bdbe6fcbe30
treef05d8985f289129d6af206935dd2ed09a693a58a
parent2d443389fddf1b9b50664669b55c701a53f12eb2
sparse-index: partially expand directories

The expand_to_pattern_list() method expands sparse directory entries
to their list of contained files when either the pattern list is NULL or
the directory is contained in the new pattern list's cone mode patterns.

It is possible that the pattern list has a recursive match with a
directory 'A/B/C/' and so an existing sparse directory 'A/B/' would need
to be expanded. If there exists a directory 'A/B/D/', then that
directory should not be expanded and instead we can create a sparse
directory.

To implement this, we plug into the add_path_to_index() callback for the
call to read_tree_at(). Since we now need access to both the index we
are writing and the pattern list we are comparing, create a 'struct
modify_index_context' to use as a data transfer object. It is important
that we use the given pattern list since we will use this pattern list
to change the sparse-checkout patterns and cannot use
istate->sparse_checkout_patterns.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sparse-index.c