[PATCH] Find size of SHA1 object without inflating everything.

This adds sha1_file_size() helper function and uses it in the
rename/copy similarity estimator.  The helper function handles
deltified object as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Junio C Hamano
2005-06-02 15:20:54 -07:00
committed by Linus Torvalds
parent 4a62b61939
commit 65c2e0c349
3 changed files with 67 additions and 5 deletions

11
diff.c
View File

@ -333,7 +333,6 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
close(fd);
}
else {
/* We cannot do size only for SHA1 blobs */
char type[20];
struct sha1_size_cache *e;
@ -343,11 +342,13 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
s->size = e->size;
return 0;
}
if (!sha1_file_size(s->sha1, &s->size))
locate_size_cache(s->sha1, s->size);
}
else {
s->data = read_sha1_file(s->sha1, type, &s->size);
s->should_free = 1;
}
s->data = read_sha1_file(s->sha1, type, &s->size);
s->should_free = 1;
if (s->data && size_only)
locate_size_cache(s->sha1, s->size);
}
return 0;
}