From 688cd6d2b9335f2ac20d02996215a0e6da1779b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 14 Jan 2010 22:02:21 +0700 Subject: status: only touch path we may need to check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch gets rid of whole-tree cache refresh and untracked file search. Instead only specified path will be looked at. Again some numbers on gentoo-x86, ~80k files: Unmodified Git: $ time git st eclass/ nothing to commit (working directory clean) real 0m3.211s user 0m1.977s sys 0m1.135s Modified Git: $ time ~/w/git/git st eclass/ nothing to commit (working directory clean) real 0m1.587s user 0m1.426s sys 0m0.111s Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano diff --git a/builtin-commit.c b/builtin-commit.c index 592b103..d5d8eb6 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -1023,7 +1023,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) s.pathspec = get_pathspec(prefix, argv); read_cache(); - refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED); + refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL); s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0; s.in_merge = in_merge; wt_status_collect(&s); diff --git a/wt-status.c b/wt-status.c index 5d56988..65feb29 100644 --- a/wt-status.c +++ b/wt-status.c @@ -343,7 +343,7 @@ static void wt_status_collect_untracked(struct wt_status *s) DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; setup_standard_excludes(&dir); - fill_directory(&dir, NULL); + fill_directory(&dir, s->pathspec); for (i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (!cache_name_is_other(ent->name, ent->len)) -- cgit v0.10.2-6-g49f6 From 4e1a7baa2e466afded9ff50b9a4539b24dbd3584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sun, 17 Jan 2010 15:43:13 +0700 Subject: rm: only refresh entries that we may touch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano diff --git a/builtin-rm.c b/builtin-rm.c index 57975db..f3772c8 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -169,9 +169,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix) if (read_cache() < 0) die("index file corrupt"); - refresh_cache(REFRESH_QUIET); pathspec = get_pathspec(prefix, argv); + refresh_index(&the_index, REFRESH_QUIET, pathspec, NULL, NULL); + seen = NULL; for (i = 0; pathspec[i] ; i++) /* nothing */; -- cgit v0.10.2-6-g49f6