From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.181 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== 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== 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 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 ; Sun, 29 Nov 2026 10:02:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 793EF606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2f0458cc9easo74013085ad.3 for ; Sun, 29 Nov 2026 02:02:20 -0800 (PST) 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-to:content-type; bh=RWczS3/9dMNfAb4qTpTQbj9T2Rdx4Y3T0hEt3qEI870=; b=2dhROlMbwzqqnfLzN4yEuLWuRnOyhVJtuXXP2y1zQRNkUqjlpfCT7Q0Iy3EAt+F571 HHtn6dFIfAHUAiWMPLXKGqK6OVHuam8kl46YLi94Lir2QpR8DnaCKUHoUyLsMdHYSTa+ ml552q+UGKy3b1Q1393Y7f3FxMrjui6WK4JNQMMk1t615bA00EzWJmlD3FEDf1xgWJga eXPV6/cEb8ry18sMbrKARqwmMkgEfAvHBYb7DRq3o+95snAPDuJ1muP0E1jyOlYUT81M +n6tCS3n8j6ki8beKTDL8WUG7BY7KlZ4n7k5kAAZD+pytB+TtoVgHF6f4qv5bbWTjLDZ n56g== X-Gm-Message-State: APuU4Z9pY59/vgNKljT1LZdyIhspkvQUWs0cjtt8tnNlV41Yr7Zv2/82 po/Wi9ekPH9pCjL7ijCKjp1buv4L+W4zUX1cl3fbu//bHrVkIjLuDquso1heDayI X-Gm-Gg: AZFdTZdtpDk/S17vgVr38ib3HlcCb2IPhhE3RVUGJJwRCLGLo3W8lhKQsygs0M+A2SS 3zAq4Adgc8X6sM2GMwSiiR/d6Z3pV0n1ifEQk8gpWEKWns5Nz1QAnFibk6ZJoPahQRAFsh8D7vM kDA7nRlHZ2raT9/LvUMzZrFOyNIKZ2Oc/eMcNLHuLMnh9y3A+q5RNviNJVIWaHpGV628wVrgTyR qUp1PLgfgJGFHKIRny9rnHDgcpeXZCN0pkdzAgIWxPyXd1ArtDC1BfQDNl80S7YIKzntchd+yrd RVm1EOVq/8WbinFtArRp7XrEkAJeGlnmaA7a7rrkZzWOAduQ7fDHzjOdjz0BbHWrKzprhcgpm8U OSmW2d/6Eq1z2y1nhmRnFDsnpa+ev681gyL59kM41CSuoDPAoIXVjOMDT2OEFk6FrRaxjqGWWFr lIsedycLuAQudIiPM4FHzbLJsMVnO3VJg+Oh63WXVL93kI2A6ExYMbYg8lavK53/5rKsT2TV0rb 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) 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) From: Aniket Gupta To: git@vger.kernel.org Cc: Junio C Hamano , Laveesh Bansal Subject: [GSoC PATCH v2] fsck: report the number of objects in the connectivity message Date: Sun, 29 Nov 2026 15:32:14 +0530 Message-ID: <20261129100214.46634-1-aniketgupta3001@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261020102134.42151-1-aniketgupta3001@gmail.com> References: <20261020102134.42151-1-aniketgupta3001@gmail.com> 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-Transfer-Encoding: 8bit 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 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. - 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)