#include "tree-walk.h"
#include "unpack-trees.h"
#include "dir.h"
+#include "object-store.h"
#include "tree.h"
#include "pathspec.h"
struct dir_state {
void *tree;
unsigned long size;
- unsigned char sha1[20];
+ struct object_id oid;
};
static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned *mode)
* See the code for enum follow_symlink_result for a description of
* the return values.
*/
-enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_sha1, const char *name, unsigned char *result, struct strbuf *result_path, unsigned *mode)
+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)
{
int retval = MISSING_OBJECT;
struct dir_state *parents = NULL;
init_tree_desc(&t, NULL, 0UL);
strbuf_addstr(&namebuf, name);
- hashcpy(current_tree_oid.hash, tree_sha1);
+ oidcpy(¤t_tree_oid, tree_oid);
while (1) {
int find_result;
ALLOC_GROW(parents, parents_nr + 1, parents_alloc);
parents[parents_nr].tree = tree;
parents[parents_nr].size = size;
- hashcpy(parents[parents_nr].sha1, root.hash);
+ oidcpy(&parents[parents_nr].oid, &root);
parents_nr++;
if (namebuf.buf[0] == '\0') {
- hashcpy(result, root.hash);
+ oidcpy(result, &root);
retval = FOUND;
goto done;
}
/* We could end up here via a symlink to dir/.. */
if (namebuf.buf[0] == '\0') {
- hashcpy(result, parents[parents_nr - 1].sha1);
+ oidcpy(result, &parents[parents_nr - 1].oid);
retval = FOUND;
goto done;
}
if (S_ISDIR(*mode)) {
if (!remainder) {
- hashcpy(result, current_tree_oid.hash);
+ oidcpy(result, ¤t_tree_oid);
retval = FOUND;
goto done;
}
1 + first_slash - namebuf.buf);
} else if (S_ISREG(*mode)) {
if (!remainder) {
- hashcpy(result, current_tree_oid.hash);
+ oidcpy(result, ¤t_tree_oid);
retval = FOUND;
} else {
retval = NOT_DIR;