reset: make --mixed sparse-aware
commit4d1cfc1351ffec47bba1318e9cd1ed13c5182951
authorVictoria Dye <vdye@github.com>
Mon, 29 Nov 2021 15:52:42 +0000 (29 15:52 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Nov 2021 20:51:26 +0000 (29 12:51 -0800)
treeb43e42dcb8810e21933fda314e39f98da4db75b9
parent20ec2d034cda1afef15a4dcc6e275d7a69413510
reset: make --mixed sparse-aware

Remove the `ensure_full_index` guard on `read_from_tree` and update `git
reset --mixed` to ensure it can use sparse directory index entries wherever
possible. Sparse directory entries are reset using `diff_tree_oid`, which
requires `change` and `add_remove` functions to process the internal
contents of the sparse directory. The `recursive` diff option handles cases
in which `reset --mixed` must diff/merge files that are nested multiple
levels deep in a sparse directory.

The use of pathspecs with `git reset --mixed` introduces scenarios in which
internal contents of sparse directories may be matched by the pathspec. In
order to reset *all* files in the repo that may match the pathspec, the
following conditions on the pathspec require index expansion before
performing the reset:

* "magic" pathspecs
* wildcard pathspecs that do not match only in-cone files or entire sparse
  directories
* literal pathspecs matching something outside the sparse checkout
  definition

Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/reset.c
t/t1092-sparse-checkout-compatibility.sh