summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-05-03 20:00:43 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-05-04 05:12:40 (GMT)
commitcdda666201710dcf50d7ebee804aac65fdec32fd (patch)
treea10bca66929a8a81dea529ffecfc670297207c78 /diff.c
parent9cf04301b182c4c57d62ea63554d109db613f9d3 (diff)
downloadgit-cdda666201710dcf50d7ebee804aac65fdec32fd.zip
git-cdda666201710dcf50d7ebee804aac65fdec32fd.tar.gz
git-cdda666201710dcf50d7ebee804aac65fdec32fd.tar.bz2
diff.c: fix "size cache" handling.
We broke the size-cache handling when we changed the function signature of sha1_object_info() in 21666f1a. We obviously wanted to cache the size we obtained when sha1_object_info() succeeded, not when it failed. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index d8f9242..b28933f 100644
--- a/diff.c
+++ b/diff.c
@@ -1468,14 +1468,15 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
enum object_type type;
struct sha1_size_cache *e;
+ if (size_only && use_size_cache &&
+ (e = locate_size_cache(s->sha1, 1, 0)) != NULL) {
+ s->size = e->size;
+ return 0;
+ }
+
if (size_only) {
- e = locate_size_cache(s->sha1, 1, 0);
- if (e) {
- s->size = e->size;
- return 0;
- }
type = sha1_object_info(s->sha1, &s->size);
- if (type < 0)
+ if (use_size_cache && 0 < type)
locate_size_cache(s->sha1, 0, s->size);
}
else {