tree-walk: convert get_tree_entry_follow_symlinks internals to object_id

Convert the internals of this function to use struct object_id. This is one of the last remaining callers of read_sha1_file_extended that has not been converted yet. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 12, 2018 at 02:27 UTC 0d4a8b5b6ce4db0846b3545a753f0e698db3eda9
1 file changed +11 -11
tree-walk.c
+11 -11
@@ -583,14 +583,14 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
583 struct dir_state *parents = NULL;
584 size_t parents_alloc = 0;
585 size_t i, parents_nr = 0;
586 - unsigned char current_tree_sha1[20];
586 + struct object_id current_tree_oid;
587 struct strbuf namebuf = STRBUF_INIT;
588 struct tree_desc t;
589 int follows_remaining = GET_TREE_ENTRY_FOLLOW_SYMLINKS_MAX_LINKS;
590
591 init_tree_desc(&t, NULL, 0UL);
592 strbuf_addstr(&namebuf, name);
593 - hashcpy(current_tree_sha1, tree_sha1);
593 + hashcpy(current_tree_oid.hash, tree_sha1);
594
595 while (1) {
596 int find_result;
@@ -599,22 +599,22 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
599
600 if (!t.buffer) {
601 void *tree;
602 - unsigned char root[20];
602 + struct object_id root;
603 unsigned long size;
604 - tree = read_object_with_reference(current_tree_sha1,
604 + tree = read_object_with_reference(current_tree_oid.hash,
605 tree_type, &size,
606 - root);
606 + root.hash);
607 if (!tree)
608 goto done;
609
610 ALLOC_GROW(parents, parents_nr + 1, parents_alloc);
611 parents[parents_nr].tree = tree;
612 parents[parents_nr].size = size;
613 - hashcpy(parents[parents_nr].sha1, root);
613 + hashcpy(parents[parents_nr].sha1, root.hash);
614 parents_nr++;
615
616 if (namebuf.buf[0] == '\0') {
617 - hashcpy(result, root);
617 + hashcpy(result, root.hash);
618 retval = FOUND;
619 goto done;
620 }
@@ -671,14 +671,14 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
671
672 /* Look up the first (or only) path component in the tree. */
673 find_result = find_tree_entry(&t, namebuf.buf,
674 - current_tree_sha1, mode);
674 + current_tree_oid.hash, mode);
675 if (find_result) {
676 goto done;
677 }
678
679 if (S_ISDIR(*mode)) {
680 if (!remainder) {
681 - hashcpy(result, current_tree_sha1);
681 + hashcpy(result, current_tree_oid.hash);
682 retval = FOUND;
683 goto done;
684 }
@@ -688,7 +688,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
688 1 + first_slash - namebuf.buf);
689 } else if (S_ISREG(*mode)) {
690 if (!remainder) {
691 - hashcpy(result, current_tree_sha1);
691 + hashcpy(result, current_tree_oid.hash);
692 retval = FOUND;
693 } else {
694 retval = NOT_DIR;
@@ -714,7 +714,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
714 */
715 retval = DANGLING_SYMLINK;
716
717 - contents = read_sha1_file(current_tree_sha1, &type,
717 + contents = read_sha1_file(current_tree_oid.hash, &type,
718 &link_len);
719
720 if (!contents)