]> git.ipfire.org Git - thirdparty/git.git/commit - revision.c
tree-walk: store object_id in a separate member
authorbrian m. carlson <sandals@crustytoothpaste.net>
Tue, 15 Jan 2019 00:39:44 +0000 (00:39 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jan 2019 17:57:41 +0000 (09:57 -0800)
commitea82b2a0857e3e0449bdce4e3987dee6adbc51ae
treeed064565c3b49c8636c36dd9ce2f5ef108066f0b
parentf55ac4311ad173529cbac7a619d422674a4252ad
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>
19 files changed:
builtin/grep.c
builtin/merge-tree.c
builtin/pack-objects.c
builtin/reflog.c
cache-tree.c
delta-islands.c
fsck.c
http-push.c
list-objects.c
match-trees.c
notes.c
packfile.c
revision.c
tree-diff.c
tree-walk.c
tree-walk.h
tree.c
unpack-trees.c
walker.c