]> git.99rst.org Git - git.git/commit
reset: stop assuming that the caller passes in a clean index
authorPatrick Steinhardt <redacted>
Wed, 1 Jul 2026 11:35:35 +0000 (13:35 +0200)
committerJunio C Hamano <redacted>
Fri, 3 Jul 2026 17:32:47 +0000 (10:32 -0700)
commite420d7b0ac2d5179c156ca61bc204d8b2661c6ba
tree8c856e8478d23ab551193137e8112e56547c9f87
parent1280e92d1622484c97facb840f2788166171d460
reset: stop assuming that the caller passes in a clean index

In 652bd0211d (rebase: use 'skip_cache_tree_update' option, 2022-11-10),
we updated `reset_working_tree()` to stop updating the index tree cache.
This was done as a performance optimization: the function is only called
by "sequencer.c" and "rebase.c", both of which assume a clean index
before they perform their operation, so we know that the end result will
be a clean index, too. Consequently, we can skip recomputing the cache
as we can instead use `prime_cache_tree()` directly.

In a subsequent commit we're about to add a new caller though where the
assumption doesn't hold anymore: the index may be dirty before calling
`reset_working_tree()`, and consequently we cannot prime the cache with
a given tree anymore as the index and tree will mismatch.

Adapt the logic so that we only skip the cache tree update in case we're
doing a hard reset. While we could introduce logic that only skips the
update in case the incoming index was dirty already, that doesn't really
feel worth it: after all, the mentioned commit says itself that the
performance improvement was negligible anyway.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
reset.c
git clone https://git.99rst.org/PROJECT