diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2019-01-15 00:39:44 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-15 09:57:41 -0800 |
commit | ea82b2a0857e3e0449bdce4e3987dee6adbc51ae (patch) | |
tree | ed064565c3b49c8636c36dd9ce2f5ef108066f0b /builtin/reflog.c | |
parent | match-trees: use hashcpy to splice trees (diff) | |
download | tgif-ea82b2a0857e3e0449bdce4e3987dee6adbc51ae.tar.xz |
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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/reflog.c')
-rw-r--r-- | builtin/reflog.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/reflog.c b/builtin/reflog.c index 64a8df4f25..1f1010e2d9 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -94,8 +94,8 @@ static int tree_is_complete(const struct object_id *oid) init_tree_desc(&desc, tree->buffer, tree->size); complete = 1; while (tree_entry(&desc, &entry)) { - if (!has_sha1_file(entry.oid->hash) || - (S_ISDIR(entry.mode) && !tree_is_complete(entry.oid))) { + if (!has_sha1_file(entry.oid.hash) || + (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) { tree->object.flags |= INCOMPLETE; complete = 0; } |