[PATCH 1/1] unpack-trees: skip lstat based on fsmonitor
- From
Utsav Shah via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Oct 25, 2019, 15:23 UTC
- Message-ID
- <609c7c5047719a619ba22425dafc6ecd105e2cda.1572017008.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.424.git.1572017008.gitgitgadget@gmail.com>
From: Utsav Shah <utsav@dropbox.com>
git stash runs git reset --hard as its final step, which can be fairly slow on a large repository. This change lets us skip that if fsmonitor thinks those files aren't modified.
git stash goes from ~8s -> 2s on my repository after this change.
Signed-off-by: Utsav Shah <utsav@dropbox.com> --- unpack-trees.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/unpack-trees.c b/unpack-trees.c index 33ea7810d8..5d07a2d0ea 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -2384,7 +2384,8 @@ int oneway_merge(const struct cache_entry * const *src, if (old && same(old, a)) { int update = 0; - if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old)) { + if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old) && + !(old->ce_flags & CE_FSMONITOR_VALID)) { struct stat st; if (lstat(old->name, &st) || ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))
-- gitgitgadget