tree-walk: convert get_tree_entry_follow_symlinks to object_id

Since the only caller of this function already uses struct object_id, update get_tree_entry_follow_symlinks to use it in parameters and internally. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 2, 2018 at 00:25 UTC 3b683bcf85aead6c980d79e6f81da8be362341bc
3 files changed +11 -11
sha1_name.c
+2 -2
@@ -1685,8 +1685,8 @@ static int get_oid_with_context_1(const char *name,
1685 if (new_filename)
1686 filename = new_filename;
1687 if (flags & GET_OID_FOLLOW_SYMLINKS) {
1688 - ret = get_tree_entry_follow_symlinks(tree_oid.hash,
1689 - filename, oid->hash, &oc->symlink_path,
1688 + ret = get_tree_entry_follow_symlinks(&tree_oid,
1689 + filename, oid, &oc->symlink_path,
1690 &oc->mode);
1691 } else {
1692 ret = get_tree_entry(&tree_oid, filename, oid,
tree-walk.c
+8 -8
@@ -488,7 +488,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
488 struct dir_state {
489 void *tree;
490 unsigned long size;
491 - unsigned char sha1[20];
491 + struct object_id oid;
492 };
493
494 static int find_tree_entry(struct tree_desc *t, const char *name, struct object_id *result, unsigned *mode)
@@ -576,7 +576,7 @@ int get_tree_entry(const struct object_id *tree_oid, const char *name, struct ob
576 * See the code for enum follow_symlink_result for a description of
577 * the return values.
578 */
579 -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)
579 +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)
580 {
581 int retval = MISSING_OBJECT;
582 struct dir_state *parents = NULL;
@@ -589,7 +589,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
589
590 init_tree_desc(&t, NULL, 0UL);
591 strbuf_addstr(&namebuf, name);
592 - hashcpy(current_tree_oid.hash, tree_sha1);
592 + oidcpy(&current_tree_oid, tree_oid);
593
594 while (1) {
595 int find_result;
@@ -609,11 +609,11 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
609 ALLOC_GROW(parents, parents_nr + 1, parents_alloc);
610 parents[parents_nr].tree = tree;
611 parents[parents_nr].size = size;
612 - hashcpy(parents[parents_nr].sha1, root.hash);
612 + oidcpy(&parents[parents_nr].oid, &root);
613 parents_nr++;
614
615 if (namebuf.buf[0] == '\0') {
616 - hashcpy(result, root.hash);
616 + oidcpy(result, &root);
617 retval = FOUND;
618 goto done;
619 }
@@ -663,7 +663,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
663
664 /* We could end up here via a symlink to dir/.. */
665 if (namebuf.buf[0] == '\0') {
666 - hashcpy(result, parents[parents_nr - 1].sha1);
666 + oidcpy(result, &parents[parents_nr - 1].oid);
667 retval = FOUND;
668 goto done;
669 }
@@ -677,7 +677,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
677
678 if (S_ISDIR(*mode)) {
679 if (!remainder) {
680 - hashcpy(result, current_tree_oid.hash);
680 + oidcpy(result, &current_tree_oid);
681 retval = FOUND;
682 goto done;
683 }
@@ -687,7 +687,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
687 1 + first_slash - namebuf.buf);
688 } else if (S_ISREG(*mode)) {
689 if (!remainder) {
690 - hashcpy(result, current_tree_oid.hash);
690 + oidcpy(result, &current_tree_oid);
691 retval = FOUND;
692 } else {
693 retval = NOT_DIR;
tree-walk.h
+1 -1
@@ -64,7 +64,7 @@ enum follow_symlinks_result {
64 */
65 };
66
67 -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);
67 +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);
68
69 struct traverse_info {
70 const char *traverse_path;