Skip to content

Commit a5411df

Browse files
peffgitster
authored andcommitted
mark_tree_contents_uninteresting(): drop missing object check
It's generally acceptable for UNINTERESTING objects in a traversal to be unavailable (e.g., see aeeae1b). When marking trees UNINTERESTING, we access the object database twice: once to check if the object is missing (and return quietly if it is), and then again to actually parse it. We can instead just try to parse; if that fails, we can then return quietly. That halves the effort we spend on locating the object. Note that this isn't _exactly_ the same as the original behavior, as the parse failure could be due to other problems than a missing object: it could be corrupted, in which case the original code would have died. But the new behavior is arguably better, as it covers the object being unavailable for any reason. We'll also still issue a warning to stderr in such a case. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 468165c commit a5411df

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

revision.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
5151
{
5252
struct tree_desc desc;
5353
struct name_entry entry;
54-
struct object *obj = &tree->object;
5554

56-
if (!has_object_file(&obj->oid))
55+
if (parse_tree_gently(tree, 1) < 0)
5756
return;
58-
if (parse_tree(tree) < 0)
59-
die("bad tree %s", oid_to_hex(&obj->oid));
6057

6158
init_tree_desc(&desc, tree->buffer, tree->size);
6259
while (tree_entry(&desc, &entry)) {

0 commit comments

Comments
 (0)