summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-11-20 10:32:10 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-11-20 10:32:10 -0800
commit10022a6d02f10afada7990f232d184a7ebe82b90 (patch)
treed976802bd99cda8d9c6c59142c7ff644e0db69e8
parentMerge branch 'jk/maint-http-half-auth-fetch' (diff)
parentupdate-index/diff-index: use core.preloadindex to improve performance (diff)
downloadtgif-10022a6d02f10afada7990f232d184a7ebe82b90.tar.xz
Merge branch 'kb/preload-index-more'
Use preloadindex in more places, which has a nice speedup on systems with slow stat calls (and even on Linux). * kb/preload-index-more: update-index/diff-index: use core.preloadindex to improve performance
-rw-r--r--builtin/diff-index.c8
-rw-r--r--builtin/diff.c12
-rw-r--r--builtin/update-index.c1
3 files changed, 15 insertions, 6 deletions
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 2eb32bd9da..1c737f7921 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -41,9 +41,13 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
if (rev.pending.nr != 1 ||
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
usage(diff_cache_usage);
- if (!cached)
+ if (!cached) {
setup_work_tree();
- if (read_cache() < 0) {
+ if (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {
+ perror("read_cache_preload");
+ return -1;
+ }
+ } else if (read_cache() < 0) {
perror("read_cache");
return -1;
}
diff --git a/builtin/diff.c b/builtin/diff.c
index 9c70e40809..8c2af6cb43 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -130,8 +130,6 @@ static int builtin_diff_index(struct rev_info *revs,
usage(builtin_diff_usage);
argv++; argc--;
}
- if (!cached)
- setup_work_tree();
/*
* Make sure there is one revision (i.e. pending object),
* and there is no revision filtering parameters.
@@ -140,8 +138,14 @@ static int builtin_diff_index(struct rev_info *revs,
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
- if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
- perror("read_cache_preload");
+ if (!cached) {
+ setup_work_tree();
+ if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
+ perror("read_cache_preload");
+ return -1;
+ }
+ } else if (read_cache() < 0) {
+ perror("read_cache");
return -1;
}
return run_diff_index(revs, cached);
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 74986bf163..ada1dff846 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -593,6 +593,7 @@ struct refresh_params {
static int refresh(struct refresh_params *o, unsigned int flag)
{
setup_work_tree();
+ read_cache_preload(NULL);
*o->has_errors |= refresh_cache(o->flags | flag);
return 0;
}