/* Initialize the descriptor entry */
desc->entry.path = path;
desc->entry.mode = canon_mode(mode);
- desc->entry.oid = (const struct object_id *)(path + len);
+ desc->entry.pathlen = len - 1;
+ hashcpy(desc->entry.oid.hash, (const unsigned char *)path + len);
return 0;
}
static int update_tree_entry_internal(struct tree_desc *desc, struct strbuf *err)
{
const void *buf = desc->buffer;
- const unsigned char *end = desc->entry.oid->hash + the_hash_algo->rawsz;
+ const unsigned char *end = (const unsigned char *)desc->entry.path + desc->entry.pathlen + 1 + the_hash_algo->rawsz;
unsigned long size = desc->size;
unsigned long len = end - (const unsigned char *)buf;
pathlen--;
info->pathlen = pathlen ? pathlen + 1 : 0;
info->name.path = base;
- info->name.oid = (void *)(base + pathlen + 1);
- if (pathlen)
+ info->name.pathlen = pathlen;
+ if (pathlen) {
+ hashcpy(info->name.oid.hash, (const unsigned char *)base + pathlen + 1);
info->prev = &dummy;
+ }
}
char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n)
int namelen = strlen(name);
while (t->size) {
const char *entry;
- const struct object_id *oid;
+ struct object_id oid;
int entrylen, cmp;
- oid = tree_entry_extract(t, &entry, mode);
+ oidcpy(&oid, tree_entry_extract(t, &entry, mode));
entrylen = tree_entry_len(&t->entry);
update_tree_entry(t);
if (entrylen > namelen)
if (cmp < 0)
break;
if (entrylen == namelen) {
- oidcpy(result, oid);
+ oidcpy(result, &oid);
return 0;
}
if (name[entrylen] != '/')
if (!S_ISDIR(*mode))
break;
if (++entrylen == namelen) {
- oidcpy(result, oid);
+ oidcpy(result, &oid);
return 0;
}
- return get_tree_entry(oid, name + entrylen, result, mode);
+ return get_tree_entry(&oid, name + entrylen, result, mode);
}
return -1;
}
* with the sha1 of the found object, and *mode will hold the mode of
* the object.
*
- * See the code for enum follow_symlink_result for a description of
+ * See the code for enum get_oid_result for a description of
* the return values.
*/
-enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned *mode)
+enum get_oid_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned *mode)
{
int retval = MISSING_OBJECT;
struct dir_state *parents = NULL;