Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speed up creation of temporary index when autofixing staged changes
Instead of using "git read-tree" to create an entirely new index, start by copying the old index file, and then subtracting the changes made since HEAD. This greatly improves performance on a monorepo of 30k files, where my .git/index file is around 5MB. A run of git-autofixup with a single staged line and some 100 commits in the topic branch goes from 6 seconds to merely 0.5. Take care to support the case where a user has set their own GIT_INDEX_FILE. This is a bit awkward because we apply it's default value ($GIT_DIR/index) in the callee but I couldn't make it work in the caller. In a previous attempt I tried to remove the temporary index, see krobelus@optimize-staged-changes but that approach made it hard to reliably preserve user data in failure scenarios - a little copying is much safer.
- Loading branch information