Signed-off-by: Nicolas Pitre <[email protected]>
---
packv4-parse.c | 25 +++++++++++++++++++++++++
packv4-parse.h | 2 ++
sha1_file.c | 2 +-
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/packv4-parse.c b/packv4-parse.c
index 04eab46..4c218d2 100644
--- a/packv4-parse.c
+++ b/packv4-parse.c
@@ -365,3 +365,28 @@ static int decode_entries(struct packed_git *p, struct
pack_window **w_curs,
return 0;
}
+
+void *pv4_get_tree(struct packed_git *p, struct pack_window **w_curs,
+ off_t offset, unsigned long size)
+{
+ unsigned long avail;
+ unsigned int nb_entries;
+ unsigned char *dst, *dcp;
+ const unsigned char *src, *scp;
+ int ret;
+
+ src = use_pack(p, w_curs, offset, &avail);
+ scp = src;
+ nb_entries = decode_varint(&scp);
+ if (scp == src)
+ return NULL;
+
+ dst = xmallocz(size);
+ dcp = dst;
+ ret = decode_entries(p, w_curs, offset, 0, nb_entries, &dcp, &size, 0);
+ if (ret < 0 || size != 0) {
+ free(dst);
+ return NULL;
+ }
+ return dst;
+}
diff --git a/packv4-parse.h b/packv4-parse.h
index 40aa75a..5f9d809 100644
--- a/packv4-parse.h
+++ b/packv4-parse.h
@@ -3,5 +3,7 @@
void *pv4_get_commit(struct packed_git *p, struct pack_window **w_curs,
off_t offset, unsigned long size);
+void *pv4_get_tree(struct packed_git *p, struct pack_window **w_curs,
+ off_t offset, unsigned long size);
#endif
diff --git a/sha1_file.c b/sha1_file.c
index b57d9f8..79e1293 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2177,7 +2177,7 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
if (type == OBJ_COMMIT) {
data = pv4_get_commit(p, &w_curs, curpos, size);
} else {
- die("no pack v4 tree parsing yet");
+ data = pv4_get_tree(p, &w_curs, curpos, size);
}
break;
}
--
1.8.4.38.g317e65b
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html