From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795979421; b=O6e3ziO0Ov393/v2OI3LBdae6rFs6fqQVEJuowhjC3GGJlo+pK8ahOnBejWXXq40Cdep /i7ZErmKG+xO4ugev4t0L/Fbprnop8vEroHMM92ZhkFaiGcMZ4jy2zn6JqmuwO3D3nW2e XRP2FvlwFQRGASfmePAPbM2aHJNhoI086BJKAF8vn2sXGOK05WiDqQm36sUJMjhvlRtV/ Ne1Y/ikwrAkgb5JgAyY9vEOwtzVeD+5TR20hjlXTcBT966S3vTEkiqKi84jAzMpypVNUY ujYsKVnRWWcHeOGRN415cW2ghz6dW0dT0QHZq5HrWzE3YLu7ORJvsRfmTVBPrzpswJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795979421; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: User-Agent:MIME-Version:Content-Type; bh=tMXCUV6K8TFUikbG/2C8DVp386un2h6pt2geBNABHiI=; b=oyz70yETErop117mlnAt1Cu7g9d/CqRGhrqOkVARkS+RnoKbl7zLls5UkZ/sDtW7hjCj huoM+LsbW8HGvZFseEHUoOewOgO5GxfYnCgoJMUBKrgEc+VZA0dtoC7tcg1Q/8d5VuyES 04EOT3BPv32Kt+5L5YSc4u05orNVGxQq6GOO5NOIQ5yFEkPIVTtE+NxiTECJ5YdJW1GVW RPgy8iQC4diSsAVD90HuF6Eg2eiB9CC1fOCX2/WzP0Ng4lqIbb0l9F1PlyC+jTV3HwDyZ KxpkbXijhXbucGsYm+EdiN807/CP/bmgf6PI+LclNgEVMcyCBhfkN0VQVYD8261pgxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=ZhDb0Z0Y; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ZwiACVeC; arc=none smtp.remote-ip=103.168.172.151 Received: from fout-a8-smtp.messagingengine.com (fout-a8-smtp.messagingengine.com [103.168.172.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AE22606A31C for ; Sun, 29 Nov 2026 19:10:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1AE22606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=ZhDb0Z0Y; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ZwiACVeC Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 33CCEEC1468 for ; Sun, 29 Nov 2026 14:10:20 -0500 (EST) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-01.internal (MEProxy); Sun, 29 Nov 2026 14:10:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1795979420; x=1796065820; bh=tMXCUV6K8T FUikbG/2C8DVp386un2h6pt2geBNABHiI=; b=ZhDb0Z0YXoryV8cnn7wbMXv0Lz dejt/bS2so+YTIr+jkSP5yfg7qcFcnz4ME/oD9BRwXhgxSv+HQO/DNulL9SxQ4Vi qQeWgNL7J1Y9Y262AFweuIt2LIVQZoz2EOk5/hLMD2ZXTJpqUGHoFkwsWkYObnv4 UO6NR8Zf+A5Eh1AKRegQVfoUeGnBJ8Ot/rFvq5OJvIcAUY4X+r0TiPhyWo4AWT6M BV/uQ4qMUWcWbJ67KVG7FbPF71v4pkr5yQi3Z33tKz9htQ7w9rsk2adivAHKP9Sx J0SNEm96Yc4sJgUGHuoXUaPzQ7/GFRWlTMp9ZC8rK2Vu8Ix9VGYM7177WBxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1795979420; x=1796065820; bh=tMXCUV6K8TFUikbG/2C8DVp386un2h6pt2g eBNABHiI=; b=ZwiACVeCMiT64L2etKyUL6defAIFRH65go977oFMjaPZDpP3K74 NQQ25msOVeMWPPOdD7hlmDtCuyDGPmTjGkqxKYMx/VCyd6QY2NQ9ZX7qDgU0pDGH XgfRtgXWGDrWOP47F9Mnn8fBQzAKl7yZgn+sfjoa7OKZgeYQRAN10GgAlGtD6VHj vCmGVQT3dq1Z8LAhQvmFWsSxo89BnQbhwtSUpuP0AKC1jOGgA1wPNxK8Z6IaIyCG QaWIugH/Aa+n0twJtodxvcQf9shsIdy19owsbIWVjwT+8mlVXZ248VbMBrX+Xmti TxaFgBcfqVfwhekSE5JfInrTiIhyXRc9Wkg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pobox.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795979420; d=pobox.com; mf=PGdpdHN0ZXJAcG9ib3guY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:HYNFVeZHcGRgcdyMI3vlGCjL2gBXyUKRJxvfvxby2O9gQs8 Kgw0VdEje4wvI51MmVInDOTENv242diS/xgKIziPxXSaDNjW6oIW6R0+VitwQd8M QkPcvu1mULGbxrO6ME3PKaslK4cUJb+4zKNIx96cT0IGvOAg6DEdCr/MTeonFomb euKxF8sILUCw8lksyQeV2UDESFqJ2oz9jytftebLoBaq88odVhY4/0RGF76FIxWP q7Iik2aEkedHsAnUrUvkgyTLjo7xXvNIzH4Jp2WISoBt/emwxQaCBrAL7VzdI2Yl JPCIU7TJFkZVF0fQr+mrxxIVBpqYKCmqzEfj+SA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to,user-agent; Message-Instance: m=1; h=sha256:qgCa4kuADuBUuCquxWJpbW/bLwvRILv2CcIAo4z59CI=:Du8ZD/D3S/KoCAqTwMmKP0NjmGDjQzbcfbjURqDU+8Y=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF/3dYNkKTZ8PnxZauAx8k9Tgaj/IMzwn/al0N3jaZVkvepvcThkoLTu8n/gtOMsI MZOavwvZioNLGq/mqShfm3yaFXB3pyrIooTU92JM+jVro672Hf55Lo52T8SFwjrScUMjb0 EvDpYTMHg/R1RESCVBLJh55qekH3MEnwrxUmpFD0+lmsx5JOZRIJrHNxE67S01QD/9zdbK vjEprVhIyq74WofltBwEU98oNXM/6yvvSGOM4eEjhNjrvfHEqJCxD1q7tHArfGd6L0quGv ZpLhpmyzqTJiWhSlU3ruopQ9SvQ9iY7LyE3AbIYbaup2AcDFwer9gQLDANz2fpXM7PqxL+ e0ALZdlCYOixBtb2cwRNikR2lK1UGPDtQhwFhltQ5A6MZqh5ZYqzRzqt2T4nXOujNWNazO DoikSVX56qUw2Io8MgqWC3gtMMJZVL1SH9hnjKDyW+OWoHIAShrWRDMxrEujKyUlClCEG8 4B2Ococd5pjym0P6gEbLbDxVWV3IjEP2K1lqYIMTT4g/6TpbgZwvK5bNfRqSHt4ou1tCsq /35I5c9dvJiLRvqNP6J2Iibmjok0hrwRv1MoFi4y7zFuXVWm2Hg6LZYzOc9bNpZSEtKlaA 8LlZ/9b0Q7garNPD55esVGwB8/Gw+Sx7p2I/CXWa631P7QdiYtT+zJBuVGkg X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 29 Nov 2026 14:10:19 -0500 (EST) From: Junio C Hamano To: Aniket Gupta Cc: git@vger.kernel.org, Laveesh Bansal Subject: Re: [GSoC PATCH v2] fsck: report the number of objects in the connectivity message In-Reply-To: <20261129100214.46634-1-aniketgupta3001@gmail.com> (Aniket Gupta's message of "Sun, 29 Nov 2026 15:32:14 +0530") References: <20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-1-aniketgupta3001@gmail.com> Date: Sun, 29 Nov 2026 11:10:18 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain Aniket Gupta writes: > The verbose "Checking connectivity" message prints the value of > get_max_object_index(), which is number of buckets in the object hash > and not the number of objects in it. The hash is larger than what it > holds so a repository with 21 objects says 64 objects. Micronits. - "which is the number of buckets" is missing "the". - What holds the objects is not a "hash" but a "hashtable". - In an empty repository, we have no hash buckets, so the capacity of the hashtable exactly matches the number of objects in that case. "In a non-empty repository, the hashtable is larger than what it holds" would be more accurate. For any non-empty table, grow_object_hash() allocates at least 32 buckets and doubles when '.obj_hash_size' - 1 <= '.nr_objs' * 2, so 21 objects indeed sit in 64 buckets. > Add get_object_count() to return the number of objects in the hash and > use it for the message. The loop below will still walk every bucket and > it keeps using get_max_object_index(). > > Signed-off-by: Aniket Gupta > Reviewed-by: Laveesh Bansal > --- > Changes in v2: > > - Retitle as Laveesh suggested. In a partial clone the count also > includes the blobs that the trees refer to, so "number of objects" > fits better. Good. > - Add Laveesh's Reviewed-by. Good. > - Rebase onto current master. A report on rebasing is incomplete without an explanation of the reason why you had to rebase (what you wanted to achieve by rebasing). There certainly would have been changes on the 'master' front since the version you based your previous round on. But were there ones among these changes that you specifically wanted to take advantage of, or that caused conflicts that you wanted to resolve on your end (instead of having the maintainer do it for you)? Another small change not mentioned in the proposed log message is to report the number of objects using "%u". > builtin/fsck.c | 13 ++++++++----- > object.c | 5 +++++ > object.h | 7 +++++++ > t/t1450-fsck.sh | 15 +++++++++++++++ > 4 files changed, 35 insertions(+), 5 deletions(-) > > 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); > - 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); > + } By the time check_connectivity() reaches this point, cmd_fsck() has populated '.obj_hash' from its sources, and traverse_reachable() has already walked reachable trees and commits (which inserts referenced objects, including missing or promisor blobs, via lookup_tree() and lookup_blob()). Neither check_reachable_object() nor check_unreachable_object() in the loop inserts new entries into '.obj_hash', so get_object_count() matches the exact number of non-NULL objects visited by the loop. Using "%u" matches the return type of get_object_count() that is unsigned. > for (i = 0; i < max; i++) { > struct object *obj = get_indexed_object(repo, i); > diff --git a/object.c b/object.c > index 97f7fc0e87..2fdba93d4c 100644 > --- a/object.c > +++ b/object.c > @@ -20,6 +20,11 @@ unsigned int get_max_object_index(const struct repository *repo) > return repo->parsed_objects->obj_hash_size; > } > > +unsigned int get_object_count(const struct repository *repo) > +{ > + return repo->parsed_objects->nr_objs; > +} Tracking '.nr_objs' directly is clean. parsed_object_pool_new() zero-initializes the pool, create_object() increments '.nr_objs' on every insertion into '.obj_hash', and nothing decrements or removes entries before parsed_object_pool_clear() tears the pool down. All other callers of get_max_object_index() walk the bucket array with get_indexed_object(). builtin/index-pack.c:check_objects() passes the bucket count to start_delayed_progress() because its loop calls display_progress() with the bucket index, so leaving those callers untouched makes sense. The code is prepared to have up to 2 billion objects in an object pool on 32-bit machines, as the type of the .nr_objs member in the parsed_object_pool struct is 'int' (it is a bit surprising that it is not even "unsigned int"). Something to think about later after the dust settles (#leftoverbits). > struct object *get_indexed_object(const struct repository *repo, > unsigned int idx) > { > diff --git a/object.h b/object.h > index 46cade33fb..20ea6f5c0c 100644 > --- a/object.h > +++ b/object.h > @@ -173,6 +173,13 @@ 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, as that > + * counts the buckets, which are not all in use. > + */ > +unsigned int get_object_count(const struct repository *repo); Minor nit. "This is smaller than the value get_max_object_index() returns when the object hashmap is not empty, as that counts ...". > + > /* > * Return the object from the specified bucket in the object hashmap. > */ > diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh > index 3e9eb251cb..c871ad8edf 100755 > --- a/t/t1450-fsck.sh > +++ b/t/t1450-fsck.sh > @@ -1165,4 +1165,19 @@ test_expect_success 'fsck with blob size equal to core.bigFileThreshold' ' > ) > ' > > +test_expect_success 'fsck --verbose reports the number of objects' ' > + git init count && > + test_commit -C count one && > + git -C count fsck --verbose 2>err && > + test_grep "Checking connectivity (3 objects)" err > +' > + > +test_expect_success 'fsck --verbose uses the singular for a single object' ' > + git init single && > + blob=$(echo single | git -C single hash-object -w --stdin) && > + git -C single update-ref refs/tags/blob $blob && > + git -C single fsck --verbose 2>err && > + test_grep "Checking connectivity (1 object)" err > +' Both tests cover the expected counts cleanly. - test_commit defaults to a lightweight tag, producing 1 blob, 1 tree, and 1 commit (3 objects). - You can have only commits under refs/heads/, so you create a blob and point at it with refs/tags/blob, which would exercise a singular form. I wonder if you can just 'git add' a regular file in a freshly created repository without committing to get the same effect? 'git fsck' would consider the index as a connectivity anchor, so it will traverse to the blob object, without a tag to the blob, which is a bit of an unusual thing to have these days. Optional cleanup with test_when_finished "rm -rf ..." would match the test right above, though other tests in this file omit it too, so we should be OK.