summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-06-02 22:20:54 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-02 22:48:33 (GMT)
commit65c2e0c349aa5c7f605defb52dc67f1b3658a1b9 (patch)
tree011b8aba6186497e2eece190bb560165a9b44f8f /diff.c
parent4a62b61939396c512bd7592f800110bddf45af72 (diff)
downloadgit-65c2e0c349aa5c7f605defb52dc67f1b3658a1b9.zip
git-65c2e0c349aa5c7f605defb52dc67f1b3658a1b9.tar.gz
git-65c2e0c349aa5c7f605defb52dc67f1b3658a1b9.tar.bz2
[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>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/diff.c b/diff.c
index 7cf40da..5513632 100644
--- a/diff.c
+++ b/diff.c
@@ -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;
}