Article View: linux.kernel.git
Article #4067[GSoC PATCH v2] fsck: report the number of objects in the connectivity message
From: Aniket Gupta
Date: Sun, 29 Nov 2026 10:02
Date: Sun, 29 Nov 2026 10:02
113 lines
14260 bytes
14260 bytes
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.
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 <aniketgupta3001@gmail.com>
Reviewed-by: Laveesh Bansal <laveeshb@laveeshbansal.com>
---
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.
- Add Laveesh's Reviewed-by.
- Rebase onto current master.
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);
+ }
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..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);
+
/*
* 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
+'
+
test_done
base-commit: acba8bf9753134d9bde89f94369f775838a8c5fe
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261129100214.46634-1-aniketgupta3001@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76621-linux-kernel-git=dewy.ruReferences:
<20261020102134.42151-1-aniketgupta3001@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76621-linux-kernel-git=dewy.ru
From: aniketgupta3001@gmail.com (Aniket Gupta)
Newsgroups: linux.kernel.git
Subject: [GSoC PATCH v2] fsck: report the number of objects in the connectivity message
Date: Sun, 29 Nov 2026 15:32:14 +0530
Organization: Usenet Network
Message-ID: <20261129100214.46634-1-aniketgupta3001@gmail.com>
References: <20261020102134.42151-1-aniketgupta3001@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1145624"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:V9kE9uU8e7MNAIjSQq7Rq+ySfHs= sha256:ozWeA+y6BcXp+VZFeyXI+DLwfyQ3X4RpUkXapI+rqlo=
sha1:nRv3RAgQVZEXwO97O4Gwj1Kd9CU= sha256:JqNoxnk27G/+hpTKs/T+iXTPIJ06A5ZRFbnGdFe3D2U=
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 E151D125F97; Sun, 29 Nov 2026 13:02:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, 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 83gm-kvYFzOM;
Sun, 29 Nov 2026 13:02:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-76621-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 42CD4125CEE; Sun, 29 Nov 2026 13:02:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sin.lore.kernel.org (Postfix) with ESMTP id F3E8922290; Sun, 29 Nov 2026 10:02:23 +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=1795946541;
b=Z/KxGmGfxCOXNdJ5yG4wxCiNVJx0NQ29g/IG2YgWtIDOszK0UjPQ2GHE2NNNZYoEQ0KZ
kzZwHIhiqckFpMqLav6ZbagV5CchM6o1aNHQ80fFR+CXjl7S0kLdwZjfeNMFqTKyIia9j
j/5qznOst2J0HMd1MJ2sQtZtcgV0A91kf4KmLRoFdOTWWvCxwRtxJfUUfEBsAkRcp4WAr
+vixt7lSOOBa1SYlrWnj4EzAPBUWI71bhX6WTnC/weSQ47YuIWBgoG+dciCIznsmYaQVB
zyo7CV0Znk5uUJlklIkxifRFj/MIodTSvNstUbvlMAQIsB+XSE+FzBwG/DL38VVGDCA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795946541;
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=RWczS3/9dMNfAb4qTpTQbj9T2Rdx4Y3T0hEt3qEI870=;
b=xGrwKCzxve+I+/82Wq530j+f+PmlLIxciy9glm4qSCIEvZK1gRuCz1oXahw2MdKkvdvU
VTL8bqLSZ9SZzOnvZAB55mJjxB+aPqfIkzJgS9ppxeOgwDxyWUB7XtXEmaiR3jZa2iSGf
N1bRl6I2XXJAdrX/WPf8a1Dk+64ixd29nDLZxeYYFgccMZWBWf4WwdvyPOp9Kghjcxrbr
TJh/Ot0eIzzsKTSQV5Hog9+/hBAtV3jKjb91wGXO/K9jtdvB9G0rOpS6SWn/vd6RD0azj
A01E3+0PBewxWydvIrgHzi79cw+7PdkeWP5TJK91FYYkz59W3x6ELhdHCyS+S1WPsbQ==
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=SZwSAh0d;
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 A9DC8606A32C;
Sun, 29 Nov 2026 10:02:21 +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=SZwSAh0d
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795946540;
b=wJC2cCDydg6bV1WltnVyWPCqDX0fDT4Lc7GMC7CSoPjAQgsdYEjMZMWgSWHGCmz28ZLo
vUKcKj2zLwvHf8FMD0Uhba3z+ss7ynCnwosSJKvnu1M/mhf24JfHIq78dqcJgllt1t4i6
ugELaow9LZo9o0ttDYV34A55z4yG//X3AS8LuDq4mUFHhxYjVPF9RkFnMmbpnKqeM1ERS
LEIEpDRRBGIygeQ7+zdr7WxIL7/hI+uoneXLiyQPQOKsLUA6c/HbExVTfZbHwq1+ISsFh
uTz6Ju37tljCwGGOee60LnA1m0RkYf+OJhvqjYMl0GxTZvI6XbZ6xGcR6M1P7gMZX+A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795946540;
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=RWczS3/9dMNfAb4qTpTQbj9T2Rdx4Y3T0hEt3qEI870=;
b=2m3l3hn2QFyDwMom/lgc7FzC15I6lIarx3EP9xkkBZGjlC24sobSgvFeaqWcO62H2cBX
m+E8opw5fMMFK2G/vvsrbeFSLiYa9RjRWoxmz44C7BjaMmskByVmBuvcgXp5jC3GN+AgE
Rnyh0h4TeyX+eow2lEGYPUCfXMQhWjqTPFz/I4IsgH/nzDecUn3YsPRMshefqXGDCJdRG
bmfmH8GGJjxG7kK1bhevSkYXSQfMt4FhFzWFri0VAx7ils/A30wtzOV4gesyPG48DknPe
nK4A5I31RBUPgiUvueec+Sd0yi0zVBANg+93fbH3A69rHQZhvUveqnx0LKoZGH/whqQ==
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=SZwSAh0d;
arc=none smtp.remote-ip=209.85.214.181
X-Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181])
(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 793EF606A31C
for <git@vger.kernel.org>; Sun, 29 Nov 2026 10:02:20 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 793EF606A31C
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-f181.google.com with SMTP id d9443c01a7336-2f0458cc9easo74013085ad.3
for <git@vger.kernel.org>; Sun, 29 Nov 2026 02:02:20 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795946540; x=1796551340; 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=RWczS3/9dMNfAb4qTpTQbj9T2Rdx4Y3T0hEt3qEI870=;
b=SZwSAh0dtv8jozYxZVXpiDuJg10KrKhjM+FbOof93Gf4QX0xMvJbEz4ZA7pIZFdkr5
J5BrF3NtdVm2QNi8kiPO16W9wwJXTIBbYGRkiJ9rjNcozcYoSfViTjUbIjgcCO6UzPXE
BMP0lQNyh8Vo903bZABUJxSFZYymfuvJ+z+Gb3K6jfU+1jAyIyt+sdW4D8Rx6iWNCOXF
xvBHlLYmLfRZhlxbxNvzdka+C+etB6cl3g7oCGtFTb4R6svnEJMd9Dj0vnBX/4cEP0DB
MqSZf43m7Yzj3aXsX0gfkVViFAdZ+JEMH0avOuOAyGphBpRAy6BWHqeIyN2z/HPWowHh
4ytQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795946540; x=1796551340;
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-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rb
VKpPbgfu9BliUq9n9Co7TFBJgGjxqcUwlfiaRZm9b8TQPfx5GT2GP+ya6eRWHWic86BFuq5LZcZ
tpZrhsFrsSqKGlXUb4uX9Qd0At51v1JVVXle9sB7JLKXhc6QypOIOQQ5j7lcWkj0KuR8F32GU1T
E2irMP0w5eJUDh3M9ad4S
X-Received: by 2002:a17:903:19e7:b0:2ef:e044:290c with SMTP id d9443c01a7336-2f03f1a1bd7mr305316015ad.25.1795946539692;
Sun, 29 Nov 2026 02:02:19 -0800 (PST)
X-Received: from localhost.localdomain ([223.190.82.63])
by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f099a4d875sm106404585ad.37.2026.11.29.02.02.17
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Sun, 29 Nov 2026 02:02:19 -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: <20261020102134.42151-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