]> git.ipfire.org Git - thirdparty/git.git/commit - wt-status.c
wt-status: expand added sparse directory entries
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 14 Jul 2021 13:12:38 +0000 (13:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jul 2021 20:42:49 +0000 (13:42 -0700)
commitfe0d576153117953189e03d6c2c09445ccad4977
treefa46bc9296b60cb9991acb5e900d0900637db1e2
parentd76723ee5313d0176e8777af4aa104d7562543c1
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.

Reviewed-by: Elijah Newren <newren@gmail.com>
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