path: root/cache-tree.c
diff options
authorbrian m. carlson <>2019-01-15 00:39:44 (GMT)
committerJunio C Hamano <>2019-01-15 17:57:41 (GMT)
commitea82b2a0857e3e0449bdce4e3987dee6adbc51ae (patch)
treeed064565c3b49c8636c36dd9ce2f5ef108066f0b /cache-tree.c
parentf55ac4311ad173529cbac7a619d422674a4252ad (diff)
tree-walk: store object_id in a separate member
When parsing a tree, we read the object ID directly out of the tree buffer. This is normally fine, but such an object ID cannot be used with oidcpy, which copies GIT_MAX_RAWSZ bytes, because if we are using SHA-1, there may not be that many bytes to copy. Instead, store the object ID in a separate struct member. Since we can no longer efficiently compute the path length, store that information as well in struct name_entry. Ensure we only copy the object ID into the new buffer if the path length is nonzero, as some callers will pass us an empty path with no object ID following it, and we will not want to read past the end of the buffer. Signed-off-by: brian m. carlson <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'cache-tree.c')
1 files changed, 2 insertions, 2 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 190c6e5..98cb665 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -675,7 +675,7 @@ static void prime_cache_tree_rec(struct repository *r,
else {
struct cache_tree_sub *sub;
- struct tree *subtree = lookup_tree(r, entry.oid);
+ struct tree *subtree = lookup_tree(r, &entry.oid);
if (!subtree->object.parsed)
sub = cache_tree_sub(it, entry.path);
@@ -724,7 +724,7 @@ int cache_tree_matches_traversal(struct cache_tree *root,
it = find_cache_tree_from_traversal(root, info);
it = cache_tree_find(it, ent->path);
- if (it && it->entry_count > 0 && oideq(ent->oid, &it->oid))
+ if (it && it->entry_count > 0 && oideq(&ent->oid, &it->oid))
return it->entry_count;
return 0;