From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 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== 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== 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 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 ; Mon, 30 Nov 2026 12:36:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3FBBC606A31C 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=SWSVjOk0 Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-38190551625so19631482eec.1 for ; Mon, 30 Nov 2026 04:36:19 -0800 (PST) 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) 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) From: Aniket Gupta To: git@vger.kernel.org Cc: Junio C Hamano , Laveesh Bansal Subject: [GSoC PATCH v3] fsck: report the number of objects in the connectivity message Date: Mon, 30 Nov 2026 18:06:13 +0530 Message-ID: <20261130123613.75255-1-aniketgupta3001@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261129100214.46634-1-aniketgupta3001@gmail.com> References: <20261020102134.42151-1-aniketgupta3001@gmail.com> <20261129100214.46634-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 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 Reviewed-by: Laveesh Bansal --- 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)