Re: [PATCH] builtin-commit: fix partial-commit support
flat view
From: Kristian Høgsberg <hidden>
Date: 2016-06-15 22:43:52
On Sun, 2007-11-18 at 02:21 -0800, Junio C Hamano wrote:
When making a partial-commit, we need to prepare two index files, one to be used to write out the tree to be committed (temporary index) and the other to be used as the index file after the commit is made. The temporary index needs to be initialized to HEAD and then all the named paths on the command line need to be staged on top of the index. For this, running add_files_to_cache() that compares what is in the index and the paths given from the command line is not enough -- the comparison will miss the paths that the user previously ran "git add" to the index since the HEAD because the index reset to the HEAD would not know about them. The index file needs to get the same modification done when preparing the temporary index as described above. This implementation mimics the behaviour of the scripted version of git-commit. It first runs overlay_tree_on_cache(), which was stolen from ls-files with the earlier change, to get the list of paths that the user can potentially mean, and then uses pathspec_match() to find which ones the user meant. This list of paths is used to update both the temporary and the real index file.
Oh boy, this turns out to be much more involved than what I thought. Thanks for fixing up this part of builtin-commit.
Additionally: - remove the temporary index file .git/next-index-* after commit is done or aborted.
Hmm, I see the left-over next-index-* files too, but I though the lock file would be cleaned up automatically by the atexit handler? cheers, Kristian