Skip to content

Commit ad2db40

Browse files
jonathantanmygitster
authored andcommitted
fsck: remove redundant parse_tree() invocation
If obj->type == OBJ_TREE, an invocation of fsck_walk() will invoke parse_tree() and return quickly if that returns nonzero, so it is of no use for traverse_one_object() to invoke parse_tree() in this situation before invoking fsck_walk(). Remove that code. The behavior of traverse_one_object() is changed slightly in that it now returns -1 instead of 1 in the case that parse_tree() fails, but this is not an issue because its only caller (traverse_reachable) does not care about the value as long as it is nonzero. This code was introduced in commit 271b8d2 ("builtin-fsck: move away from object-refs to fsck_walk", 2008-02-25). The same issue existed in that commit. Signed-off-by: Jonathan Tan <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cac25fc commit ad2db40

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

builtin/fsck.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,7 @@ static void mark_object_reachable(struct object *obj)
168168

169169
static int traverse_one_object(struct object *obj)
170170
{
171-
int result;
172-
struct tree *tree = NULL;
173-
174-
if (obj->type == OBJ_TREE) {
175-
tree = (struct tree *)obj;
176-
if (parse_tree(tree) < 0)
177-
return 1; /* error already displayed */
178-
}
179-
result = fsck_walk(obj, obj, &fsck_walk_options);
180-
if (tree)
181-
free_tree_buffer(tree);
182-
return result;
171+
return fsck_walk(obj, obj, &fsck_walk_options);
183172
}
184173

185174
static int traverse_reachable(void)

0 commit comments

Comments
 (0)