pr-1312/vdye/reset/handle-missing-dirs-v1
tagged this
04 Aug 20:46
While working on sparse index integration for 'git rm' [1], Shaoxuan found that removed sparse directories, when reset, would no longer be sparse. This was due to how 'unpack_trees()' determined whether a traversed directory was a sparse directory or not; it would only unpack an entry as a sparse directory if it existed in the index. However, if the sparse directory was removed, it would be treated like a non-sparse directory and its contents would be individually unpacked. To avoid this unnecessary traversal and keep the results of 'reset' as sparse as possible, the decision logic for whether a directory is sparse is changed to: * If the directory is a sparse directory in the index, unpack it. * If not, is the directory inside the sparse cone? If so, do not unpack it. * If the directory is outside the sparse cone, does it have any child entries in the index? If so, do not unpack it. * Otherwise, unpack the entry as a sparse directory. In the process of updating 'reset', a separate issue was found in 'checkout' where collapsed sparse directories did not have modified contents reported file-by-file. A similar bug was found with 'status' in 2c521b0e49 (status: fix nested sparse directory diff in sparse index, 2022-03-01), and 'checkout' was corrected the same way (setting the diff flag 'recursive' to 1). Thanks! * Victoria [1] https://lore.kernel.org/git/20220803045118.1243087-1-shaoxuan.yuan02@gmail.com/ Victoria Dye (4): checkout: fix nested sparse directory diff in sparse index oneway_diff: handle removed sparse directories cache.h: replace 'index_entry_exists()' with 'index_name_pos_sparse()' unpack-trees: handle missing sparse directories builtin/checkout.c | 1 + cache-tree.c | 2 +- cache.h | 15 ++-- diff-lib.c | 5 ++ read-cache.c | 4 +- t/t1092-sparse-checkout-compatibility.sh | 25 +++++++ unpack-trees.c | 88 +++++++++++++++++++++--- 7 files changed, 119 insertions(+), 21 deletions(-) base-commit: 4af7188bc97f70277d0f10d56d5373022b1fa385 Submitted-As: https://lore.kernel.org/git/pull.1312.git.1659645967.gitgitgadget@gmail.com
Assets 2
-
2022-08-04T20:46:07Z -
2022-08-04T20:46:07Z -