Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-01-15 03:39:44 +0300
committerJunio C Hamano <gitster@pobox.com>2019-01-15 20:57:41 +0300
commitea82b2a0857e3e0449bdce4e3987dee6adbc51ae (patch)
treeed064565c3b49c8636c36dd9ce2f5ef108066f0b /tree-walk.h
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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree-walk.h')
-rw-r--r--tree-walk.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/tree-walk.h b/tree-walk.h
index 196831007e..08d349c54f 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -1,11 +1,14 @@
#ifndef TREE_WALK_H
#define TREE_WALK_H
+#include "cache.h"
+
struct strbuf;
struct name_entry {
- const struct object_id *oid;
+ struct object_id oid;
const char *path;
+ int pathlen;
unsigned int mode;
};
@@ -19,12 +22,12 @@ static inline const struct object_id *tree_entry_extract(struct tree_desc *desc,
{
*pathp = desc->entry.path;
*modep = desc->entry.mode;
- return desc->entry.oid;
+ return &desc->entry.oid;
}
static inline int tree_entry_len(const struct name_entry *ne)
{
- return (const char *)ne->oid - ne->path - 1;
+ return ne->pathlen;
}
/*