]> git.ipfire.org Git - thirdparty/git.git/commit - read-cache.c
read-cache: set sparsity when index is new
authorVictoria Dye <vdye@github.com>
Tue, 10 May 2022 23:32:30 +0000 (23:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 May 2022 23:45:12 +0000 (16:45 -0700)
commit491df5f679f0381f529b967df25476ab944406ab
tree2ace1f4767d61a7441cdf8ff38039ad4727a7116
parentcfde4cd6ffdca7670b62a292b144425767fb1759
read-cache: set sparsity when index is new

When the index read in 'do_read_index()' does not exist on-disk, mark the
index "sparse" if the executing command does not require a full index and
sparse index is otherwise enabled.

Some commands (such as 'git stash -u') implicitly create a new index (when
the 'GIT_INDEX_FILE' variable points to a non-existent file) and perform
some operation on it. However, when this index is created, it isn't created
with the same sparsity settings as the repo index. As a result, while these
indexes may be sparse during the operation, they are always expanded before
being written to disk. We can avoid that expansion by defaulting the index
to "sparse", in which case it will only be expanded if the full index is
needed.

Note that the function 'set_new_index_sparsity()' is created despite having
only a single caller because additional callers will be added in a
subsequent patch.

Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
read-cache.c
t/t1092-sparse-checkout-compatibility.sh