show: integrate with the sparse index
commita37d14422a4edd4f95abbe9532f518127cd3ef69
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 26 Apr 2022 20:43:17 +0000 (26 20:43 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Apr 2022 20:56:38 +0000 (26 13:56 -0700)
treec083f3354ae9913829e7a3e1e350f985cb081f05
parenta9e0a49dc427a8c442619e7937abeb1af1f35ff2
show: integrate with the sparse index

The 'git show' command can take an input to request the state of an
object in the index. This can lead to parsing the index in order to load
a specific file entry. Without the change presented here, a sparse index
would expand to a full one, taking much longer than usual to access a
simple file.

There is one behavioral change that happens here, though: we now can
find a sparse directory entry within the index! Commands that previously
failed because we could not find an entry in the worktree or index now
succeed because we _do_ find an entry in the index.

There might be more work to do to make other situations succeed when
looking for an indexed tree, perhaps by looking at or updating the
cache-tree extension as needed. These situations include having a full
index or asking for a directory that is within the sparse-checkout cone
(and hence is not a sparse directory entry in the index).

For now, we demonstrate how the sparse index integration is extremely
simple for files outside of the cone as well as directories within the
cone. A later change will resolve this behavior around sparse
directories.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/log.c
t/t1092-sparse-checkout-compatibility.sh