MCPcopy Index your code
hub / github.com/git/git / decode_tree_entry

Function decode_tree_entry

tree-walk.c:17–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "read-cache-ll.h"
16
17static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
18{
19 const char *path;
20 unsigned int len;
21 uint16_t mode;
22 const unsigned hashsz = desc->algo->rawsz;
23
24 if (size < hashsz + 3 || buf[size - (hashsz + 1)]) {
25 strbuf_addstr(err, _("too-short tree object"));
26 return -1;
27 }
28
29 path = parse_mode(buf, &mode);
30 if (!path) {
31 strbuf_addstr(err, _("malformed mode in tree entry"));
32 return -1;
33 }
34 if (!*path) {
35 strbuf_addstr(err, _("empty filename in tree entry"));
36 return -1;
37 }
38 len = strlen(path) + 1;
39
40 /* Initialize the descriptor entry */
41 desc->entry.path = path;
42 desc->entry.mode = (desc->flags & TREE_DESC_RAW_MODES) ? mode : canon_mode(mode);
43 desc->entry.pathlen = len - 1;
44 oidread(&desc->entry.oid, (const unsigned char *)path + len,
45 desc->algo);
46
47 return 0;
48}
49
50static int init_tree_desc_internal(struct tree_desc *desc,
51 const struct object_id *oid,

Callers 2

init_tree_desc_internalFunction · 0.85

Calls 4

strbuf_addstrFunction · 0.85
parse_modeFunction · 0.85
canon_modeFunction · 0.85
oidreadFunction · 0.85

Tested by

no test coverage detected