wt-status: expand added sparse directory entries
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 21 May 2021 11:59:40 +0000 (11:59 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sat, 22 May 2021 08:58:19 +0000 (17:58 +0900)
commitb025501e89694e43455f55146114b7b69d1150b9
tree2a994c832f39ab074ec8adddb09cbc87011f7f83
parentc4bc613ed7f3e085631a6678a09136f083296de6
wt-status: expand added sparse directory entries

It is difficult, but possible, to get into a state where we intend to
add a directory that is outside of the sparse-checkout definition. Add a
test to t1092-sparse-checkout-compatibility.sh that demonstrates this
using a combination of 'git reset --mixed' and 'git checkout --orphan'.

This test failed before because the output of 'git status
--porcelain=v2' would not match on the lines for folder1/:

* The sparse-checkout repo (with a full index) would output each path
  name that is intended to be added.

* The sparse-index repo would only output that "folder1/" is staged for
  addition.

The status should report the full list of files to be added, and so this
sparse-directory entry should be expanded to a full list when reaching
it inside the wt_status_collect_changes_initial() method. Use
read_tree_at() to assist.

Somehow, this loop over the cache entries was not guarded by
ensure_full_index() as intended.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1092-sparse-checkout-compatibility.sh
wt-status.c