Skip to content

Commit b2f2039

Browse files
peffgitster
authored andcommitted
fsck: accept an oid instead of a "struct tree" for fsck_tree()
We don't actually look at the tree struct in fsck_tree() beyond its oid and type (which is obviously OBJ_TREE). Just taking an oid gives our callers more flexibility to avoid creating a struct, and makes it clear that we are fscking just what is in the buffer, not any pre-parsed bits from the struct. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c5b4269 commit b2f2039

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

fsck.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ static int verify_ordered(unsigned mode1, const char *name1, unsigned mode2, con
566566
return c1 < c2 ? 0 : TREE_UNORDERED;
567567
}
568568

569-
static int fsck_tree(struct tree *item,
569+
static int fsck_tree(const struct object_id *oid,
570570
const char *buffer, unsigned long size,
571571
struct fsck_options *options)
572572
{
@@ -586,7 +586,7 @@ static int fsck_tree(struct tree *item,
586586
const char *o_name;
587587

588588
if (init_tree_desc_gently(&desc, buffer, size)) {
589-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
589+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
590590
return retval;
591591
}
592592

@@ -613,13 +613,13 @@ static int fsck_tree(struct tree *item,
613613
oidset_insert(&gitmodules_found, oid);
614614
else
615615
retval += report(options,
616-
&item->object.oid, item->object.type,
616+
oid, OBJ_TREE,
617617
FSCK_MSG_GITMODULES_SYMLINK,
618618
".gitmodules is a symbolic link");
619619
}
620620

621621
if (update_tree_entry_gently(&desc)) {
622-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
622+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
623623
break;
624624
}
625625

@@ -664,25 +664,25 @@ static int fsck_tree(struct tree *item,
664664
}
665665

666666
if (has_null_sha1)
667-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_NULL_SHA1, "contains entries pointing to null sha1");
667+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_NULL_SHA1, "contains entries pointing to null sha1");
668668
if (has_full_path)
669-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_FULL_PATHNAME, "contains full pathnames");
669+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_FULL_PATHNAME, "contains full pathnames");
670670
if (has_empty_name)
671-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_EMPTY_NAME, "contains empty pathname");
671+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_EMPTY_NAME, "contains empty pathname");
672672
if (has_dot)
673-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_HAS_DOT, "contains '.'");
673+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_HAS_DOT, "contains '.'");
674674
if (has_dotdot)
675-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_HAS_DOTDOT, "contains '..'");
675+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_HAS_DOTDOT, "contains '..'");
676676
if (has_dotgit)
677-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_HAS_DOTGIT, "contains '.git'");
677+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_HAS_DOTGIT, "contains '.git'");
678678
if (has_zero_pad)
679-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_ZERO_PADDED_FILEMODE, "contains zero-padded file modes");
679+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_ZERO_PADDED_FILEMODE, "contains zero-padded file modes");
680680
if (has_bad_modes)
681-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_BAD_FILEMODE, "contains bad file modes");
681+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_BAD_FILEMODE, "contains bad file modes");
682682
if (has_dup_entries)
683-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_DUPLICATE_ENTRIES, "contains duplicate file entries");
683+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_DUPLICATE_ENTRIES, "contains duplicate file entries");
684684
if (not_properly_sorted)
685-
retval += report(options, &item->object.oid, item->object.type, FSCK_MSG_TREE_NOT_SORTED, "not properly sorted");
685+
retval += report(options, oid, OBJ_TREE, FSCK_MSG_TREE_NOT_SORTED, "not properly sorted");
686686
return retval;
687687
}
688688

@@ -982,7 +982,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
982982
if (obj->type == OBJ_BLOB)
983983
return fsck_blob(&obj->oid, data, size, options);
984984
if (obj->type == OBJ_TREE)
985-
return fsck_tree((struct tree *) obj, data, size, options);
985+
return fsck_tree(&obj->oid, data, size, options);
986986
if (obj->type == OBJ_COMMIT)
987987
return fsck_commit(&obj->oid, data, size, options);
988988
if (obj->type == OBJ_TAG)

0 commit comments

Comments
 (0)