git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/4] mark_tree_contents_uninteresting(): drop missing object check

From
Jeff King <peff@peff.net>
Date
May 11, 2018, 18:00 UTC
Message-ID
<20180511180055.GA12543@sigill.intra.peff.net>
In-Reply-To
<20180511180029.GA11290@sigill.intra.peff.net>

It's generally acceptable for UNINTERESTING objects in a traversal to be unavailable (e.g., see aeeae1b771). 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 <peff@peff.net>
---
 revision.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/revision.c b/revision.c
index 1cff11833e..ef70f69f08 100644
--- a/revision.c
+++ b/revision.c
@@ -52,12 +52,9 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
 {
 	struct tree_desc desc;
 	struct name_entry entry;
-	struct object *obj = &tree->object;
 
-	if (!has_object_file(&obj->oid))
+	if (parse_tree_gently(tree, 1) < 0)
 		return;
-	if (parse_tree(tree) < 0)
-		die("bad tree %s", oid_to_hex(&obj->oid));
 
 	init_tree_desc(&desc, tree->buffer, tree->size);
 	while (tree_entry(&desc, &entry)) {
-- 
2.17.0.988.gec4b43b3e5
Previous: Jeff KingNext: Jeff King
Message 2 of 11 in “a few mark_parents_uninteresting cleanups”
  1. 0/4 a few mark_parents_uninteresting cleanupsJeff King, May 11, 2018
  2. 1/4 mark_tree_contents_uninteresting(): drop missing object checkJeff King, May 11, 2018
  3. 2/4 mark_parents_uninteresting(): drop missing object checkJeff King, May 11, 2018
  4. Junio C HamanoMay 13, 2018
  5. 3/4 mark_parents_uninteresting(): replace list with stackJeff King, May 11, 2018
  6. 4/4 mark_parents_uninteresting(): avoid most allocationJeff King, May 11, 2018
  7. Derrick StoleeMay 14, 2018
  8. Jeff KingMay 14, 2018
  9. Derrick StoleeMay 14, 2018
  10. Jeff KingMay 14, 2018
  11. Derrick StoleeMay 14, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.