Re: [PATCH v4 04/10] sparse-index: use WRITE_TREE_MISSING_OK
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Aug 30, 2021, 13:19 UTC
- Message-ID
- <2870fcb8-a356-c2c2-d084-b560326e1ad4@gmail.com>
- In-Reply-To
- <CABPp-BFcySug2kSvxT7YdJ1Oorza5AfxKPJgMBE2wN8qOw+=Eg@mail.gmail.com>
On 8/27/2021 5:33 PM, Elijah Newren wrote:
Show 22 quoted lines
> On Tue, Aug 24, 2021 at 2:51 PM Derrick Stolee via GitGitGadget > <gitgitgadget@gmail.com> wrote: >> >> From: Derrick Stolee <dstolee@microsoft.com> >> >> When updating the cache tree in convert_to_sparse(), the >> WRITE_TREE_MISSING_OK flag indicates that trees might be computed that >> do not already exist within the object database. > > Okay. > >> This happens in cases >> such as 'git add' creating new trees that it wants to store in >> anticipation of a following 'git commit'. > > This doesn't make any sense to me. Does 'git add' call > convert_to_sparse()? I don't see why it would; wouldn't the calls to > convert_to_sparse() come via sparse-checkout init/set commands? If > I'm correct on that, and 'git add' wants to create new trees, then by > the time convert_to_sparse() is called in some subsequent git > operation, then convert_to_sparse would already have the trees it > needs.
If someone adds a change outside the sparse-checkout cone, then the index is expanded in-memory, then is converted to sparse when the index is written again.
Show 6 quoted lines
> I thought the reason you would need this is someone modified and > staged a change to a file underneath a directory that will be > sparsified away; at the time of convert_to_sparse(), a tree object may > not have yet been written for the new tree with the newly modified > file (because those tend to be written at commit time), but you'd need > it at the time you sparsified.
Yes. I think we are trying to say the same thing.
Thanks, -Stolee