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>
Junio C Hamano committed
May 3, 2007 at 13:00 UTC
cdda666201710dcf50d7ebee804aac65fdec32fd
1 file changed
+7
-6
diff.c
+7
-6
@@ -1468,14 +1468,15 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
1468
enum object_type type;
1469
struct sha1_size_cache *e;
1470
1471
+ if (size_only && use_size_cache &&
1472
+ (e = locate_size_cache(s->sha1, 1, 0)) != NULL) {
1473
+ s->size = e->size;
1474
+ return 0;
1475
+ }
1476
+
1477
if (size_only) {
1472
- e = locate_size_cache(s->sha1, 1, 0);
1473
- if (e) {
1474
- s->size = e->size;
1475
- return 0;
1476
- }
1478
type = sha1_object_info(s->sha1, &s->size);
1478
- if (type < 0)
1479
+ if (use_size_cache && 0 < type)
1480
locate_size_cache(s->sha1, 0, s->size);
1481
}
1482
else {