Use a diff for iteration in index_update_all and index_add_all#3109
Conversation
|
This is great. I'll look over this more deeply shortly, and I'm very excited to do so. Until then, just a random thought that So this is very nice. Thanks for the nice monday morning surprise! |
|
Hm, that's an interesting point about the endings. Maybe we should take the crlf configuration into account in the preparation for the diff? |
|
Come to think of it, this new method is probably not correct for type changes, since it doesn't pass |
|
Sorry, I was a little vague earlier, I meant the current |
8c9adeb to
097ab0e
Compare
|
It did later think you might have been talking about the current code. I've updated the commit message and added TYPECHANGE to the things for diff to tell us about. |
We currently iterate over all the entries and re-add them to the index. While this provides correctness, it is wasteful as we try to re-insert files which have not changed. Instead, take a diff between the index and the worktree and only re-add those which we already know have changed.
Refactor so we look like the code we're replacing, which should also allow us to more easily inplement add-all.
Instead of going through each entry we have and re-adding, which may not even be correct for certain crlf options and has bad performance, use the function which performs a diff against the worktree and try to add and remove files from that list.
Without this option, we would not be able to catch exec bit changes.
097ab0e to
874cc35
Compare
Use a diff for iteration in index_update_all and index_add_all
Re-adding every entry means we hash data we already have hashed, which proves quite a bit slower than it has to be. We can know whether we need to re-calculate hashes by iterating over the entries a diff gives us, rather than every entry in the index.
This should resolve #2687