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

Re: [GSoC PATCH v3] fsck: report the number of objects in the connectivity message

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 1, 2026, 16:06 UTC
Message-ID
<aw7wiYY8acDYHzYL@pks.im>
In-Reply-To
<20261130123613.75255-1-aniketgupta3001@gmail.com>
On Mon, Nov 30, 2026 at 06:06:13PM +0530, Aniket Gupta wrote:
Show 8 quoted lines
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index c4558efcf1..3aca0736d4 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -377,11 +377,14 @@ static void check_connectivity(struct repository *repo)
>  
>  	/* Look up all the requirements, warn about missing objects.. */
>  	max = get_max_object_index(repo);
Micronit: It's a tiny bit confusing that you now assign this variable
before the `if (verbose)` block, because we don't actually need it in
there. I would have moved the assignment down to the second loop.
Show 31 quoted lines
> -	if (verbose)
> -		fprintf_ln(stderr, Q_("Checking connectivity (%d object)",
> -				      "Checking connectivity (%d objects)",
> -				      max),
> -			   max);
> +	if (verbose) {
> +		unsigned int nr = get_object_count(repo);
> +
> +		fprintf_ln(stderr, Q_("Checking connectivity (%u object)",
> +				      "Checking connectivity (%u objects)",
> +				      nr),
> +			   nr);
> +	}
>  
>  	for (i = 0; i < max; i++) {
>  		struct object *obj = get_indexed_object(repo, i);
> diff --git a/object.h b/object.h
> index 46cade33fb..21e0837ed2 100644
> --- a/object.h
> +++ b/object.h
> @@ -173,6 +173,14 @@ int type_from_string_gently(const char *str, ssize_t, int gentle);
>   */
>  unsigned int get_max_object_index(const struct repository *repo);
>  
> +/*
> + * Return the number of objects currently in the object hashmap. This
> + * is smaller than the value get_max_object_index() returns when the
> + * object hashmap is not empty, as that counts the buckets, which are
> + * not all in use.
> + */
> +unsigned int get_object_count(const struct repository *repo);
Nit: The function name is rather generic, and it may for example lead
the reader to believe that it is about the total number of objects
contained in the object database. It's not though, it's only about the
total number of _parsed_ objects.
So should this be called `get_parsed_object_count()` instead?
The patch looks otherwise good to me, thanks!
Patrick
Previous: Aniket GuptaNext: Aniket Gupta
Message 10 of 13 in “fsck: report the real object count in the connectivity message”
  1. fsck: report the real object count in the connectivity messageAniket Gupta, Oct 20, 2026
  2. Laveesh BansalNov 12, 2026
  3. Aniket GuptaNov 12, 2026
  4. Laveesh BansalNov 23, 2026
  5. Aniket GuptaNov 23, 2026
  6. fsck: report the number of objects in the connectivity messageAniket Gupta, Nov 29, 2026
  7. Junio C HamanoNov 29, 2026
  8. Aniket GuptaNov 29, 2026
  9. fsck: report the number of objects in the connectivity messageAniket Gupta, Nov 30, 2026
  10. Patrick SteinhardtDec 1, 2026
  11. Aniket GuptaDec 1, 2026
  12. fsck: report the number of objects in the connectivity messageAniket Gupta, Dec 2, 2026
  13. Patrick SteinhardtDec 3, 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.