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

[PATCH 2/7] odb/source-inmemory: signal missing objects via positive return

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 18, 2026, 14:19 UTC
Message-ID
<20260818-pks-odb-generic-corrupt-objects-v1-2-ec234567510f@pks.im>
In-Reply-To
<20260818-pks-odb-generic-corrupt-objects-v1-0-ec234567510f@pks.im>

The in-memory source returns a negative value from its `read_object_info()` callback when the object in question does not exist. Adapt the callback to return a positive value for missing objects according to the new calling convention.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 odb/source-inmemory.c         | 2 +-
 t/unit-tests/u-odb-inmemory.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c
index 3e71611b8e..57183daf4d 100644
--- a/odb/source-inmemory.c
+++ b/odb/source-inmemory.c
@@ -66,7 +66,7 @@ static int odb_source_inmemory_read_object_info(struct odb_source *source,
 
 	object = find_cached_object(inmemory, oid);
 	if (!object)
-		return -1;
+		return 1;
 
 	populate_object_info(inmemory, oi, object);
 	return 0;
diff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c
index ddf2db5c81..93b3f38dab 100644
--- a/t/unit-tests/u-odb-inmemory.c
+++ b/t/unit-tests/u-odb-inmemory.c
@@ -72,7 +72,7 @@ void test_odb_inmemory__read_missing_object(void)
 	const char *end;
 
 	cl_must_pass(parse_oid_hex_algop(RANDOM_OID, &oid, &end, repo.hash_algo));
-	cl_must_fail(odb_source_read_object_info(&source->base, &oid, NULL, 0));
+	cl_assert(odb_source_read_object_info(&source->base, &oid, NULL, 0) > 0);
 
 	odb_source_free(&source->base);
 }
-- 
2.55.0.822.g20453c30eb.dirty
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 5 of 18 in “odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` generically”
  1. 0/7 odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` genericallyPatrick Steinhardt, Aug 18, 2026
  2. 1/7 odb/source: discern missing and corrupt objectsPatrick Steinhardt, Aug 18, 2026
  3. Junio C HamanoAug 18, 2026
  4. Patrick SteinhardtAug 19, 2026
  5. 2/7 odb/source-inmemory: signal missing objects via positive returnPatrick Steinhardt, Aug 18, 2026
  6. Junio C HamanoAug 18, 2026
  7. Patrick SteinhardtAug 19, 2026
  8. 3/7 odb/source-packed: flag known-bad objects as corrupt and not missingPatrick Steinhardt, Aug 18, 2026
  9. Junio C HamanoAug 18, 2026
  10. Patrick SteinhardtAug 19, 2026
  11. Junio C HamanoAug 19, 2026
  12. 4/7 odb/source-loose: distinguish missing and corrupt objectsPatrick Steinhardt, Aug 18, 2026
  13. Junio C HamanoAug 18, 2026
  14. 5/7 odb/source-files: signal mark objects via positive returnPatrick Steinhardt, Aug 18, 2026
  15. Junio C HamanoAug 18, 2026
  16. Patrick SteinhardtAug 19, 2026
  17. 6/7 odb/source: allow `read_object_info()` to bubble up error messagesPatrick Steinhardt, Aug 18, 2026
  18. 7/7 odb: handle `OBJECT_INFO_DIE_IF_CORRUPT` genericallyPatrick Steinhardt, Aug 18, 2026

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.