Git development
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Aniket Gupta <aniketgupta3001@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Laveesh Bansal <laveeshb@laveeshbansal.com>
Subject: Re: [GSoC PATCH v3] fsck: report the number of objects in the connectivity message
Date: Tue, 1 Dec 2026 17:06:33 +0100	[thread overview]
Message-ID: <aw7wiYY8acDYHzYL@pks.im> (raw)
In-Reply-To: <20261130123613.75255-1-aniketgupta3001@gmail.com>

On Mon, Nov 30, 2026 at 06:06:13PM +0530, Aniket Gupta wrote:
> 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.

> -	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

  reply	other threads:[~2026-12-01 16:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 10:21 [GSoC PATCH] fsck: report the real object count in the connectivity message Aniket Gupta
2026-11-12  2:55 ` Laveesh Bansal
2026-11-12 13:07   ` Aniket Gupta
2026-11-23 18:46     ` Laveesh Bansal
2026-11-23 22:43       ` Aniket Gupta
2026-11-29 10:02 ` [GSoC PATCH v2] fsck: report the number of objects " Aniket Gupta
2026-11-29 19:10   ` Junio C Hamano
2026-11-29 19:33     ` Aniket Gupta
2026-11-30 12:36   ` [GSoC PATCH v3] " Aniket Gupta
2026-12-01 16:06     ` Patrick Steinhardt [this message]
2026-12-01 19:27       ` Aniket Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aw7wiYY8acDYHzYL@pks.im \
    --to=ps@pks.im \
    --cc=aniketgupta3001@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=laveeshb@laveeshbansal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox