Skip to content

Commit 3b683bc

Browse files
bk2204gitster
authored andcommitted
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>
1 parent e84bc23 commit 3b683bc

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

sha1_name.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,8 +1685,8 @@ static int get_oid_with_context_1(const char *name,
16851685
if (new_filename)
16861686
filename = new_filename;
16871687
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,
16901690
&oc->mode);
16911691
} else {
16921692
ret = get_tree_entry(&tree_oid, filename, oid,

tree-walk.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info)
488488
struct dir_state {
489489
void *tree;
490490
unsigned long size;
491-
unsigned char sha1[20];
491+
struct object_id oid;
492492
};
493493

494494
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
576576
* See the code for enum follow_symlink_result for a description of
577577
* the return values.
578578
*/
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)
580580
{
581581
int retval = MISSING_OBJECT;
582582
struct dir_state *parents = NULL;
@@ -589,7 +589,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
589589

590590
init_tree_desc(&t, NULL, 0UL);
591591
strbuf_addstr(&namebuf, name);
592-
hashcpy(current_tree_oid.hash, tree_sha1);
592+
oidcpy(&current_tree_oid, tree_oid);
593593

594594
while (1) {
595595
int find_result;
@@ -609,11 +609,11 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
609609
ALLOC_GROW(parents, parents_nr + 1, parents_alloc);
610610
parents[parents_nr].tree = tree;
611611
parents[parents_nr].size = size;
612-
hashcpy(parents[parents_nr].sha1, root.hash);
612+
oidcpy(&parents[parents_nr].oid, &root);
613613
parents_nr++;
614614

615615
if (namebuf.buf[0] == '\0') {
616-
hashcpy(result, root.hash);
616+
oidcpy(result, &root);
617617
retval = FOUND;
618618
goto done;
619619
}
@@ -663,7 +663,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
663663

664664
/* We could end up here via a symlink to dir/.. */
665665
if (namebuf.buf[0] == '\0') {
666-
hashcpy(result, parents[parents_nr - 1].sha1);
666+
oidcpy(result, &parents[parents_nr - 1].oid);
667667
retval = FOUND;
668668
goto done;
669669
}
@@ -677,7 +677,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
677677

678678
if (S_ISDIR(*mode)) {
679679
if (!remainder) {
680-
hashcpy(result, current_tree_oid.hash);
680+
oidcpy(result, &current_tree_oid);
681681
retval = FOUND;
682682
goto done;
683683
}
@@ -687,7 +687,7 @@ enum follow_symlinks_result get_tree_entry_follow_symlinks(unsigned char *tree_s
687687
1 + first_slash - namebuf.buf);
688688
} else if (S_ISREG(*mode)) {
689689
if (!remainder) {
690-
hashcpy(result, current_tree_oid.hash);
690+
oidcpy(result, &current_tree_oid);
691691
retval = FOUND;
692692
} else {
693693
retval = NOT_DIR;

tree-walk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ enum follow_symlinks_result {
6464
*/
6565
};
6666

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);
6868

6969
struct traverse_info {
7070
const char *traverse_path;

0 commit comments

Comments
 (0)