Skip to content

Commit 4e1a7ba

Browse files
pcloudsgitster
authored andcommitted
rm: only refresh entries that we may touch
This gets rid of the whole tree cache refresh. Instead only path that we touch will get refreshed. We may still lstat() more than needed, but it'd be better playing safe. This potentially reduces a large number of lstat() on big trees. Take gentoo-x86 tree for example, which has roughly 80k files: Unmodified Git: $ time git rm --cached skel.ebuild rm 'skel.ebuild' real 0m1.441s user 0m0.821s sys 0m0.531s Modified Git: $ time ~/w/git/git rm --cached skel.ebuild rm 'skel.ebuild' real 0m0.941s user 0m0.828s sys 0m0.091s Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 688cd6d commit 4e1a7ba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin-rm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
169169

170170
if (read_cache() < 0)
171171
die("index file corrupt");
172-
refresh_cache(REFRESH_QUIET);
173172

174173
pathspec = get_pathspec(prefix, argv);
174+
refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL);
175+
175176
seen = NULL;
176177
for (i = 0; pathspec[i] ; i++)
177178
/* nothing */;

0 commit comments

Comments
 (0)