Article View: linux.kernel.git
Article #4107[GSoC PATCH v3] fsck: report the number of objects in the connectivity message
From: Aniket Gupta
Date: Mon, 30 Nov 2026 12:36
Date: Mon, 30 Nov 2026 12:36
124 lines
14908 bytes
14908 bytes
The verbose "Checking connectivity" message prints the value of
get_max_object_index(), which is the number of buckets in the object
hashtable and not the number of objects in it. In a non-empty
repository the hashtable is larger than what it holds, so a repository
with 21 objects says 64 objects.
Add get_object_count() to return the number of objects in the
hashtable and use it for the message, printed with "%u" as the count is
unsigned. The loop below will still walk every bucket and it keeps
using get_max_object_index().
Signed-off-by: Aniket Gupta <aniketgupta3001@gmail.com>
Reviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
Changes in v3:
- Reword the log message: "the number of buckets", "hashtable"
instead of "hash", and the hashtable is larger than what it holds
only in a non-empty repository (Junio).
- Mention in the log message that the count is printed with "%u"
(Junio).
- Say in the comment above get_object_count() that the count is
smaller only when the hashmap is not empty (Junio).
- In the singular test, add a file to the index instead of creating a
blob and pointing a tag at it (Junio).
- Clean up the repositories the two new tests create with
test_when_finished (Junio).
builtin/fsck.c | 13 ++++++++-----
object.c | 5 +++++
object.h | 8 ++++++++
t/t1450-fsck.sh | 17 +++++++++++++++++
4 files changed, 38 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);
+ }
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;
+}
+
struct object *get_indexed_object(const struct repository *repo,
unsigned int idx)
{
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);
+
/*
* 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..5503bd2533 100755
--- a/t/t1450-fsck.sh
+++ b/t/t1450-fsck.sh
@@ -1165,4 +1165,21 @@ test_expect_success 'fsck with blob size equal to core.bigFileThreshold' '
)
'
+test_expect_success 'fsck --verbose reports the number of objects' '
+ test_when_finished rm -rf count &&
+ 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' '
+ test_when_finished rm -rf single &&
+ git init single &&
+ echo single >single/file &&
+ git -C single add file &&
+ git -C single fsck --verbose 2>err &&
+ test_grep "Checking connectivity (1 object)" err
+'
+
test_done
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261130123613.75255-1-aniketgupta3001@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76665-linux-kernel-git=dewy.ruReferences:
<20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-1-aniketgupta3001@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76665-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: [GSoC PATCH v3] fsck: report the number of objects in the connectivity message
Date: Mon, 30 Nov 2026 18:06:13 +0530
Organization: Usenet Network
Message-ID: <20261130123613.75255-1-aniketgupta3001@gmail.com>
References: <20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-1-aniketgupta3001@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1424522"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lPnbXZ83ggWubSU5Cc3chSBWIeY= sha256:moDWRTiGb6O7psA6EBQoQTOl6M6ysHORevK+WyQ8Hac=
sha1:lBz/h/LVrnK5FurbBJ4M4av+Epk= sha256:bTfYplrc/bktaDKNApu1NzC5X08cOOJiDJSmuQ4Dqug=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 71B96125FE2; Mon, 30 Nov 2026 15:36:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id MWT-dz8HJKyK;
Mon, 30 Nov 2026 15:36:34 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76665-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 2C865125FD9; Mon, 30 Nov 2026 15:36:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 0570C2D11D; Mon, 30 Nov 2026 12:36:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796042180;
b=rIyCO4Vj2jbewfV0UTqYFTt2E1Gl1buz6BAASkB06ZshUhpgPgkZSkWCJtSLhbpPqILY
shqNFX6+wu1cXEq4SwZa4spz7YD8JQ3wMcfVR/ioMF9G9JPOXKZ5UM6qxJgQEjZhi4F4G
4PpbUoPQi4WYMk3VJ/UmCw2N3DDONJkCleyflnJEeDY0qEE3DUneZMPyVcEz9lAXUOQX9
Vz48EMZoGJqbBkiA7CNxwN9ZK0jik8YEh9mNTdxuZCEI45/pZdpJkHO8QGVWziyGPFP75
uPEDF63NCbS2jDWjAjMo7RZbyLVDV47R1vpNgEMom0qM78QJDLGaXU0qyLWkauYJzTA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796042180;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=uLJhT051EkabIA57aocYPf8M/FxZqL85QdLGfrKlCJw=;
b=KI1hRWljKFIWp5lTaYY14V49wji+L5bH9sW4njs4avlqZ6hxaoONsLP6U7Ka8UBXPXp9
TOgLG3H2Ow3yjhdZBNbsijVLQ8DTQgE7AdZ7E0R6y3FKw4ocaJyRasZLI7X2V1ileAe4E
4dxlopf0vL9sBIN5rqpskCgkWWe8d2E79jQiSzfd+fV/6e8Tx9VmbKQn1fPjjpcSCXmU8
owGeBPF+lrLiFvck3Nw4Hi7z0Zh+Iyg2aETfQbRkJf6huroEBBqngE8wGur7x1hqc0nB0
SAZCbsjTsHrkMKaqYuueI2s7pcOuu8GrpwOb6PnAOyi/Lf4whO+G4Uy7NBlGrIO2WWg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SWSVjOk0;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BEAA606A335;
Mon, 30 Nov 2026 12:36:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SWSVjOk0
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796042179;
b=sP+2SrCT85FM1WDcl4HJJPboe+d82Zm4BHuBa6lwaf4e5qu6YUg+PElmIKmKEdB6dIFY
/buYgUSxtDs/yBaPHFlTDt/22kb9+CaWnz1kJkvG/k4QSKSwA4QipMZu63tsPD2jvzRIR
Kbm2fDEkjdy9a5YMOtPIDOU3vgG9IIPF66gq4T2eNVnOwdboEZ2y7gIkR8EyxaiYfJPU2
ZhuXpGccsvq8EIdZ/xUa+iFp2lsFKUUuYlp11XgUD+3+t5n3I3Pd9uC1Sso+bcAUV1WoW
kP7UaJiKlescXdnrL1kZC00KaYPmTfspZlYf5yzC0ln/Wjgb0XtzS81UFf7m4jK1WNQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796042179;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=uLJhT051EkabIA57aocYPf8M/FxZqL85QdLGfrKlCJw=;
b=e9EMKO1MwJjMLSkCgp5G0txsyhe533Di/81bAG86iRb3pIjr6si3V7ouZRX1teUuWQxP
vVERsfgSXqVTOslBZnOHtcw4YSTwaFcytuG4phr3S64gJPA9UwewywxFEPD7yDfsLCPye
mQvCNLVMvPjZgMa5nnLUZdHlbUua3fgkMXeZUgtsEz1TZu+D7WMaTZztHf75ukp+qTPjV
MXGah5wjoIG9srTybogHt4tcPnVghCexwyGtcZmhlEfu9SWihRRq6MWuFUexA5SdWl86c
17CSjT807iPJHPDpoHIyKN4qA0Fu/JKOKpeqAXwTNJ2spQ8Vk9QsqlP8VWYYoFGtY9A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SWSVjOk0;
arc=none smtp.remote-ip=74.125.82.171
X-Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FBBC606A31C
for <git@vger.kernel.org>; Mon, 30 Nov 2026 12:36:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3FBBC606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-38190551625so19631482eec.1
for <git@vger.kernel.org>; Mon, 30 Nov 2026 04:36:19 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796042178; x=1796646978; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=uLJhT051EkabIA57aocYPf8M/FxZqL85QdLGfrKlCJw=;
b=SWSVjOk03gk6tV2fTz80Kv+c3raW8bYKCKaGHkasmfjJG2g/n/T6Y3bzL8QD2iuWU6
ZlbsadyD3WhEHUwx9tsbAkTbWi7aBG2cxVaV9lqIpNTFYOSVVg5klQkW+147tmKzIyAj
sXCuMKtW3YvRFBKNv1bEMmLCeZLgKo9z/DOM/ST+3lsXBvvJGQKowmk2M7hy4+Tny9mU
8DSAPsP4QbTQaeL0uj885gb0oeabENuUWZGG56zfNTGH1sV0k0pkrNxyy1ah+XjfqOhH
dvDoE5215uTS/ufSL6PAxddUsCNYg9KdN3/l7NmN52KCM/o/Hmh21/UYEew/7fV6aLUi
//+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796042178; x=1796646978;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=uLJhT051EkabIA57aocYPf8M/FxZqL85QdLGfrKlCJw=;
b=zsrmL9370IjCHRV0X/3U77E1m4mNbX6ySMAktGrOkmRpMfXK6ive5/uNHozc+FzBPR
HweWpcYsx3CMy796pLFgP+jZtOh5EjpO+XPNFogKn05cTUwc1mYJd8oRsIXTrOPWuD8k
oNC0e+RwbowQv/EgVOzQbOywHHkBktWh7STW0bQTp0AEFNJr17qOHKxxtitlE5P/Ii1z
Su6jIpIe44eV0bKMSQMhT9Tas0Y+84M7rfy0MuCCuNlWmhGWHO4Geb89Y6Pljra23sfX
lj5FjtNhQlpLy/7QZ/YBMUGw+3Io4p/Tf8in91BG/KGf0W2QibsiFOSDbStzffzh6NPV
geLg==
X-Gm-Message-State: APuU4Z/k4yZJxE+tfrWhWqsdJ3A7IxsTroOg62PpTP8GJgNr6XqjaFDQ
0q/Dsvqwdk0MtyG9zkxLTJH3RUJCPhEIuwAHBU8ACInNnDFt61Qy+ZnpdWk7g9P5
X-Gm-Gg: AZFdTZecZ1Csv/exwlCCjNWBPI/dlHsMjX+42X26/qdOJosP9sj1ptQSlCLV4zoTvH4
XSu6H2Lp1NZ1udxY/IWp4lfGX11qJTXbnQE4vit7ptyQLkFEY/e8Bp8fp0w/L0ZNVg56dCDFEsf
TeXEUsnYebLPG1FKmAAN3iVIPjvckQGEGE+mVHdVD2X5M5z9liewzSjwUlSPuRbAaKa+vXWQa2G
n1tNyjIAKNNbHSVrbpaln3jbyGZhDt2Jhgv2JlTeib17dWgIzkcFuWnAmKDa05B7xeyfOPtG73w
wD2eJUN9CL4pUvFSDlkQa1M4vCG2d1/8o7Ul2tfikhlv3dCGqc4UAnC9IRYEkgKVMqPvH4lnJyl
enyg5Dk0I+nxrHYiUUol2r9dr/zA7CCghYBpGmtlIR/aDM6aQDpgKEnTMr7W/hs88Kv86nN/SIv
9yTBA+lO5E2sIg6SA2QmLltq2iNhfwFTGFuFNIH0m71VzYIOphAO9snjN6eI3mvWZvMOE0nmOZa
piLhSPsCVeDa77uG1vzaFAOOqx3L0vAwn31JA6ODOl23e7VtexJrkErnJyWPKz0y15rtGoXIgcF
JAfr7o/0Lu0WcxiRkGVQikod3HN4Wzl6UV8HtKwFEwaDJ1Q+dy2WhJaNL9JKSAXIYWWOeCEzE6n
u4lGzvuOmqYagXYjyPGwEhgzuRn18f/8nfmKlk0kw0XI=
X-Received: by 2002:a05:693c:8642:20b0:386:9e22:ca4c with SMTP id 5a478bee46e88-3869e22cc7emr33383150eec.35.1796042178121;
Mon, 30 Nov 2026 04:36:18 -0800 (PST)
X-Received: from localhost.localdomain ([103.25.231.125])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38566cd46c5sm125214106eec.11.2026.11.30.04.36.16
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Mon, 30 Nov 2026 04:36:17 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
Laveesh Bansal <laveeshb@laveeshbansal.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261129100214.46634-1-aniketgupta3001@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list