From patchwork Tue Jun 28 08:17:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12897906 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 38DC6C433EF for ; Tue, 28 Jun 2022 08:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244570AbiF1ITd (ORCPT ); Tue, 28 Jun 2022 04:19:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244154AbiF1ITE (ORCPT ); Tue, 28 Jun 2022 04:19:04 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398D12CE1C for ; Tue, 28 Jun 2022 01:18:00 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id h192so11506021pgc.4 for ; Tue, 28 Jun 2022 01:18:00 -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=QR7dnif8nsv3nXwQqB2Q7wKuWJBI0ake6Y+kEG/nnnA=; b=YAdkH3xAt8AjhZ7PzgsVSulypaZXYY6SPeg1kEhVT1kQP7aJcdK1apUBBQxFov4uQD yMy1mia4wV5uX46ZlKMPzDpkt+bdCHo6/ZjduyH4a7DHIpR0I0QHXNZGk3bKqLscs+tB eXCvtzbHgO/MDaOl7HcYfpQ2v6pKArjSTvVRMtpteLfbI3DWHduJwP8hVG8W5vjrwi4O C9t9/okp4J984Ieidf86jvTqVSy2gySUJob8YAW8lkosxmbYtO7WBzbEewOsDK998OGl LneG1eCo++6OgMS/z/Tejo4dKWQlqhur1dL2FmDGLNnhE95A0eb7TRlijme4Aw1Z8DkE RnEg== 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=QR7dnif8nsv3nXwQqB2Q7wKuWJBI0ake6Y+kEG/nnnA=; b=01+bliXOQ7ye98dp8LSHPC4meSUU4Ai/WLxM/CipAfocPkixFKCnTM+9+Sm6wvxXTu IMpZhpAyD3NnCbh47MJVIM3nbIafIH967BXzmdJrxtEqiY0yJpTTzZqOpCGJTfbVX6v1 dGtxmb5U1OTjBAfF7/3A2CVb3Y5WntOecMdHXIJaYwNnxzKaLmYirLeTbHep3rYwZQU2 M48TWr7kxx5yA+F2dh0x6Y03BDwXpmO9j2a6wnm1gwa50Lh1xpK7SSWBH4jL4Lh8kgur GPgTH/kIkVDOxGRSOR+QFZ+MiKMw92ZbCnUl3Y05CD1ATGI7CS0kyva6czUrdVxGoSUa Cg0w== X-Gm-Message-State: AJIora/+jYs7PM3/0HyZq2SjqalHj4Rs+R4B9VgsaXpKsqGUiesGJRi4 6IxpiGp9JIhvlZ1bbQbUYSM= X-Google-Smtp-Source: AGRyM1tGzyKDn1dRa3uPKfhbmBQaApDNnEpzX9/FTw38sT0j6bWiwKqq8WGz7bhrnoskSjo7aPrwjQ== X-Received: by 2002:a63:2b16:0:b0:3fa:faf9:e6d7 with SMTP id r22-20020a632b16000000b003fafaf9e6d7mr16212267pgr.325.1656404279668; Tue, 28 Jun 2022 01:17:59 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.34]) by smtp.gmail.com with ESMTPSA id d9-20020a170902f14900b0016368840c41sm8551206plb.14.2022.06.28.01.17.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 01:17:59 -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, git@jeffhostetler.com Subject: [PATCH v5 1/5] pack-bitmap.c: continue looping when first MIDX bitmap is found Date: Tue, 28 Jun 2022 16:17:46 +0800 Message-Id: <589e3f4075513b13dcd057242fa207b95371b114.1656403084.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.gf3b87a33da 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 28 08:17:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12897907 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 4780DCCA479 for ; Tue, 28 Jun 2022 08:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244198AbiF1ITq (ORCPT ); Tue, 28 Jun 2022 04:19:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244175AbiF1ITE (ORCPT ); Tue, 28 Jun 2022 04:19:04 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 069DD30B for ; Tue, 28 Jun 2022 01:18:03 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id n12so11394399pfq.0 for ; Tue, 28 Jun 2022 01:18:03 -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=wiUbMhmj1oXboZpE0eEjX6N9mwXCNkRKVw15kAdhNtc=; b=QKousY00B+iNq12ef3nmaySU2OZi5CI9EJXgJ0Y8AZheJbTThc/oXLLXuow/jbtIFc 3Uv5LKLKoZUgojnnlhAK76XZIlOgLbRjSDkjVUN8GBSGhDkYKZJl1ji/o4NBVUSVRdV6 1LbtLJ7aTUwrbSJJwAxulhTKHLyHj0FKgb7HWCDWG9OKuoqNWCCkvWA+dcZpCym6ml4V 4aLKHUdBnfD3dcExK5e7faw9CyI+M2c93Ula/ta5uovSSVyTzTib0kH1UyH7v6d76tdO RDAnj2wjrG1rw1L4LUQKQrhtuFXmJmX9WVsFTsLKsOFnnZdXXGUjPBkbhM0WhbhoGHFf oApQ== 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=wiUbMhmj1oXboZpE0eEjX6N9mwXCNkRKVw15kAdhNtc=; b=2NZI92KuwR4aVI9ri4iujRlQuedW+87qDFg9PIm9k1hrqj/2Vq4AnNQbtFJxsxvQUv SmQzaLB6hRSS1Dc99WaNRYzHoUW57YJhOlLipLmt96IGLlVWRGsES7qgE1FY3+Y9A1Tv uhjjo28DIrYrasM+qu6gdIWNE+RchOfG2RHRIkNMYgLvO4D4K9HFqiBxAg0NIG7Jh5Iw nE6HZjO0d1gnhVhlpOF5FRN2GUliiBWjLdytze++50PIo4SWbko+83PnD3Ca0sTmyiA9 U3X+kl2orZ/VJofwq5ePSQqGqgGRB7PjPumaod7tlIwajzQwI67y0N/rebRpUpVTrmrX H88g== X-Gm-Message-State: AJIora8B0Up8yKQy33LrVmOBa3EJQNjG0pFpKA/zevztq9cWvkBENlPC W3PqjdQb6Jp5DBdiO2AhMJ4= X-Google-Smtp-Source: AGRyM1uvUlBDTQ3+ODdPEk9zH0j1KeHW7i0aqx6d570fES/Kt4kCmMzrOVkYW49qvfcGX8YFxLcGJw== X-Received: by 2002:a63:4b49:0:b0:40d:dd27:7490 with SMTP id k9-20020a634b49000000b0040ddd277490mr10698657pgl.80.1656404282522; Tue, 28 Jun 2022 01:18:02 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.34]) by smtp.gmail.com with ESMTPSA id d9-20020a170902f14900b0016368840c41sm8551206plb.14.2022.06.28.01.17.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 01:18:02 -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, git@jeffhostetler.com Subject: [PATCH v5 2/5] pack-bitmap.c: rename "idx_name" to "bitmap_name" Date: Tue, 28 Jun 2022 16:17:47 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.582.gf3b87a33da 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 28 08:17:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12897908 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 78DF1CCA47E for ; Tue, 28 Jun 2022 08:19:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243910AbiF1ITt (ORCPT ); Tue, 28 Jun 2022 04:19:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244220AbiF1ITG (ORCPT ); Tue, 28 Jun 2022 04:19:06 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6470C75 for ; Tue, 28 Jun 2022 01:18:05 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id a15so11300848pfv.13 for ; Tue, 28 Jun 2022 01:18:05 -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=UId79//JeIuY+oKqjYOXD/Nq6lYWgpGjKSGJwa1/atA=; b=U4M+xvzlx7OIs4kVtMYPAcVN3N/KgN7whXMwQm7C/WLuc4sF1jqJtRo1cfntDLimPu UtFjpzmloQxi0hkka1Z/Nud0bcHK2l9NyR6tkqOsuw1WNT+/kkA41eLZOLZNRaIiO7CK NwrwxJtTI5KT3oXTUczCvZ4ilr9BZC0a2VX+wo9pPFABckoDAz2idaH/QYcvWtD3W8r/ Z0QZIo+K0FyGs2iI+5JtcMoBTn5pjgw9u48c0hCV+T+VDNpAH2DFoVpc2kYdbH4GIA52 YWPLexCij0zuDakpkLIxZxb209pC4KxO2GIkB/DikMZgS53GK9d9S4lkzQGA8YW0IGJ6 eewg== 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=UId79//JeIuY+oKqjYOXD/Nq6lYWgpGjKSGJwa1/atA=; b=cKjpZFwEkDITDDjE1KNjNJSJuEvEUld4rfPPC2cL1dl2FxNTniPSCGVom9rASUVwfG 0QZbY0wnPERXs58uNJ9z0tvY+qs/t+SCDnZGTzrOqN/ZzqRy6bAL771VU/AXj/YFiY0p Rz+HJsmn6Y7L4Z9p5+qDFYSfz6X0R/Lub2hGmJh+HWSkPRdbuHhwxWgexTw8nBuHfQ3y ocaDngEE34mWvAFvrOOBn3iazyWR3PfEJ5GJrYoW/ooRf76mqMAaJXhIOFviB2kTQShC scze821WFI9NGBEXGPSNZgq3rlLbRuFgT4m5dxJNRX49DnydqxTPlJ1eckxDMp0yfctM utBQ== X-Gm-Message-State: AJIora90Q3RNN9AfEVPqtqMZObCd194SrZOb59xG3SJh1MUhK/oQiq49 u8aXLA3poXImGTDnGWzETU8= X-Google-Smtp-Source: AGRyM1sV1zRm/QBf4muK3GuUW/Xe+DWDOfHRbNeo26GnP0bbf/AlEYuSYwgWtRrtEmz+RpxD1fQWhw== X-Received: by 2002:a05:6a00:1592:b0:525:7809:42c6 with SMTP id u18-20020a056a00159200b00525780942c6mr2354851pfk.64.1656404285399; Tue, 28 Jun 2022 01:18:05 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.34]) by smtp.gmail.com with ESMTPSA id d9-20020a170902f14900b0016368840c41sm8551206plb.14.2022.06.28.01.18.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 01:18:05 -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, git@jeffhostetler.com Subject: [PATCH v5 3/5] pack-bitmap.c: using error() instead of silently returning -1 Date: Tue, 28 Jun 2022 16:17:48 +0800 Message-Id: <82d4493a6ee7d18063e0feb72d0bc1cc450f2682.1656403084.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.gf3b87a33da 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 f13a6bfe3a..9f60dbf282 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 28 08:17:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12897909 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 F3A34C43334 for ; Tue, 28 Jun 2022 08:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245011AbiF1ITu (ORCPT ); Tue, 28 Jun 2022 04:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244344AbiF1ITG (ORCPT ); Tue, 28 Jun 2022 04:19:06 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA9E615D for ; Tue, 28 Jun 2022 01:18:08 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id q18so10373667pld.13 for ; Tue, 28 Jun 2022 01:18:08 -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=Bok6uTmco3tEd0qeAA344P/DWMG2aLZgrZLCXueymzY=; b=p5GMGHPtv/qI4HeNIPq8b2/XdUwbGJlqWJ6ESVuiAtQJ5DmJmBeC+ZWc/cM8qS4otw hsE1mjhGrDnt/87Mv+RBow8L4Breke4FJYxd/XYBDI1kp4QOgol64ge/K1wJd2faWuaJ oG7kb9kMQYXalHe3+fD0nFk+iGuQKNboh5PYwH2xwf2mpNgMc2C9BTN6sccKUfpndU2J 1x4Zl90vZQ7npfr9Y9bwUCpH2Zb1iNxcKlGpxpyImBdCW79CeFW8YdR9Or1I127vWR75 UWiUO51d4qp8rUsFLpMVQepMnV9l2wHDda4R7ZC4CgPd/ZCG8jGyfG3iFNPYoSuAq8B1 0ADQ== 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=Bok6uTmco3tEd0qeAA344P/DWMG2aLZgrZLCXueymzY=; b=vl2cN97lGBjUPtKM7qqgAG8jMp9KZ71eZQ7l2m3mDVGktTLIJw6k+N+llHDkZNIrnr qCx+24zrODattfAHZ7NsjLzQdDqS5nJmO37CnvtsO81u+9Hk90pS37EHNjQEh8HfwRbM P9J0esnS+4iK5spbFqro/opd7Kt2WTe//dEU0VJAS2tHRnQl+5SA78+QheGdt8rQp7UQ QhkgpRm/U120jR8ID73P1j+9BqWZ8d70NNhzlWaiXCs8JYfG4aF8D1Uq6QcfuABUg5BO A6n5Bzwl0Z/+5hCV26yXMYWehYCjxGZER/cSAShSY263BTWhSx7o0zUk3ICovi810XQy bnsQ== X-Gm-Message-State: AJIora8hSixG5UyuleOa34xhNMrSem5QNKRyFV6elRCLfx1spzzmboFB GZpb+VlrwzviWQ4UsJBbR2E= X-Google-Smtp-Source: AGRyM1uH0JupdET28bqIcMBJfgaQy7Gm0HLNQQWlJfC22zSTyRoLx8FHrvZkMo/BkGsxz+wChQ6Wqw== X-Received: by 2002:a17:902:e888:b0:16a:1b3d:aac4 with SMTP id w8-20020a170902e88800b0016a1b3daac4mr3761229plg.80.1656404288316; Tue, 28 Jun 2022 01:18:08 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.34]) by smtp.gmail.com with ESMTPSA id d9-20020a170902f14900b0016368840c41sm8551206plb.14.2022.06.28.01.18.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 01:18:07 -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, git@jeffhostetler.com Subject: [PATCH v5 4/5] pack-bitmap.c: retrieve missing i18n translations Date: Tue, 28 Jun 2022 16:17:49 +0800 Message-Id: <065b7c9ccb5a412526a934f9b67c8be64a40fc7f.1656403084.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.582.gf3b87a33da In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In pack-bitmap.c, some printed texts are translated,some are not. Let's support the translations of the bitmap related output. Signed-off-by: Teng Long --- pack-bitmap.c | 76 +++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 9f60dbf282..922b9cbc54 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -138,7 +138,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index) index->map_size - index->map_pos); if (bitmap_size < 0) { - error("Failed to load bitmap index (corrupted?)"); + error(_("Failed to load bitmap index (corrupted?)")); ewah_pool_free(b); return NULL; } @@ -160,14 +160,14 @@ static int load_bitmap_header(struct bitmap_index *index) size_t header_size = sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz; if (index->map_size < header_size + the_hash_algo->rawsz) - return error("Corrupted bitmap index (too small)"); + return error(_("Corrupted bitmap index (too small)")); if (memcmp(header->magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)) != 0) - return error("Corrupted bitmap index file (wrong header)"); + return error(_("Corrupted bitmap index file (wrong header)")); index->version = ntohs(header->version); if (index->version != 1) - return error("Unsupported version for bitmap index file (%d)", index->version); + return error(_("Unsupported version for bitmap index file (%d)"), index->version); /* Parse known bitmap format options */ { @@ -176,12 +176,12 @@ static int load_bitmap_header(struct bitmap_index *index) unsigned char *index_end = index->map + index->map_size - the_hash_algo->rawsz; if ((flags & BITMAP_OPT_FULL_DAG) == 0) - return error("Unsupported options for bitmap index file " - "(Git requires BITMAP_OPT_FULL_DAG)"); + return error(_("Unsupported options for bitmap index file " + "(Git requires BITMAP_OPT_FULL_DAG)")); if (flags & BITMAP_OPT_HASH_CACHE) { if (cache_size > index_end - index->map - header_size) - return error("corrupted bitmap index file (too short to fit hash cache)"); + return error(_("corrupted bitmap index file (too short to fit hash cache)")); index->hashes = (void *)(index_end - cache_size); index_end -= cache_size; } @@ -215,7 +215,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index, * because the SHA1 already existed on the map. this is bad, there * shouldn't be duplicated commits in the index */ if (ret == 0) { - error("Duplicate entry in bitmap index: %s", oid_to_hex(oid)); + error(_("Duplicate entry in bitmap index: %s"), oid_to_hex(oid)); return NULL; } @@ -259,14 +259,14 @@ static int load_bitmap_entries_v1(struct bitmap_index *index) struct object_id oid; if (index->map_size - index->map_pos < 6) - return error("corrupt ewah bitmap: truncated header for entry %d", i); + return error(_("corrupt ewah bitmap: truncated header for entry %d)"), i); commit_idx_pos = read_be32(index->map, &index->map_pos); xor_offset = read_u8(index->map, &index->map_pos); flags = read_u8(index->map, &index->map_pos); if (nth_bitmap_object_oid(index, &oid, commit_idx_pos) < 0) - return error("corrupt ewah bitmap: commit index %u out of range", + return error(_("corrupt ewah bitmap: commit index %u out of range"), (unsigned)commit_idx_pos); bitmap = read_bitmap_1(index); @@ -274,13 +274,13 @@ static int load_bitmap_entries_v1(struct bitmap_index *index) return -1; if (xor_offset > MAX_XOR_OFFSET || xor_offset > i) - return error("Corrupted bitmap pack index"); + return error(_("Corrupted bitmap pack index")); if (xor_offset > 0) { xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET]; if (xor_bitmap == NULL) - return error("Invalid XOR offset in bitmap pack index"); + return error(_("Invalid XOR offset in bitmap pack index")); } recent_bitmaps[i % MAX_XOR_OFFSET] = store_bitmap( @@ -305,7 +305,7 @@ char *pack_bitmap_filename(struct packed_git *p) size_t len; if (!strip_suffix(p->pack_name, ".pack", &len)) - BUG("pack_name does not end in .pack"); + BUG(_("pack_name does not end in .pack")); return xstrfmt("%.*s.bitmap", (int)len, p->pack_name); } @@ -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; } @@ -819,7 +819,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git, revs->include_check_data = &incdata; if (prepare_revision_walk(revs)) - die("revision walk setup failed"); + die(_("revision walk setup failed")); show_data.bitmap_git = bitmap_git; show_data.base = base; @@ -1134,7 +1134,7 @@ static void filter_bitmap_tree_depth(struct bitmap_index *bitmap_git, unsigned long limit) { if (limit) - BUG("filter_bitmap_tree_depth given non-zero limit"); + BUG(_("filter_bitmap_tree_depth given non-zero limit")); filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TREE); @@ -1148,7 +1148,7 @@ static void filter_bitmap_object_type(struct bitmap_index *bitmap_git, enum object_type object_type) { if (object_type < OBJ_COMMIT || object_type > OBJ_TAG) - BUG("filter_bitmap_object_type given invalid object"); + BUG(_("filter_bitmap_object_type given invalid object")); if (object_type != OBJ_TAG) filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter, OBJ_TAG); @@ -1304,14 +1304,14 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, revs->ignore_missing_links = 0; if (haves_bitmap == NULL) - BUG("failed to perform bitmap walk"); + BUG(_("failed to perform bitmap walk")); } wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap, filter); if (!wants_bitmap) - BUG("failed to perform bitmap walk"); + BUG(_("failed to perform bitmap walk")); if (haves_bitmap) bitmap_and_not(wants_bitmap, haves_bitmap); @@ -1432,7 +1432,7 @@ uint32_t midx_preferred_pack(struct bitmap_index *bitmap_git) { struct multi_pack_index *m = bitmap_git->midx; if (!m) - BUG("midx_preferred_pack: requires non-empty MIDX"); + BUG(_("midx_preferred_pack: requires non-empty MIDX")); return nth_midxed_pack_int_id(m, pack_pos_to_midx(bitmap_git->midx, 0)); } @@ -1629,15 +1629,15 @@ static void test_bitmap_type(struct bitmap_test_data *tdata, } if (bitmap_type == OBJ_NONE) - die("object %s not found in type bitmaps", + die(_("object %s not found in type bitmaps"), oid_to_hex(&obj->oid)); if (bitmaps_nr > 1) - die("object %s does not have a unique type", + die(_("object %s does not have a unique type"), oid_to_hex(&obj->oid)); if (bitmap_type != obj->type) - die("object %s: real type %s, expected: %s", + die(_("object %s: real type %s, expected: %s"), oid_to_hex(&obj->oid), type_name(obj->type), type_name(bitmap_type)); @@ -1651,7 +1651,7 @@ static void test_show_object(struct object *object, const char *name, bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid); if (bitmap_pos < 0) - die("Object not in bitmap: %s\n", oid_to_hex(&object->oid)); + die(_("Object not in bitmap: %s\n"), oid_to_hex(&object->oid)); test_bitmap_type(tdata, object, bitmap_pos); bitmap_set(tdata->base, bitmap_pos); @@ -1666,7 +1666,7 @@ static void test_show_commit(struct commit *commit, void *data) bitmap_pos = bitmap_position(tdata->bitmap_git, &commit->object.oid); if (bitmap_pos < 0) - die("Object not in bitmap: %s\n", oid_to_hex(&commit->object.oid)); + die(_("Object not in bitmap: %s\n"), oid_to_hex(&commit->object.oid)); test_bitmap_type(tdata, &commit->object, bitmap_pos); bitmap_set(tdata->base, bitmap_pos); @@ -1683,26 +1683,26 @@ void test_bitmap_walk(struct rev_info *revs) struct ewah_bitmap *bm; if (!(bitmap_git = prepare_bitmap_git(revs->repo))) - die("failed to load bitmap indexes"); + die(_("failed to load bitmap indexes")); if (revs->pending.nr != 1) - die("you must specify exactly one commit to test"); + die(_("you must specify exactly one commit to test")); - fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n", + fprintf(stderr, _("Bitmap v%d test (%d entries loaded)\n"), bitmap_git->version, bitmap_git->entry_count); root = revs->pending.objects[0].item; bm = bitmap_for_commit(bitmap_git, (struct commit *)root); if (bm) { - fprintf(stderr, "Found bitmap for %s. %d bits / %08x checksum\n", + fprintf(stderr, _("Found bitmap for %s. %d bits / %08x checksum\n"), oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm)); result = ewah_to_bitmap(bm); } if (result == NULL) - die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid)); + die(_("Commit %s doesn't have an indexed bitmap"), oid_to_hex(&root->oid)); revs->tag_objects = 1; revs->tree_objects = 1; @@ -1711,7 +1711,7 @@ void test_bitmap_walk(struct rev_info *revs) result_popcnt = bitmap_popcount(result); if (prepare_revision_walk(revs)) - die("revision walk setup failed"); + die(_("revision walk setup failed")); tdata.bitmap_git = bitmap_git; tdata.base = bitmap_new(); @@ -1719,7 +1719,7 @@ void test_bitmap_walk(struct rev_info *revs) tdata.trees = ewah_to_bitmap(bitmap_git->trees); tdata.blobs = ewah_to_bitmap(bitmap_git->blobs); tdata.tags = ewah_to_bitmap(bitmap_git->tags); - tdata.prg = start_progress("Verifying bitmap entries", result_popcnt); + tdata.prg = start_progress(_("Verifying bitmap entries"), result_popcnt); tdata.seen = 0; traverse_commit_list(revs, &test_show_commit, &test_show_object, &tdata); @@ -1727,9 +1727,9 @@ void test_bitmap_walk(struct rev_info *revs) stop_progress(&tdata.prg); if (bitmap_equals(result, tdata.base)) - fprintf(stderr, "OK!\n"); + fprintf(stderr, _("OK!\n")); else - die("mismatch in bitmap results"); + die(_("mismatch in bitmap results")); bitmap_free(result); bitmap_free(tdata.base); @@ -1747,7 +1747,7 @@ int test_bitmap_commits(struct repository *r) MAYBE_UNUSED void *value; if (!bitmap_git) - die("failed to load bitmap indexes"); + die(_("failed to load bitmap indexes")); kh_foreach(bitmap_git->bitmaps, oid, value, { printf("%s\n", oid_to_hex(&oid)); @@ -1825,8 +1825,8 @@ uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git, if (!bitmap_is_midx(bitmap_git)) load_reverse_index(bitmap_git); else if (load_midx_revindex(bitmap_git->midx) < 0) - BUG("rebuild_existing_bitmaps: missing required rev-cache " - "extension"); + BUG(_("rebuild_existing_bitmaps: missing required rev-cache " + "extension")); num_objects = bitmap_num_objects(bitmap_git); CALLOC_ARRAY(reposition, num_objects); From patchwork Tue Jun 28 08:17:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12897910 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 0F7C2C433EF for ; Tue, 28 Jun 2022 08:19:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244238AbiF1ITw (ORCPT ); Tue, 28 Jun 2022 04:19:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244226AbiF1ITG (ORCPT ); Tue, 28 Jun 2022 04:19:06 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD66B65EF for ; Tue, 28 Jun 2022 01:18:11 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id c4so10391114plc.8 for ; Tue, 28 Jun 2022 01:18:11 -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=MfKkdjno+WrBH9glqxySVKSZf4JT07QftT/YpA39pt8=; b=XA+H+QXOV5RdSenrIuUsEe3UppVIn9cAkobyuFtuEJ9cp7kAc9AkpzPk6dA1RJraEI NvZLch1g5PMk2vasCeILNiIUubqPJtK5uTVP+5lA8DYB6cViX88Jym8s+EoN/BO3Z/zx VQfYt6/GkwljV16c5MKsOCtryDzEw1XVkeMzG3WA9pAsN4Y2MCHCKpybYrZBEOIuygXU zv2Vm6ePa9jTMkIEfD7Wd121rXyUYBaTHNDjrQ0nZLZOjtppEUJ5qkS1uQ6jbhRwMVH8 3eLiFtc9FOiQe1RuJcs3YLOMWS9TmuNTFdcZnZB62o39gQKbUl+KXrKu18KYlb9sHcyW wjAg== 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=MfKkdjno+WrBH9glqxySVKSZf4JT07QftT/YpA39pt8=; b=Ycp0IghNj/UfwaC0jJIbxTh96sZbIM5b7M+Rgn9K2kuNIXzX7YOrmqKz7w68wijYwx 3fAmVNW0dZQCSs4RHfS/KIhDpbLQmOnKOQq76Y82kg8pOMqcHIwELcQGu2C4Ig88x91Q HTMzQLgDy6BGoqbm2nCx1/jOPuQiUxrJ4YGl85GcdlTw0L7QnWpzZETPEmXsRlX5Xij7 h+lbOmAiXcSgtLUixzBZzUqGTdp5r8xr+fRNlcPSQD67gOHV09eow/ZbhoMwWeDJbtU5 rI+Tc15h90cH1D1vRXJxHzeBA+fLqrPtdlNjBKkbX99WBMxgBUn+lbO6aWEGssPGZT36 1sWg== X-Gm-Message-State: AJIora9+5QNgt8dCTfzajhRpxh5rwST5VCyjxG40urgXONCZBXOFzqwK 2xMvuFTDAKqxfmjBb/OyW/c= X-Google-Smtp-Source: AGRyM1vtGjrpaW1peqdeZs0kglkTZlMlrwBCUkIOi/2yu2AbrHlUZFf8FSNVZfxC11MN535Ev48zCg== X-Received: by 2002:a17:903:2145:b0:16a:65c:353c with SMTP id s5-20020a170903214500b0016a065c353cmr2529645ple.44.1656404291336; Tue, 28 Jun 2022 01:18:11 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.34]) by smtp.gmail.com with ESMTPSA id d9-20020a170902f14900b0016368840c41sm8551206plb.14.2022.06.28.01.18.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2022 01:18:10 -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, git@jeffhostetler.com Subject: [PATCH v5 5/5] tr2: avoid to print "interesting" config repeatedly Date: Tue, 28 Jun 2022 16:17:50 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.582.gf3b87a33da In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We can use GIT_TRACE2_CONFIG_PARAMS and trace2.configparams to dump the config which we are inteseted in to the tr2 log. If an "interesting" config exists in multiple scopes, it will be dumped multiple times. So, let's fix it to only print the final value instead. Signed-off-by: Teng Long Helped-by: Jeff Hostetler --- trace2/tr2_cfg.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/trace2/tr2_cfg.c b/trace2/tr2_cfg.c index ec9ac1a6ef..632bb6feec 100644 --- a/trace2/tr2_cfg.c +++ b/trace2/tr2_cfg.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "strmap.h" #include "trace2/tr2_cfg.h" #include "trace2/tr2_sysenv.h" @@ -10,6 +11,7 @@ static int tr2_cfg_loaded; static struct strbuf **tr2_cfg_env_vars; static int tr2_cfg_env_vars_count; static int tr2_cfg_env_vars_loaded; +static struct strset tr_cfg_set = STRSET_INIT; /* * Parse a string containing a comma-delimited list of config keys @@ -101,12 +103,17 @@ static int tr2_cfg_cb(const char *key, const char *value, void *d) { struct strbuf **s; struct tr2_cfg_data *data = (struct tr2_cfg_data *)d; + const char *prior_value; for (s = tr2_cfg_patterns; *s; s++) { struct strbuf *buf = *s; int wm = wildmatch(buf->buf, key, WM_CASEFOLD); if (wm == WM_MATCH) { - trace2_def_param_fl(data->file, data->line, key, value); + if (strset_contains(&tr_cfg_set, key) + || git_config_get_value(key, &prior_value)) + continue; + trace2_def_param_fl(data->file, data->line, key, prior_value); + strset_add(&tr_cfg_set, key); return 0; } }