Article View: linux.kernel.git
Article #4261[GSoC PATCH v4] fsck: report the number of objects in the connectivity message
From: Aniket Gupta
Date: Wed, 02 Dec 2026 20:09
Date: Wed, 02 Dec 2026 20:09
189 lines
17543 bytes
17543 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_parsed_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 v4:
- Move the assignment of max down to the loop that uses it (Patrick).
- Rename get_object_count() to get_parsed_object_count() and mention in
comment that objects that were only referenced are counted too
(Patrick).
builtin/fsck.c | 15 +++++++++------
object.c | 5 +++++
object.h | 9 +++++++++
t/t1450-fsck.sh | 17 +++++++++++++++++
4 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/builtin/fsck.c b/builtin/fsck.c
index c4558efcf1..b3c42cd19c 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -376,13 +376,16 @@ 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_parsed_object_count(repo);
+ fprintf_ln(stderr, Q_("Checking connectivity (%u object)",
+ "Checking connectivity (%u objects)",
+ nr),
+ nr);
+ }
+
+ max = get_max_object_index(repo);
for (i = 0; i < max; i++) {
struct object *obj = get_indexed_object(repo, i);
diff --git a/object.c b/object.c
index 97f7fc0e87..6390849b48 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_parsed_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..b39a041b3e 100644
--- a/object.h
+++ b/object.h
@@ -173,6 +173,15 @@ 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
+ * includes objects that were only referenced and never parsed. It 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_parsed_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
Range-diff against v3:
1: d61ff386fd ! 1: e13b917429 fsck: report the number of objects in the connectivity message
@@ Commit message
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
+ Add get_parsed_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().
@@ Commit message
## builtin/fsck.c ##
@@ builtin/fsck.c: static void check_connectivity(struct repository *repo)
+ }
/* Look up all the requirements, warn about missing objects.. */
- max = get_max_object_index(repo);
+- 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);
-+
++ unsigned int nr = get_parsed_object_count(repo);
+
+ fprintf_ln(stderr, Q_("Checking connectivity (%u object)",
+ "Checking connectivity (%u objects)",
+ nr),
+ nr);
+ }
-
++
++ max = get_max_object_index(repo);
for (i = 0; i < max; i++) {
struct object *obj = get_indexed_object(repo, i);
+
## object.c ##
@@ object.c: 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)
++unsigned int get_parsed_object_count(const struct repository *repo)
+{
+ return repo->parsed_objects->nr_objs;
+}
@@ object.h: int type_from_string_gently(const char *str, ssize_t, int gentle);
+/*
+ * Return the number of objects currently in the object hashmap. This
-+ * is smaller than the value get_max_object_index() returns when the
++ * includes objects that were only referenced and never parsed. It 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);
++unsigned int get_parsed_object_count(const struct repository *repo);
+
/*
* Return the object from the specified bucket in the object hashmap.
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261202200909.38901-1-aniketgupta3001@gmail.com>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76898-linux-kernel-git=dewy.ruReferences:
<20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-1-aniketgupta3001@gmail.com> <20261130123613.75255-1-aniketgupta3001@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76898-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: [GSoC PATCH v4] fsck: report the number of objects in the connectivity message
Date: Thu, 3 Dec 2026 01:39:09 +0530
Organization: Usenet Network
Message-ID: <20261202200909.38901-1-aniketgupta3001@gmail.com>
References: <20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-1-aniketgupta3001@gmail.com> <20261130123613.75255-1-aniketgupta3001@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2049324"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:tmNkTFGpiZ/+XIgVIOOc3qJrvDU= sha256:Mq/YZCLZ56dzTLcu5J0vLHxHrSfxVi3h/MGnGDgLOV4=
sha1:u6ZBR4ZFjTPL1GTz7l10MyjAwOA= sha256:AaCvqQdt7Mrtv3gTyaOo/NUSV02FYXTce2dWyiHJdQs=
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 159AF117712; Wed, 2 Dec 2026 23:09:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 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, URIBL_BLOCKED=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 aaTvBBIZQVUN;
Wed, 2 Dec 2026 23:09:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76898-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 4DFE41176F8; Wed, 2 Dec 2026 23:09:21 +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 94E492A021; Wed, 2 Dec 2026 20:09:17 +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=1796242157;
b=l+P8HfLvTWItoD2x7Yz237pxUeXY7PtfU5BzNVTFaptka9Ok4UQMUoPOi3NaAw9uR4jT
9Yykdeid9SwAK/cpmS+A5hUPSTgOX2OQfMijlHHWxs/6zRqDpaCpX9+kf5/bktLsY7Ggx
T61DTThRv3h45VpiMt+H0AjEZO3St3AZQ5bvtVIoT5+w9Y4Q2FB0nRREWZwPmvF9kialO
CW4vAdvcCJXNoJESvGsZ346Xh9FS4Al6/RK7aOTk4QT0LgmukwxRf5/WzR6oZicrMR+O9
sk2fI7yqNLeJDw+XAC1y1WSn1OfaqnxfzCLnuigYvVAhcZ4t4y1b3zneVJ2FffrdQgQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796242157;
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=+9y929NMX8M3989LpXcpLzNYqH5FQoBNobsmy5z8viM=;
b=e9KI44O0yI7zDxKqamTGzHmTbA1wxUPWAjbS4ZJU9eJTLyb/OTmOmdvIsBfNnZBkjekA
XQxEKaQX5drfvxtvOEx+KAekaYPvye+oTHiECP4pxYVjzQch3AamERVDBV6XePvvI1zUt
w4F6tqUVaHwlBOs2NwJxUjFv7qAhvZoVLjmmvxLLkEr8HXppPQP0eMvTGsCCQbKPmAZvJ
yACKH96XMjrhIYzQULmpozoolPKkJ4IU8UiJ+DJDOOBJRjfRJp3Bpxl/IJyujkK5bKYKC
tOy533WmSSAPSe65uHcKJnxdPR6oKuGp12RDAmPct3U6RAV5ulCY3wl1ygXOOu4sdzA==
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=umjcId6v;
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 6A036606A334;
Wed, 2 Dec 2026 20:09:17 +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=umjcId6v
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.169
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796242156;
b=cCuKI54nciUJTgPX+JNxSVcnovZdXOlvcF7+MnfJgCkniWXRNIoFxlGJhFlzUO6VqP6m
L9NZ5/fqQHou37Er8xIpdf0yP60Y9FTEEg5widbvfcWSJrg02lYqhU7Np/KJ+dlHknhJ3
WMAjkXvlXlY5bVMkialnUBe45yvZTaoseAH3qVEh6u4j5rMrWMvQ/ZXohpKWy0ctxoETo
r6kFvH3tYJy2tKCZjHc1xb9dMoHfFVfCmz4dMjqRnA+6D9xDkXrLiwK8yl4P0eaFPE2Xa
BwXYHUDWPgplwhidMlK5xQLL4o31+arsrE9XWdRUql1DGxFRCc9+kbTMjCyELggUSnA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796242156;
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=+9y929NMX8M3989LpXcpLzNYqH5FQoBNobsmy5z8viM=;
b=z50xYwRcoy1dFMetATiocOh0qL2swhsCDZdo6T2HMnyCwI1lU/6wngw7PnVXQtp8TPQv
YUkBjmOH7r0W5hqUJD1MOta97HrzUyYvY3yypX/WOFUe6VkdOUshlMfJTXxUWdj3EjCg0
H/93huZEM/oRuNUGG3mCtj58dUE1EKWNWU1y5bUpyIF3npuckfQbv9j+8ldqaM/Im/oyE
nf92BHKkktlmMxK3gQcoidRk+eQP76V8HpXGK/iBya9vfXL+mhQZINMl1zlU/7Rvbc+NN
QcNjv3/6JCAv12GUisQr53BDaJcNEkS9k+E/eocfKl/iux6H5ZPpLobir7gRn6oBDaA==
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=umjcId6v;
arc=none smtp.remote-ip=209.85.214.169
X-Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169])
(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 3007E606A322
for <git@vger.kernel.org>; Wed, 2 Dec 2026 20:09:16 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3007E606A322
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-pl1-f169.google.com with SMTP id d9443c01a7336-2f02b9c1f6fso1621095ad.0
for <git@vger.kernel.org>; Wed, 02 Dec 2026 12:09:15 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796242155; x=1796846955; 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=+9y929NMX8M3989LpXcpLzNYqH5FQoBNobsmy5z8viM=;
b=umjcId6v4clOltCWGfgzhofcaKaXdXmgEtTzHbi1jNEdhLDqqkf/B5vjdx1CAEFPfR
IP0mqHZjIit7iFoMPKOY3wSKUzCcFDP9rS17026f+CmTlWhlw/GjpEqIDkcybSBn/QnF
Hwcqg32RxJFFkDhYiU2MsHxX31hZMvFrkhxTFTARQZf0I2M9Oha1coz7lY561h0kitDP
dyoD6pP1tTXmjDnxHffii8yu+NU08/d+I6Jsg+y8D2l6W8gtuwSSVajeh/FOb8s51MBH
HUWvwpxxR9a9KahH02L+O+Hokxx24RsSGbl+dmIit/AlNVgSAYg3UtCn+dMfV7BhwcMm
/Cog==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796242155; x=1796846955;
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=+9y929NMX8M3989LpXcpLzNYqH5FQoBNobsmy5z8viM=;
b=rnQk38aCJi6mPPt6As3eLCA3l5QYd0W74MXCLaMqXGCYnZU3TXdpeDlLAIw50kNydc
/tbX/yNViOeBqqx34M0IEs6m278j/oRwd52hkRvsUxmf9qRZL3SIGXgcYnkvq81kUsMD
GHS3ujfJIdvjbpmI23NoR3KX1R3EO7Y6qbKt6OWxY3PkKD/lFEIHHsCHAT2K/+elVJuj
e4bAPpMprlo5Bz4pftARvN/UJE5pDZb1f0sMe9jv/ci5MwMK4rD9cWIxvitEzssui8Rp
C90UdLOFc2zg5z5tp2eXScedWPsxrk3pU+/mC4D7QFTDadZIgNGhwKIYSRMFYgPyfbCn
m/PA==
X-Gm-Message-State: APuU4Z8elxxsz9erX/Ow4pGWxm7evXXcD6+gd5eQTCdyC+QmvWXsrM0T
8bkwSCwkcEts3KDwZqe1soeBQevjoPwYxrY2iLvpcGXdOiii+2nf6hbXrBLrG63h
X-Gm-Gg: AZFdTZco6HmjOHoAssnyvqzY12MPLFHhZsj1eQd8QsSw2ELjr0NjfDHBvzGpH/kWJk0
tHznm8unrv0nvmfGfteiFIY/mV6wrHLkH0RO4bwU08UVrcc3zPM1IlCTYyrYbP8DZn8+yMsDJRl
rJCxXv5wkVYheR3FqcbQsSPg1ZY5E3io1QnPSdB3srjy8IWXcG9gXHsTaJGFL0qxDiDPr2qoQCy
s5dMT81palS1N90xAGLFRDRXD0RNKLvcm/bUDFHLQs2VcUm38we6LbjAUMqUPHHMPKkHQZTZSMw
Kh2O+27S3zA9JoLXEOIoibhg544mKvpxGHbJuy+N6M3xsfMJRxDGXsajh2UpSMCPi3yyPRwmVst
g2by4eRSNE6zZWidM87MqAcfJe2ahOsfQdLCNhO4mDAwnCo8spsNa8wz2i6omdJK8jkLL6J+TQE
rTZifJ0OTHShffROrJoEq4E07HaHgEdbLnhM+yjXHB39l7MOQZcYieMjwIAuSAq3id8UPCwxNHf
2PjQW6nCC7IsnqiNpozDfdN3pX2qrtpgYxXCys+rsyOFfvQZVR/aUvpls0t7YT3zRzYBCREJcll
x5vhIDqshGo0US1JsvlSgxd5W87UBK3rogpKryF1IrmyxJcTVg6nrnsQ/hmxqyvZmEMTvoSbibh
+9aY22O+dYEAQ5OwB67u6TCx2ilMFYQTwwnAox5FGGu4=
X-Received: by 2002:a17:902:dad0:b0:2ea:1e40:624 with SMTP id d9443c01a7336-2f03f1b80f8mr335928405ad.17.1796242155159;
Wed, 02 Dec 2026 12:09:15 -0800 (PST)
X-Received: from localhost.localdomain ([223.190.80.135])
by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f14fc8csm204111975ad.74.2026.12.02.12.09.12
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 02 Dec 2026 12:09:14 -0800 (PST)
X-Cc: Junio C Hamano <gitster@pobox.com>,
Laveesh Bansal <laveeshb@laveeshbansal.com>,
Patrick Steinhardt <ps@pks.im>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261130123613.75255-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