Patrick Steinhardt <ps@xxxxxx> writes: > 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?