diff options
author | Carlos Martín Nieto <cmn@elego.de> | 2011-07-26 12:44:06 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-09-27 14:33:18 +0200 |
commit | acd31b4ad6b3bb3e3048fe3b4d7005b9a4a770e5 (patch) | |
tree | 30a27cc3bc3ec29d12c9b3973f3e2124fa65112c /src/tree-cache.c | |
parent | b183ffe77ee0f81d51019ed46cd10fa0a9a353ac (diff) | |
download | libgit2-acd31b4ad6b3bb3e3048fe3b4d7005b9a4a770e5.tar.gz |
tree cache: correctly handle invalidated trees
The fix introduced in a02fc2cd1 (2011-05-24; index: correctly parse
invalidated TREE extensions) threw out the rest of the data in the
extension if it found an invalidated entry. This was the result of
incorrect reading of the documentation.
Insted, keep reading the extension, as there may be cached data we can
use.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Diffstat (limited to 'src/tree-cache.c')
-rw-r--r-- | src/tree-cache.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/tree-cache.c b/src/tree-cache.c index 9f1431258..2e6e5f103 100644 --- a/src/tree-cache.c +++ b/src/tree-cache.c @@ -45,16 +45,6 @@ static int read_tree_internal(git_tree_cache **out, goto cleanup; } - /* Invalidated TREE. Free the tree but report success */ - if (count == -1) { - /* FIXME: return buffer_end or the end position for - * this single tree entry */ - *buffer_in = buffer_end; - *out = NULL; - git_tree_cache_free(tree); /* Needs to be done manually */ - return GIT_SUCCESS; - } - tree->entries = count; if (*buffer != ' ' || ++buffer >= buffer_end) { @@ -76,14 +66,17 @@ static int read_tree_internal(git_tree_cache **out, goto cleanup; } - /* 160-bit SHA-1 for this tree and it's children */ - if (buffer + GIT_OID_RAWSZ > buffer_end) { - error = GIT_EOBJCORRUPTED; - goto cleanup; - } + /* The SHA1 is only there if it's not invalidated */ + if (tree->entries >= 0) { + /* 160-bit SHA-1 for this tree and it's children */ + if (buffer + GIT_OID_RAWSZ > buffer_end) { + error = GIT_EOBJCORRUPTED; + goto cleanup; + } - git_oid_fromraw(&tree->oid, (const unsigned char *)buffer); - buffer += GIT_OID_RAWSZ; + git_oid_fromraw(&tree->oid, (const unsigned char *)buffer); + buffer += GIT_OID_RAWSZ; + } /* Parse children: */ if (tree->children_count > 0) { |