Skip to content

Commit

Permalink
diff.c: fix "size cache" handling.
Browse files Browse the repository at this point in the history
We broke the size-cache handling when we changed the function
signature of sha1_object_info() in 21666f1.  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>
  • Loading branch information
Junio C Hamano committed May 4, 2007
1 parent 9cf0430 commit cdda666
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit cdda666

Please sign in to comment.