diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2016-04-22 18:12:09 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2016-04-22 18:12:09 +0200 |
commit | 5fe874632df9c70022e2ea47a01876780f8b3d02 (patch) | |
tree | 5ae8cb5782df1b75e7cd6ec89c1df2cbb984f01f /src/pack.c | |
parent | 1dc449105b329ea4f8ea9982bc2da869d231c04a (diff) | |
download | libgit2-cmn/read-only-size.tar.gz |
odb: allow asking for the size alonecmn/read-only-size
Reading a packed object's type can be expensive if it's deeply
chained. Allow a caller to skip that part of the lookup if they don't
care or know the type through other means.
Diffstat (limited to 'src/pack.c')
-rw-r--r-- | src/pack.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pack.c b/src/pack.c index e7003e66d..0578d852e 100644 --- a/src/pack.c +++ b/src/pack.c @@ -513,6 +513,13 @@ int git_packfile_resolve_header( } else *size_p = size; + /* + * If the caller isn't interested in the type, we can return + * now instead of trying to resolve the deltas. + */ + if (type_p == NULL) + return 0; + while (type == GIT_OBJ_OFS_DELTA || type == GIT_OBJ_REF_DELTA) { curpos = base_offset; error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos); |