From patchwork Tue Jun 21 13:25:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12889312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72D4FC43334 for ; Tue, 21 Jun 2022 13:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351697AbiFUNbR (ORCPT ); Tue, 21 Jun 2022 09:31:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351716AbiFUN3M (ORCPT ); Tue, 21 Jun 2022 09:29:12 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6606B2AC5D for ; Tue, 21 Jun 2022 06:25:16 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 23so6955752pgc.8 for ; Tue, 21 Jun 2022 06:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fi65D4MYJjaJ7Lgxqk/fx1z53rLLHQyarhYPZodZC1s=; b=GEq0gQ+ttem9OqDYfgjXr0qD+j6h3s4nkyScyd2CmrFiluGMVb5a10gu2oLW+OS5W1 P+Z7jDMEVmf78HfjyxfkRUc5phXVHmD2nKGKRp1oT1bOA0sCtlfYyDTd4a6K/V5GJWaA FY8c80RrFVS57aurZXeEE+yjTdlJ0gcxpGbNh2Wh0sUFp+eIsuJiK/Inv+dq5a8YT0Pf jSsAy3BL319uDZJdvZchlNnjdc4zMOOhVHf7rt9MM6Z46K9Rw+o1k5ycK/eSp+eJ6GOd 6/vcmOzReonIaxzz70p6n4CaX+1+NpAke7/xXQGZyG/8QCz1vwN6OvI3UsuRTMNrE/qc hGrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fi65D4MYJjaJ7Lgxqk/fx1z53rLLHQyarhYPZodZC1s=; b=CePMtsCiicR6Ot57NJC8FaJMt92nL7ZT67d2jJ/fZen8UdSS8G2JnMN1EHf0i8P1aP H4KhisyPKzJevfUkG4IYIHjOA53ZqsyVbDMdsOjuDqByjEWUOorIWBcoh4IrmWyjFJF9 g0AkFqCmdpv4VRekPoL5KBznNkJi1DwNRE6YilIbeg0aIfH3tjCTMxCWlglG6rQbMehF ERpNJgCCq4sliilsadQHSLzBS/4dQESOea6v6lXJWtZplDQ6UA2CjFNO4jQhpGMVypsw lulhdxaKIlXJGpZ7SxlVPtIO0ExQd3NAZ4SHnZTr//6/2+YxHWrwItbQu2Oclrs2tp+Y hgGg== X-Gm-Message-State: AJIora+0f5Ly6jElPJCruWuaUdxIKqT3VM/HpEYN/7PuDxzZYwfd0+sD 92WP3wxEvV6q0no9WzqAt2M= X-Google-Smtp-Source: AGRyM1u0oaoGECA9eyck/sGDi4t8BD6asXlPD22cSpDNxlY9Kg+e/fXdcGRIS2laUX/0Dke3Rwxe9A== X-Received: by 2002:a63:e45:0:b0:401:9f3e:9a6c with SMTP id 5-20020a630e45000000b004019f3e9a6cmr25760667pgo.395.1655817915878; Tue, 21 Jun 2022 06:25:15 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.41]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b0016a058b7547sm8602426pln.294.2022.06.21.06.25.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2022 06:25:15 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v3 1/5] pack-bitmap.c: continue looping when first MIDX bitmap is found Date: Tue, 21 Jun 2022 21:25:01 +0800 Message-Id: <589e3f4075513b13dcd057242fa207b95371b114.1655817253.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.g270d558070.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In "open_midx_bitmap()", we do a loop with the MIDX(es) in repo, when the first one has been found, then will break out by a "return" directly. But actually, it's better to continue the loop until we have visited both the MIDX in our repository, as well as any alternates (along with _their_ alternates, recursively). The reason for this is, there may exist more than one MIDX file in a repo. The "multi_pack_index" struct is actually designed as a singly linked list, and if a MIDX file has been already opened successfully, then the other MIDX files will be skipped and left with a warning "ignoring extra bitmap file." to the output. The discussion link of community: https://public-inbox.org/git/YjzCTLLDCby+kJrZ@nand.local/ Helped-by: Taylor Blau Signed-off-by: Teng Long --- pack-bitmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 9c666cdb8b..112c2b12c6 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -494,15 +494,16 @@ static int open_pack_bitmap(struct repository *r, static int open_midx_bitmap(struct repository *r, struct bitmap_index *bitmap_git) { + int ret = -1; struct multi_pack_index *midx; assert(!bitmap_git->map); for (midx = get_multi_pack_index(r); midx; midx = midx->next) { if (!open_midx_bitmap_1(bitmap_git, midx)) - return 0; + ret = 0; } - return -1; + return ret; } static int open_bitmap(struct repository *r, From patchwork Tue Jun 21 13:25:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12889314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 251B8CCA473 for ; Tue, 21 Jun 2022 13:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351839AbiFUNeM (ORCPT ); Tue, 21 Jun 2022 09:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232707AbiFUNbB (ORCPT ); Tue, 21 Jun 2022 09:31:01 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1191B2AC5F for ; Tue, 21 Jun 2022 06:25:19 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id r66so7166967pgr.2 for ; Tue, 21 Jun 2022 06:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OTlS4nWfJ7TvnT8HtkO8kEvpLCRI9A5BzB8pCWJc7p4=; b=NABb7cyJmWZJiqpvUm59fc8LXiVqCV8WLN4NTSHBvI8PmAM/MZeiTL27bw5z2bdH/j ayjeT9qFMrT78ONIPpbrT3r/nJ83biH5pPvlrTxHixe02C/M6TdpmLNRed+7oYOB4YZE I2eJ70PNBH1rYbOZwdrR37ovQCyUplAdlQwZbO5uvGcVBPn7C8H0WcD7okfurdfk30Hr YKffXJoX8GnbAW8/n/t9m5yD2tziC2/xBCKoKaRz2MYmhOwX+OVMVjaiWvT0fA3Oa7N1 UtnQB2ImF3hkhqkFcaHsutdaQC3NyImpQySstjhCSzM4NVfnRrkuEpGAf/DSL8TLXrPH Zy0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OTlS4nWfJ7TvnT8HtkO8kEvpLCRI9A5BzB8pCWJc7p4=; b=7pX8jeoHEUBixyGn54aZ/hXKeElHi+qnhyZokibQibU+nOnJae5c1GiIIRzIpGSKit 69FKL+ZYVHaaPmY3t/X9ehoFA6MqQBDA+Fhzefm5z3POGQXd42xUUMzLkLFJTlAPHbf7 xjx9MPkLpHiVqzwmZfZxyhXsO6bBMUeKZS9NxbAiP4Mg9Ow1TGJ0XHaO1o9kzUDAUD35 TkSbfZEFUiRN719nHq6UO8BsxJrhp3ySPwHngGaN1w7PGH8t7dQbDi8QMX7yWFpIDH8v 8kH+Rjmjj+Zv0/XYJp/OtAPjp07/XLCwkXG1SwZIK3fV/23XeiNZNuycnFoUITpZLMAk qWuw== X-Gm-Message-State: AJIora8mnK6nc8+YYqa3p8d4Orz65P1yqdfHIXZg97RlryYUMrRZk3E0 hXZl9ko0+2bp5YxQ8bApJdQ= X-Google-Smtp-Source: AGRyM1uzYWQdHQ/lTTDO0TF2QLYTrqzWftJ0ZDKL0qFrxS7e+1jE98MyrL48+6FRthBNnfV74h8pKA== X-Received: by 2002:a63:2a4e:0:b0:40c:6ff9:9978 with SMTP id q75-20020a632a4e000000b0040c6ff99978mr16614487pgq.447.1655817918566; Tue, 21 Jun 2022 06:25:18 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.41]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b0016a058b7547sm8602426pln.294.2022.06.21.06.25.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2022 06:25:18 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v3 2/5] pack-bitmap.c: rename "idx_name" to "bitmap_name" Date: Tue, 21 Jun 2022 21:25:02 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.582.g270d558070.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In "open_pack_bitmap_1()" and "open_midx_bitmap_1()" we use a var named "idx_name" to represent the bitmap filename which is computed by "midx_bitmap_filename()" or "pack_bitmap_filename()" before we open it. There may bring some confusion in this "idx_name" naming, which might lead us to think of ".idx "or" multi-pack-index" files, although bitmap is essentially can be understood as a kind of index, let's define this name a little more accurate here. Signed-off-by: Teng Long --- pack-bitmap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 112c2b12c6..f13a6bfe3a 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -313,10 +313,10 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, struct multi_pack_index *midx) { struct stat st; - char *idx_name = midx_bitmap_filename(midx); - int fd = git_open(idx_name); + char *bitmap_name = midx_bitmap_filename(midx); + int fd = git_open(bitmap_name); - free(idx_name); + free(bitmap_name); if (fd < 0) return -1; @@ -368,14 +368,14 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git { int fd; struct stat st; - char *idx_name; + char *bitmap_name; if (open_pack_index(packfile)) return -1; - idx_name = pack_bitmap_filename(packfile); - fd = git_open(idx_name); - free(idx_name); + bitmap_name = pack_bitmap_filename(packfile); + fd = git_open(bitmap_name); + free(bitmap_name); if (fd < 0) return -1; From patchwork Tue Jun 21 13:25:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12889313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB390C43334 for ; Tue, 21 Jun 2022 13:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351585AbiFUNeK (ORCPT ); Tue, 21 Jun 2022 09:34:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350501AbiFUNbB (ORCPT ); Tue, 21 Jun 2022 09:31:01 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0572AC67 for ; Tue, 21 Jun 2022 06:25:21 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id h34-20020a17090a29a500b001eb01527d9eso12545248pjd.3 for ; Tue, 21 Jun 2022 06:25:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sEgHLQnfCPK8tnL9YoNpJVoKKjuvqic03Uyz1GHRvAY=; b=goetkn9ChbSvzOlbaHv5yFJVS+Z+mChzvE3VieiCJvAgTRlLVeWcLEpN4V4exKHk0V gZOqAEAi9+mIrGoLVb64Vrp8CnpNUP02kq5QPB/FTleTh5AE5+ai5H9kjNkcC+jPEigb cMd4yH+SkLR1EwSBdHoQT8hkrdqb6RNg1yfsLYgtCyuUx0G+e+bQzvtXz3AuGTxs+6LL IoVrccf13FRSBP+s8XeQ7cpWU8NVEIMHwTS0YRGfGdahzvffL074ElHpKBtvSlkAeSpv NRzHL2qsw2onT0SpwFq+KSu3UDY/LYSENk7ytKVkE3YVp8jzpDrnHs3ALAEhlMe1Mb3X EIrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sEgHLQnfCPK8tnL9YoNpJVoKKjuvqic03Uyz1GHRvAY=; b=vrkLci5vYXtGnBg+8hjYzKvMW2eozIjStzRTtelMDC1NC1bhr6l5RF+UtvriOiaQne iK0MEwjvKWc5bIIXdDuwXATwaZhKvz80G8w1Rey8Ylb9pfPyOaz+mBhsAbNZlOKpTMnX jVX1OewWAQGHmRwNyJ2D9Wj6bz8a/rhF+EmGBiLtkUH4UysE8bZd9e7t/O+NP1isvZi6 EcoA+02aGeRaZLpthawK8Bs3g42MIZLuPE1n1ZOTjrUa1ZY3vjjS5AJXZYpdVT/Khwh9 0wpNZ3ITYwbV2FW6aEmcJpsAVpoEw1oUxVjXqH10q70p79tyd8rF4l7irXszuCYbrEJS Qm7Q== X-Gm-Message-State: AJIora8+vO62oOmPWUHDaiCGWWMW9wclRCEqFOhf1cB1wz2/ud1tWQYE pJPkuf4zfqJ5AKiifnuQeIA= X-Google-Smtp-Source: AGRyM1tQaM08EumCDh8stTFLTvpNvmFoUcVysvdSZhoyAncda95zStrs40vy2OpkTLfxB9/209rEXg== X-Received: by 2002:a17:90b:504:b0:1e6:a0a4:c823 with SMTP id r4-20020a17090b050400b001e6a0a4c823mr44052120pjz.190.1655817921306; Tue, 21 Jun 2022 06:25:21 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.41]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b0016a058b7547sm8602426pln.294.2022.06.21.06.25.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2022 06:25:20 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v3 3/5] pack-bitmap.c: make warnings support i18N when opening bitmap Date: Tue, 21 Jun 2022 21:25:03 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.582.g270d558070.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When calling the "open_midx_bitmap_1()" or "open_pack_bitmap_1()", there will be a warning if a normal bitmap or MIDX bitmap already has been opened, then let's make the warning text supporting for translation. Discussion in community: 1. https://public-inbox.org/git/YkPGq0mDL4NG6D1o@nand.local/#t 2. https://public-inbox.org/git/220330.868rsrpohm.gmgdl@evledraar.gmail.com/ Helped-by: Ævar Arnfjörð Bjarmason Helped-by: Taylor Blau Signed-off-by: Teng Long --- pack-bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index f13a6bfe3a..af0f41833e 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -330,7 +330,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, struct strbuf buf = STRBUF_INIT; get_midx_filename(&buf, midx->object_dir); /* ignore extra bitmap file; we can only handle one */ - warning("ignoring extra bitmap file: %s", buf.buf); + warning(_("ignoring extra bitmap file: %s"), buf.buf); close(fd); strbuf_release(&buf); return -1; @@ -387,7 +387,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git if (bitmap_git->pack || bitmap_git->midx) { /* ignore extra bitmap file; we can only handle one */ - warning("ignoring extra bitmap file: %s", packfile->pack_name); + warning(_("ignoring extra bitmap file: %s"), packfile->pack_name); close(fd); return -1; } From patchwork Tue Jun 21 13:25:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12889316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BF7ACCA483 for ; Tue, 21 Jun 2022 13:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232465AbiFUNeR (ORCPT ); Tue, 21 Jun 2022 09:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351434AbiFUNbB (ORCPT ); Tue, 21 Jun 2022 09:31:01 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA1E2AC6E for ; Tue, 21 Jun 2022 06:25:24 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id o18so5471570plg.2 for ; Tue, 21 Jun 2022 06:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k/r8JRLHdYM+5p1XDW85HmYMw7+KNWd0BuBVGeCQ7ck=; b=OoTZUAZdnVAoEPcD4akRi54HTcmRwowzi1JVfSkYVSCcXjSdiUZ3DZTtSPBvOcYlGn gA7PtZpNmlEACIRoZXxVtZ90Vy3K09+V1fDN+Xzp09CiK82zdbGpd/LkkyOWAUGVZNwH 9G9Y8PEbP1CgPLS5golqqYbL2fOZjg/uvgMewCTev7af57skO+8UGmUdw5c7+muPWm4O e2I+REf/N14Ca7c0ezeFcSLd/x9Nbad45RQgGId2s9EqtyVjHtNqtSTb9HGi2RTmUlSN eMVHeiqEo7LKZP6fI5je30gvg4+oe4eLR5qIXdkDb9hu+RsMK+u+uEOk8dPpi9kL3kz1 tQSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k/r8JRLHdYM+5p1XDW85HmYMw7+KNWd0BuBVGeCQ7ck=; b=SXt3ZhK2YpeOrABmhejl4A4a+Zn1hqgIPS8pKLK6o0vpXtf9OKZrlx3njLA96Niszb c+/M6aFg5toItVviTrU9KVKTd5jGwKSLfu/clzGkFmXAkwdor6xNEN7Xwpx1G8vvVUQt 8Z/RoIlpYCZ0dPgQKY3PZyeHOQASAJM3x9XcR6w5lI9Mtot2NaVl7jChEKZVvklXC/7C QaosnZA8pOH8X1B7mJ5BSUYr2Z7V0PWujvf22IXp5648VB+Bw6hyQ6IbwrOtb6uFRkxY qZqmh8kLDiCXFnyr47JQrZb8S2nydxaNs0FqMIKffssHBeoqOm64xdDQp4+3+yzu3mjB Tm0A== X-Gm-Message-State: AJIora8nSb8wrUONxoaveeQJ1pIM3dZm8C8NZxh4EOs0xKVoPQrWCQdM lbFpd5G0Hd9oFcE9rFNeAmc= X-Google-Smtp-Source: AGRyM1swyuYj44q5uNnbEBf0SZwgTz6WGZPyceIDhTxfUkQaKdkq+A9xKcT5MwhGToDqrxSGubVRFg== X-Received: by 2002:a17:903:240d:b0:169:684c:dad8 with SMTP id e13-20020a170903240d00b00169684cdad8mr24455572plo.173.1655817924235; Tue, 21 Jun 2022 06:25:24 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.41]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b0016a058b7547sm8602426pln.294.2022.06.21.06.25.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2022 06:25:23 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v3 4/5] pack-bitmap.c: using error() instead of silently returning -1 Date: Tue, 21 Jun 2022 21:25:04 +0800 Message-Id: <917551f2b53196c4754d8881a383e989a02d571e.1655817253.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.g270d558070.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In "open_pack_bitmap_1()" and "open_midx_bitmap_1()", it's better to return error() instead of "-1" when some unexpected error occurs like "stat bitmap file failed", "bitmap header is invalid" or "checksum mismatch", etc. There are places where we do not replace, such as when the bitmap does not exist (no bitmap in repository is allowed) or when another bitmap has already been opened (in which case it should be a warning rather than an error). Signed-off-by: Teng Long --- pack-bitmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index af0f41833e..a54d5a0c9f 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -323,7 +323,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, if (fstat(fd, &st)) { close(fd); - return -1; + return error_errno(_("cannot stat bitmap file")); } if (bitmap_git->pack || bitmap_git->midx) { @@ -361,7 +361,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, bitmap_git->map_pos = 0; bitmap_git->map = NULL; bitmap_git->midx = NULL; - return -1; + return error(_("cannot open midx bitmap file")); } static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git *packfile) @@ -382,7 +382,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git if (fstat(fd, &st)) { close(fd); - return -1; + return error_errno(_("cannot stat bitmap file")); } if (bitmap_git->pack || bitmap_git->midx) { @@ -394,7 +394,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git if (!is_pack_valid(packfile)) { close(fd); - return -1; + return error(_("packfile is invalid")); } bitmap_git->pack = packfile; @@ -409,7 +409,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git bitmap_git->map_size = 0; bitmap_git->map_pos = 0; bitmap_git->pack = NULL; - return -1; + return error(_("bitmap header is invalid")); } return 0; From patchwork Tue Jun 21 13:25:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12889315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5FC0CCA481 for ; Tue, 21 Jun 2022 13:34:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbiFUNeP (ORCPT ); Tue, 21 Jun 2022 09:34:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351445AbiFUNbB (ORCPT ); Tue, 21 Jun 2022 09:31:01 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68C052AC71 for ; Tue, 21 Jun 2022 06:25:27 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id a15so5911954pfv.13 for ; Tue, 21 Jun 2022 06:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SwAqmWL3uzzEszhth1nDt8QRizxHE8JmPjl4J8Uz4/Q=; b=UHmuTvz6miUHN1o4CVvweoaGtBDex7JxJehRwMBT4i8yojCNZ4KUjqIlYqaTtN0QPn s+KslNRVxHf3lnOqZKhopGHSO80Ffxn+tcAVOUIhi+LYO08NdsuLYjxmgKLFoX29hM0l AgU864g+PqE4Lnz240DcSRzdtPmBlbFlC+Miwom+ShLZyuK6SPNxb2crRnVKb2fkQnEC 3tM7HuOUmaEDPfW3398bk+hGixhRT12bZdtmwBkzCFU5P0At6Cse3l4Fjti25tmLV12G RKRpvE0pEzutfxzgaQPujEhZCdNqElY+w2SxE/FhFCaq/w8M/rQ646wG8OWLB35uwX6U TUyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SwAqmWL3uzzEszhth1nDt8QRizxHE8JmPjl4J8Uz4/Q=; b=urPyZDWy4fj91BmMvKBhJ+r9BviQH1GEsh+Wri5dWn+RUUHFXSDySmnNgRSrkbUgGe pQp5qx8NSO7WpThavEZm6P6MnAKuRWckiZzHegqWINC8SrdjPFhecDBrBrbsaCFYs29R S+5Sz72kJ3lLkzgCbOiJrNB6VhI/xtutpF9nrq/9x/SlZkIndSGLVlZi9rj8H+2g6r6C UYLX4ExxlqDHrj233++fjj0BjpExwWqLPG8BiUkvRoMeF/ttmRHAbl30P0EpmUpiU3fz KULV66v4Q6TqOXLr8lGXPPoARuVxp1OUeooK5rXSLh0A1gNDx/BE5oFArTrQp6tJvnKK 4wtw== X-Gm-Message-State: AJIora9wQp5/BQybdSXpoBcg6vFde5sO+a+aC4x9iqid6/+WPW3fkS5S KTBGIrzYoD54aET4pvs73X31HZdBcwv80upj X-Google-Smtp-Source: AGRyM1usRoe1alOz/OqbqYnYiaub6wGyh472ZZdzq1BKh02JoOtv2BLIrGISRwZGiCIoll4fabkpyQ== X-Received: by 2002:a63:149:0:b0:40c:f753:2fb0 with SMTP id 70-20020a630149000000b0040cf7532fb0mr3103419pgb.172.1655817926886; Tue, 21 Jun 2022 06:25:26 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.41]) by smtp.gmail.com with ESMTPSA id f8-20020a170902684800b0016a058b7547sm8602426pln.294.2022.06.21.06.25.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2022 06:25:26 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v3 5/5] bitmap: add trace2 outputs during open "bitmap" file Date: Tue, 21 Jun 2022 21:25:05 +0800 Message-Id: <8735ae99798a43650acb9a1df7ba2072c7758476.1655817253.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.g270d558070.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org It's supported for a repo to use bitmap in both single-pack bitmap way or a multi-pack(MIDX) bitmap. Either of two bitmap kinds can exist in the repository, or both can be stored but let the config controls which kind of bitmap is used (like "core.multipackIndex", etc.). Because of this, sometimes the bitmap debug path is not obvious enough, for example, when executing: $ git rev-list --test-bitmap HEAD fatal: failed to load bitmap indexes When the output look like this, it's unclear which kind(s) of .bitmap exist, and which were read. For example, it's possible a MIDX bitmap exists, but was not read (e.g., because core.multiPackIndex=false), among many other scenarios. Therefore, we added some trace2 code so that when we read the bitmap we can be more clear about the decision path, such as whether it is working on MIDX or single-pack bitmap at present, or the related config is enabled or not. This may help with logging, user troubleshooting, and development debugging. Here are some brief output (omitted some unrelated or repetitive rows and columns, using "..." instead of) examples on two scenarios when executing: $ GIT_TRACE2_PERF=1 git rev-list --test-bitmap HEAD Scenario 1: core.multipackIndex [false], MIDX bitmap exists [Y], single-pack bitmap exists [N] ... ... | main | data | r1 | ... | config | core.multipackindex:false ... | d0 | main | region_enter | r1 | ... | pack-bitmap | label:open_bitmap ... | d0 | main | data | r1 | ... | bitmap | ..path:.git/objects/pack/pack-e9eb18e6a423057f4424a762069e13804a75d01e.bitmap ... | main | region_leave | r1 | ... | pack-bitmap | label:open_bitmap ... | main | error | | ... | | failed to load bitmap indexes fatal: failed to load bitmap indexes ... | d0 | main | exit | | ... | | code:128 ... Scenario 2: core.multipackIndex [false], MIDX bitmap exists [Y], single-pack bitmap exists [Y] ... | d0 | main | region_enter | r0 | ... | pack-bitmap | label:open_bitmap ... | d0 | main | data | r0 | ... | bitmap | ..path:/home/tenglong.tl/test/dyrone_bitmap/.git/objects/pack/pack-e9eb18e6a423057f4424a762069e13804a75d01e.bitmap ... | main | region_leave | r0 | ... | pack-bitmap | label:open_bitmap Bitmap v1 test (1 entries loaded) Found bitmap for d864fefa87415d6cd289c72aa9ffd45b4a8ffd84. 64 bits / 11030517 checksum ... | main | region_enter | r0 | ... | progress | label:Verifying bitmap entries Verifying bitmap entries: 100% (3/3), done. ... | main | data | r0 | ... | progress | ..total_objects:3 ... | main | region_leave | r0 | ... | progress | label:Verifying bitmap entries OK! ... | d0 | main | exit | | ... | | code:0 ... Signed-off-by: Teng Long --- pack-bitmap.c | 21 ++++++++++++++++----- repo-settings.c | 22 ++++++++++++---------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index a54d5a0c9f..c39d722592 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -312,9 +312,12 @@ char *pack_bitmap_filename(struct packed_git *p) static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, struct multi_pack_index *midx) { + int fd; struct stat st; + char *bitmap_name = midx_bitmap_filename(midx); - int fd = git_open(bitmap_name); + trace2_data_string("midx", the_repository, "path", bitmap_name); + fd = git_open(bitmap_name); free(bitmap_name); @@ -346,8 +349,10 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, if (load_bitmap_header(bitmap_git) < 0) goto cleanup; - if (!hasheq(get_midx_checksum(bitmap_git->midx), bitmap_git->checksum)) + if (!hasheq(get_midx_checksum(bitmap_git->midx), bitmap_git->checksum)) { + error(_("midx and bitmap checksum don't match")); goto cleanup; + } if (load_midx_revindex(bitmap_git->midx) < 0) { warning(_("multi-pack bitmap is missing required reverse index")); @@ -374,6 +379,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git return -1; bitmap_name = pack_bitmap_filename(packfile); + trace2_data_string("bitmap", the_repository, "path", bitmap_name); fd = git_open(bitmap_name); free(bitmap_name); @@ -509,11 +515,16 @@ static int open_midx_bitmap(struct repository *r, static int open_bitmap(struct repository *r, struct bitmap_index *bitmap_git) { - assert(!bitmap_git->map); + int ret = 0; + assert(!bitmap_git->map); + trace2_region_enter("pack-bitmap", "open_bitmap", r); if (!open_midx_bitmap(r, bitmap_git)) - return 0; - return open_pack_bitmap(r, bitmap_git); + goto done; + ret = open_pack_bitmap(r, bitmap_git); +done: + trace2_region_leave("pack-bitmap", "open_bitmap", r); + return ret; } struct bitmap_index *prepare_bitmap_git(struct repository *r) diff --git a/repo-settings.c b/repo-settings.c index b4fbd16cdc..115d96ece3 100644 --- a/repo-settings.c +++ b/repo-settings.c @@ -4,10 +4,12 @@ #include "midx.h" static void repo_cfg_bool(struct repository *r, const char *key, int *dest, - int def) + int def, int trace) { if (repo_config_get_bool(r, key, dest)) *dest = def; + if (trace) + trace2_data_string("config", r, key, *dest ? "true" : "false"); } void prepare_repo_settings(struct repository *r) @@ -29,8 +31,8 @@ void prepare_repo_settings(struct repository *r) r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_CONSECUTIVE; /* Booleans config or default, cascades to other settings */ - repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0); - repo_cfg_bool(r, "feature.experimental", &experimental, 0); + repo_cfg_bool(r, "feature.manyfiles", &manyfiles, 0, 0); + repo_cfg_bool(r, "feature.experimental", &experimental, 0, 0); /* Defaults modified by feature.* */ if (experimental) { @@ -42,13 +44,13 @@ void prepare_repo_settings(struct repository *r) } /* Boolean config or default, does not cascade (simple) */ - repo_cfg_bool(r, "core.commitgraph", &r->settings.core_commit_graph, 1); - repo_cfg_bool(r, "commitgraph.readchangedpaths", &r->settings.commit_graph_read_changed_paths, 1); - repo_cfg_bool(r, "gc.writecommitgraph", &r->settings.gc_write_commit_graph, 1); - repo_cfg_bool(r, "fetch.writecommitgraph", &r->settings.fetch_write_commit_graph, 0); - repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1); - repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1); - repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0); + repo_cfg_bool(r, "core.commitgraph", &r->settings.core_commit_graph, 1, 0); + repo_cfg_bool(r, "commitgraph.readchangedpaths", &r->settings.commit_graph_read_changed_paths, 1, 0); + repo_cfg_bool(r, "gc.writecommitgraph", &r->settings.gc_write_commit_graph, 1, 0); + repo_cfg_bool(r, "fetch.writecommitgraph", &r->settings.fetch_write_commit_graph, 0, 0); + repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1, 0); + repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1, 1); + repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0, 0); /* * The GIT_TEST_MULTI_PACK_INDEX variable is special in that