From: Junio C Hamano Date: Thu, 3 May 2007 20:00:43 +0000 (-0700) Subject: diff.c: fix "size cache" handling. X-Git-Tag: v1.5.2-rc2~5^2~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cdda666201710dcf50d7ebee804aac65fdec32fd;p=git.git 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 --- diff --git a/diff.c b/diff.c index d8f9242ea..b28933f87 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 {