From: Junio C Hamano Date: Mon, 25 Apr 2022 21:35:52 GMT Subject: Re: [PATCH 4/7] read-cache: set sparsity when index is new Message-ID: In-Reply-To: <64edbed0f95623e307371cfc3905786e5b0a02f3.1650908958.git.gitgitgadget@gmail.com> "Victoria Dye via GitGitGadget" writes: > From: Victoria Dye > > 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. Makes sense.