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

Re: [PATCH v2 10/10] builtin/fsck: move loose object verification into the loose source

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 11, 2026, 12:23 UTC
Message-ID
<aqPy0q0LJJCcBgZY@pks.im>
In-Reply-To
<875x0cnio5.fsf@emacs.iotcl.com>
On Fri, Sep 11, 2026 at 01:15:06PM +0200, Toon Claes wrote:
Show 14 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/odb.h b/odb.h
> > index 0bf6c8d7d2..b87f281cbd 100644
> > --- a/odb.h
> > +++ b/odb.h
> > @@ -218,6 +218,9 @@ enum odb_fsck_flags {
> >  
> >  	/* Display a progress meter, if sensible. */
> >  	ODB_FSCK_PROGRESS = (1 << 1),
> > +
> > +	/* Be extra verbose when checking the database. */
> > +	ODB_FSCK_VERBOSE = (1 << 2),
> 
> Shall we document this one is mutually exclusive with ODB_FSCK_PROGRESS?

But is it really? Sure, we'll potentially have interleaving output where we print log messages followed by progress output. But as far as I can see, we have nothing where we fully interleave so that the progress output would be mangled.

Show 51 quoted lines
> > diff --git a/odb/source-loose.c b/odb/source-loose.c
> > index f68d3c4d6c..efef9ca61f 100644
> > --- a/odb/source-loose.c
> > +++ b/odb/source-loose.c
> > @@ -1031,12 +1032,96 @@ static void odb_source_loose_free(struct odb_source *source)
> >  	free(loose);
> >  }
> >  
> > -static int odb_source_loose_fsck(struct odb_source *source UNUSED,
> > -				 struct odb_fsck_options *opts UNUSED)
> > +struct fsck_loose_data {
> > +	struct odb_source_loose *source;
> > +	struct odb_fsck_options *opts;
> > +	struct progress *progress;
> > +	bool error_found;
> > +};
> > +
> > +static int fsck_loose(const struct object_id *oid, const char *path,
> > +		      void *cb_data)
> >  {
> > +	struct fsck_loose_data *data = cb_data;
> > +	enum object_type type = OBJ_NONE;
> > +	size_t size;
> > +	void *contents = NULL;
> > +	int eaten = 0;
> > +	struct object_info oi = OBJECT_INFO_INIT;
> > +	struct object_id real_oid = *null_oid(data->source->base.odb->repo->hash_algo);
> > +	int err = 0;
> > +
> > +	oi.sizep = &size;
> > +	oi.typep = &type;
> > +
> > +	if (read_loose_object(data->source->base.odb->repo,
> > +			      path, oid, &real_oid, &contents, &oi) < 0) {
> > +		if (contents && !oideq(&real_oid, oid))
> > +			err = error(_("%s: hash-path mismatch, found at: %s"),
> > +				    oid_to_hex(&real_oid), path);
> > +		else
> > +			err = error(_("%s: object corrupt or missing: %s"),
> > +				    oid_to_hex(oid), path);
> > +	}
> > +	if (err < 0)
> > +		goto out;
> > +
> > +	if (!contents && type != OBJ_BLOB)
> > +		BUG("read_loose_object streamed a non-blob");
> > +
> > +	if (data->opts->object_cb(oid, type, size, contents, &eaten,
> > +				  data->opts->object_payload)) {
> 
> Should we guard data->opts->object_cb being NULL?

I don't see a reason for that -- we don't currently have any callers that do, and we can still introduce this check if we ever grow one.

Thanks!
Patrick
Previous: Toon ClaesNext: Karthik Nayak
Message 42 of 54 in “odb: make consistency checks pluggable”
  1. 00/10 odb: make consistency checks pluggablePatrick Steinhardt, Aug 25, 2026
  2. 01/10 builtin/fsck: use `fsck_obj_buffer()` when checking loose objectsPatrick Steinhardt, Aug 25, 2026
  3. Karthik NayakAug 27, 2026
  4. Patrick SteinhardtAug 31, 2026
  5. 02/10 builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()`Patrick Steinhardt, Aug 25, 2026
  6. Karthik NayakAug 27, 2026
  7. Patrick SteinhardtAug 31, 2026
  8. 03/10 builtin/fsck: de-globalize option handlingPatrick Steinhardt, Aug 25, 2026
  9. Karthik NayakAug 27, 2026
  10. 04/10 builtin/fsck: don't check alternates with "--no-full"Patrick Steinhardt, Aug 25, 2026
  11. Karthik NayakAug 27, 2026
  12. Patrick SteinhardtAug 31, 2026
  13. 05/10 odb: provide infrastructure for pluggable fsck checksPatrick Steinhardt, Aug 25, 2026
  14. Karthik NayakAug 27, 2026
  15. Patrick SteinhardtAug 31, 2026
  16. 06/10 builtin/fsck: move packfile verification into the packed sourcePatrick Steinhardt, Aug 25, 2026
  17. 07/10 builtin/fsck: move reverse index verification into the packed sourcePatrick Steinhardt, Aug 25, 2026
  18. 08/10 builtin/fsck: move bitmap verification into the packed sourcePatrick Steinhardt, Aug 25, 2026
  19. Karthik NayakAug 27, 2026
  20. Patrick SteinhardtAug 31, 2026
  21. Karthik NayakAug 31, 2026
  22. 09/10 builtin/fsck: move multi-pack index verification into the packed sourcePatrick Steinhardt, Aug 25, 2026
  23. 10/10 builtin/fsck: move loose object verification into the loose sourcePatrick Steinhardt, Aug 25, 2026
  24. Karthik NayakAug 27, 2026
  25. 00/10 odb: make consistency checks pluggablePatrick Steinhardt, Aug 31, 2026
  26. 01/10 builtin/fsck: use `fsck_obj_buffer()` when checking loose objectsPatrick Steinhardt, Aug 31, 2026
  27. 02/10 builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()`Patrick Steinhardt, Aug 31, 2026
  28. 03/10 builtin/fsck: de-globalize option handlingPatrick Steinhardt, Aug 31, 2026
  29. 04/10 builtin/fsck: don't check alternates with "--no-full"Patrick Steinhardt, Aug 31, 2026
  30. 05/10 odb: provide infrastructure for pluggable fsck checksPatrick Steinhardt, Aug 31, 2026
  31. Toon ClaesSep 11, 2026
  32. Patrick SteinhardtSep 11, 2026
  33. 06/10 builtin/fsck: move packfile verification into the packed sourcePatrick Steinhardt, Aug 31, 2026
  34. 07/10 builtin/fsck: move reverse index verification into the packed sourcePatrick Steinhardt, Aug 31, 2026
  35. Toon ClaesSep 11, 2026
  36. 08/10 builtin/fsck: move bitmap verification into the packed sourcePatrick Steinhardt, Aug 31, 2026
  37. 09/10 builtin/fsck: move multi-pack index verification into the packed sourcePatrick Steinhardt, Aug 31, 2026
  38. Toon ClaesSep 11, 2026
  39. Patrick SteinhardtSep 11, 2026
  40. 10/10 builtin/fsck: move loose object verification into the loose sourcePatrick Steinhardt, Aug 31, 2026
  41. Toon ClaesSep 11, 2026
  42. Patrick SteinhardtSep 11, 2026
  43. Karthik NayakAug 31, 2026
  44. 00/10 odb: make consistency checks pluggablePatrick Steinhardt, Sep 11, 2026
  45. 01/10 builtin/fsck: use `fsck_obj_buffer()` when checking loose objectsPatrick Steinhardt, Sep 11, 2026
  46. 02/10 builtin/fsck: merge `fsck_obj_buffer()` and `fsck_obj()`Patrick Steinhardt, Sep 11, 2026
  47. 03/10 builtin/fsck: de-globalize option handlingPatrick Steinhardt, Sep 11, 2026
  48. 04/10 builtin/fsck: don't check alternates with "--no-full"Patrick Steinhardt, Sep 11, 2026
  49. 05/10 odb: provide infrastructure for pluggable fsck checksPatrick Steinhardt, Sep 11, 2026
  50. 06/10 builtin/fsck: move packfile verification into the packed sourcePatrick Steinhardt, Sep 11, 2026
  51. 07/10 builtin/fsck: move reverse index verification into the packed sourcePatrick Steinhardt, Sep 11, 2026
  52. 08/10 builtin/fsck: move bitmap verification into the packed sourcePatrick Steinhardt, Sep 11, 2026
  53. 09/10 builtin/fsck: move multi-pack index verification into the packed sourcePatrick Steinhardt, Sep 11, 2026
  54. 10/10 builtin/fsck: move loose object verification into the loose sourcePatrick Steinhardt, Sep 11, 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.