Re: [PATCH RFC v2 05/16] cache-tree: allow writing in-memory index as tree
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 25, 2025, 16:38 UTC
- Message-ID
- <xmqqjz2rs6fk.fsf@gitster.g>
- In-Reply-To
- <20250824-b4-pks-history-builtin-v2-5-964ac12f65bd@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 7 quoted lines
> The function `write_in_core_index_as_tree()` takes a repository and > writes its index into a tree object. What this function cannot do though > is to take an _arbitrary_ in-memory index. > > Introduce a new `struct index_state` parameter so that the caller can > pass a different index than the one belonging to the repository. This > will be used in a subsequent commit.
Nice.
I wonder if this would also allow us to simplify the code paths for "git commit -o <pathspec>", where we use a separate temporary index that gets populated afresh from HEAD, grab the new snapshot for the paths that match the pathspec, and write it out as a tree to be wrapped in the new commit (and then the real index is also updated at these same paths).
I guess the code paths need to expose what is in the temporary index to hooks, which means the index file needs to be written out to an actual on-disk file, so the picture would be a bit different?