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

[PATCH 5/7] odb/source-files: signal mark 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-5-ec234567510f@pks.im>
In-Reply-To
<20260818-pks-odb-generic-corrupt-objects-v1-0-ec234567510f@pks.im>

The files source conflates all failures of its child sources into a negative return value, so callers cannot tell apart whether an object is missing or whether reading it has failed. Both the packed and the loose source have been converted to adhere to the tri-state return convention of `read_object_info()` by now, so all that is left to do is to propagate their respective return values.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 odb/source-files.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/odb/source-files.c b/odb/source-files.c
index 5a68af7d84..1124a18091 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -65,12 +65,26 @@ static int odb_source_files_read_object_info(struct odb_source *source,
 					     enum object_info_flags flags)
 {
 	struct odb_source_files *files = odb_source_files_downcast(source);
+	int ret_packed, ret_loose;
 
-	if (!odb_source_read_object_info(&files->packed->base, oid, oi, flags) ||
-	    !odb_source_read_object_info(&files->loose->base, oid, oi, flags))
+	ret_packed = odb_source_read_object_info(&files->packed->base, oid, oi, flags);
+	if (!ret_packed)
 		return 0;
 
-	return -1;
+	ret_loose = odb_source_read_object_info(&files->loose->base, oid, oi, flags);
+	if (!ret_loose)
+		return 0;
+
+	/*
+	 * Reading the packed object may have failed even though the object
+	 * exists, for example because it is corrupt. Report this failure to
+	 * the caller in case neither of the sources was able to read the
+	 * object, and prefer the error of the packed source in case both
+	 * reads have failed.
+	 */
+	if (ret_packed < 0)
+		return ret_packed;
+	return ret_loose;
 }
 
 static int odb_source_files_read_object_stream(struct odb_read_stream **out,
-- 
2.55.0.822.g20453c30eb.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 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.