From patchwork Mon Jul 11 12:43:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12913653 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 24E06CCA480 for ; Mon, 11 Jul 2022 12:44:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231771AbiGKMou (ORCPT ); Mon, 11 Jul 2022 08:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbiGKMo2 (ORCPT ); Mon, 11 Jul 2022 08:44:28 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 018A76111D for ; Mon, 11 Jul 2022 05:44:21 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 89-20020a17090a09e200b001ef7638e536so8186994pjo.3 for ; Mon, 11 Jul 2022 05:44:20 -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=ce/thzzPgRSp4IHk7tN5cZqHJOAmwVizorFgazv7hzE=; b=iupHRD+7ywKZRnCQ3EimQ6UL6wVkmV+bvNpysw46BLEZxKP+TRzgKtX6i6t55yuol5 NHebWywhwmKh51DKxctjRMEWcsgwX6XDs54u5oegjYRZNH5TvEHT3xkE6x6a0vBKHDRv 8NenRZyikwzW7s6JS8D0raRU6AQFhi+KaXhJ2n3m27ZLCypFksnO/C2xx4Dkucm8FPhS txP6mlwC7Jz7dR8LVA2h4rPIMob5r6gK1TfP2halcHEPktKy13jKaR4PuptV4Ryrbzsl eWtpMmlnTZ7L3UhTUde+8MfTjP3HsI6M7XoK5bq9b4oJ83cr4vUIvcT6jSRHP7Y8igJz oPnA== 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=ce/thzzPgRSp4IHk7tN5cZqHJOAmwVizorFgazv7hzE=; b=01e9axU5LXQ6Aa9KHKO7/V+qM30mitn8dNs/DgZY2v1BrgoPc0u92KdadS72cgfp43 fgYLk83hikiSDpG9wOBLNs4a+sKCvm6zlQ46oUcqkVEBuuRqJo1zb/M/+gcC2E0vNPOR 0Rj2Th4fy/3HSyIHHubBw6D/MkFjZZ3wODKGvqDZVO9NcCLBzRMEH1uffx1CgzQ4Zz00 pt4g59Xfs8IU9NqeiouCYD8kksXzz+mFUVB9J6h0oEriF6tpX3FDDfnA1d33dhhAzMgX cZ5+rLYA8TTlFkvce8+6vNYRAQARVI1/uJRlYmDrIUKd0cgpYR4jS+K6KPLXrpa6A1/T ZXeg== X-Gm-Message-State: AJIora9g/bVRZdUNyePBWqCUXQ0gEIXaw910Aq8KklTP3OfwrvVHpT4N h5liF6USJSLQyAskRJOajVg= X-Google-Smtp-Source: AGRyM1vWU/COEtEkYmpjUxWSsVTf8eyWTaYnw4+bNrDfj09t+8pbeU/ENVlrsMwnPAsChPRPMIla4A== X-Received: by 2002:a17:902:cec5:b0:16c:4108:d292 with SMTP id d5-20020a170902cec500b0016c4108d292mr7147866plg.137.1657543460174; Mon, 11 Jul 2022 05:44:20 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:19 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 1/7] clean: fixed issues related to text output format Date: Mon, 11 Jul 2022 20:43:57 +0800 Message-Id: <94a64ba895a8eb9eb7d502e94cf3d9fdfb9d2887.1657540174.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There are some text output issues in 'pack-bitmap.c', they exist in die(), error() etc. This includes issues with capitalization the first letter, newlines, error() instead of BUG(), and substitution that don't have quotes around them. Signed-off-by: Teng Long --- pack-bitmap.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 9c666cdb8b..0fdba5e8c5 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1,5 +1,6 @@ #include "cache.h" #include "commit.h" +#include "strbuf.h" #include "tag.h" #include "diff.h" #include "revision.h" @@ -138,7 +139,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 +161,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 '%d' for bitmap index file", index->version); /* Parse known bitmap format options */ { @@ -176,7 +177,7 @@ 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 " + BUG("unsupported options for bitmap index file " "(Git requires BITMAP_OPT_FULL_DAG)"); if (flags & BITMAP_OPT_HASH_CACHE) { @@ -215,7 +216,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; } @@ -274,13 +275,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( @@ -330,7 +331,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 +388,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; } @@ -1628,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)); @@ -1650,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'", oid_to_hex(&object->oid)); test_bitmap_type(tdata, object, bitmap_pos); bitmap_set(tdata->base, bitmap_pos); @@ -1665,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'", oid_to_hex(&commit->object.oid)); test_bitmap_type(tdata, &commit->object, bitmap_pos); bitmap_set(tdata->base, bitmap_pos); @@ -1687,21 +1688,21 @@ void test_bitmap_walk(struct rev_info *revs) if (revs->pending.nr != 1) die("you must specify exactly one commit to test"); - fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n", + fprintf_ln(stderr, "Bitmap v%d test (%d entries loaded)", 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_ln(stderr, "Found bitmap for '%s'. %d bits / %08x checksum", 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; @@ -1726,7 +1727,7 @@ void test_bitmap_walk(struct rev_info *revs) stop_progress(&tdata.prg); if (bitmap_equals(result, tdata.base)) - fprintf(stderr, "OK!\n"); + fprintf_ln(stderr, "OK!"); else die("mismatch in bitmap results"); @@ -1749,7 +1750,7 @@ int test_bitmap_commits(struct repository *r) die("failed to load bitmap indexes"); kh_foreach(bitmap_git->bitmaps, oid, value, { - printf("%s\n", oid_to_hex(&oid)); + printf_ln("%s", oid_to_hex(&oid)); }); free_bitmap_index(bitmap_git); @@ -1774,7 +1775,7 @@ int test_bitmap_hashes(struct repository *r) nth_bitmap_object_oid(bitmap_git, &oid, index_pos); - printf("%s %"PRIu32"\n", + printf_ln("%s %"PRIu32"", oid_to_hex(&oid), get_be32(bitmap_git->hashes + index_pos)); } @@ -1936,7 +1937,7 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git, struct object_id oid; nth_midxed_object_oid(&oid, bitmap_git->midx, midx_pos); - die(_("could not find %s in pack %s at offset %"PRIuMAX), + die(_("could not find '%s' in pack '%s' at offset %"PRIuMAX), oid_to_hex(&oid), pack->pack_name, (uintmax_t)offset); @@ -1972,7 +1973,7 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git) continue; if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0) - die(_("unable to get disk usage of %s"), + die(_("unable to get disk usage of '%s'"), oid_to_hex(&obj->oid)); total += object_size; From patchwork Mon Jul 11 12:43:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12913654 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 34304CCA47B for ; Mon, 11 Jul 2022 12:44:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232098AbiGKMoz (ORCPT ); Mon, 11 Jul 2022 08:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231993AbiGKMoc (ORCPT ); Mon, 11 Jul 2022 08:44:32 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 868D261D92 for ; Mon, 11 Jul 2022 05:44:23 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id 72so4682098pge.0 for ; Mon, 11 Jul 2022 05:44:23 -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=l3Tr6soU1NU8ORkEpmKHQgXT/C87uEL2t+Pv5fLyRFA=; b=RHU9dlKinxlvOpSMZbc5s8T13mbYo40rrg7Q4976mf8KDczCtyTdlpKBKIF1eZaFvV +1awIN+zOCuj4J4hMc43rOAwROMK6w2hDZY6UxeMgGGfC3hPFEKJ7JfDd/41jvaVxBBo CtlO5lnLooC6kaKcjF2M1Son9bWK4F73Maicu29B4nlV8T1DIQsXQbGlsq9A8lA+3m3D Tz637fr47uq1E+CTxdZTJV5DEinCkJ2+VSU6mH2//K8Iz4NljN+JiolpP6FdFeCgqVMK pVhiqlIACxoijySKuxlKn9HQ/YfjscTr+9hWNz86a0vRT2208NLRb+utkiW7XG3E0VyJ hTHg== 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=l3Tr6soU1NU8ORkEpmKHQgXT/C87uEL2t+Pv5fLyRFA=; b=CQBdSnOEvPwGt5TUEFVyZ9Vv/BKXIVLO+O1tGxQifwbD9C0gXBiEbe3f+A/v6wtfPi ik5lUn2OENMoO5RbaV4M9rm6k/fkNppTzPSkEhcWnbRmXcycuA/6HJF5pj1xURyZwu9x DWfB6sUW7t0HJiwxVErGhzhsksw6t7YyLJCkpTI9dQQjU3hK24mHNol295bH3GmrX7WX NATIAEBnLVi+LoN/C+Xmlo/9HCtBLAswpbDue+hnvwq7Nl/k02Lpx9TRljiQkgwCPi1g Nvvr89RMJ7oeqwhBKTdnSBUtS4y3uk/xLyp2Buw+jvV/a8qR2UkXAA8BmArGD4ucH0Rk kqxg== X-Gm-Message-State: AJIora+qxhDFuC0OcKxWNZPL6/gaVrQyFBTerjbzWIh6RYGjiyStwKc5 CLO6x9t8EeKMEiXTTVc4mmk= X-Google-Smtp-Source: AGRyM1sBhAygIO/RY4Z0yKbahCnxKB6ckqC7C/N4OOHZqa1pWPN8W+2oyoNKFnBycAFiG7qo38KH2Q== X-Received: by 2002:a63:87c6:0:b0:415:e6bf:1fa6 with SMTP id i189-20020a6387c6000000b00415e6bf1fa6mr8204309pge.406.1657543462839; Mon, 11 Jul 2022 05:44:22 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:22 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 2/7] pack-bitmap.c: mark more strings for translations Date: Mon, 11 Jul 2022 20:43:58 +0800 Message-Id: X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.dirty 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 | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 0fdba5e8c5..c970ab46dd 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -139,7 +139,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; } @@ -161,14 +161,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 '%d' for bitmap index file", index->version); + return error(_("unsupported version '%d' for bitmap index file"), index->version); /* Parse known bitmap format options */ { @@ -182,7 +182,7 @@ static int load_bitmap_header(struct bitmap_index *index) 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; } @@ -216,7 +216,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; } @@ -260,14 +260,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); @@ -275,13 +275,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( @@ -331,7 +331,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; @@ -388,7 +388,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; @@ -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'", oid_to_hex(&object->oid)); + die(_("object not in bitmap: '%s'"), 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'", oid_to_hex(&commit->object.oid)); + die(_("object not in bitmap: '%s'"), oid_to_hex(&commit->object.oid)); test_bitmap_type(tdata, &commit->object, bitmap_pos); bitmap_set(tdata->base, bitmap_pos); @@ -1683,10 +1683,10 @@ 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_ln(stderr, "Bitmap v%d test (%d entries loaded)", bitmap_git->version, bitmap_git->entry_count); @@ -1702,7 +1702,7 @@ void test_bitmap_walk(struct rev_info *revs) } 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(); @@ -1729,7 +1729,7 @@ void test_bitmap_walk(struct rev_info *revs) if (bitmap_equals(result, tdata.base)) fprintf_ln(stderr, "OK!"); 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_ln("%s", oid_to_hex(&oid)); From patchwork Mon Jul 11 12:43:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12913655 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 49B20C433EF for ; Mon, 11 Jul 2022 12:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbiGKMpK (ORCPT ); Mon, 11 Jul 2022 08:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232011AbiGKMoe (ORCPT ); Mon, 11 Jul 2022 08:44:34 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F74965544 for ; Mon, 11 Jul 2022 05:44:26 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d10so4655396pfd.9 for ; Mon, 11 Jul 2022 05:44:25 -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=mA4mfPf/cGs+eJTK2hCSg24spGNe4RXDPVvAx79OZUs=; b=WlRJPKvm5977SR6zX+ofKdjLJens0Vpo2iWmMsirDdgwyWhnzTYRiQG4Vbp6ByARWC m4JUY5ENcL/5l/fS0BEApmNolRinPY+iFkTnfABzUFo3kjAWynQQcOUmbCU0aZDt7vsx wC93cJvxlx3bta+l4NkW7TKhjGTo9efRjAfbWNCJUGr3kddw8vo6ZlWSaEZQC1cjvVKq BKuLpm8rG0le1iGIIGyTaGwd9GneIQ6yqw9fPwEYHrW8p75qUBcFpRhrQs9RQKajgHzf Wis/RWsh9jTEYIyUgDYSR0EVNgTTWzy9XFB9YuDMXjXdX99NpSx/uI7neHHJKzQqFiLp Ityw== 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=mA4mfPf/cGs+eJTK2hCSg24spGNe4RXDPVvAx79OZUs=; b=feI12D1pIfEYHjOmKuZPo9T3LMNorOzoLZsVQ3wSIbUEy0Ae8QeMDA+v4px/4UgFel IPfWc/84EFoM6pnB7H2afOJ6aKo+rmD+rmz3Vhd7xYJYZPUMKbmx564pqTp8NLGziBU/ 7GhK6x69Xt54Z/9YvZ7uD4MxdMLMSdqLXAXlLF0VnJdT19Hs7zlcpBE6/odZZ3Dcu/od iYZmHVp8Jj9RDnKwf8Pn57wEzTJNV02nZgOIkJ0Y/p7x98o4LuS7xuj7xlWLf3aQQbcF bSQV8sohiGZTHmpc4oTxJyAzw/4d2OpPY80SFKVYCjNqce0wry3ZDQ9nkvGfgwd8ma4I FIxg== X-Gm-Message-State: AJIora8h9BglngkG5kUd43GTrqqlQ4k2ekjHhRUVBKoOZ8dkJve2VH/W AtMOtICGSHGlv46K/tag9Lk= X-Google-Smtp-Source: AGRyM1tIg0mDhZjKEQXubhG1hELVjpU4jKBRQUTHwB86E1Of755Xc/sHODKncWhy4fPY2YLFOkaEOw== X-Received: by 2002:a05:6a00:1a86:b0:52a:d419:9552 with SMTP id e6-20020a056a001a8600b0052ad4199552mr4101373pfv.70.1657543465160; Mon, 11 Jul 2022 05:44:25 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:24 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 3/7] pack-bitmap.c: rename "idx_name" to "bitmap_name" Date: Mon, 11 Jul 2022 20:43:59 +0800 Message-Id: X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.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 c970ab46dd..7d8cc063fc 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -314,10 +314,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; @@ -369,14 +369,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 Mon Jul 11 12:44:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12913656 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 11842CCA480 for ; Mon, 11 Jul 2022 12:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232027AbiGKMpM (ORCPT ); Mon, 11 Jul 2022 08:45:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbiGKMoh (ORCPT ); Mon, 11 Jul 2022 08:44:37 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FDCF65595 for ; Mon, 11 Jul 2022 05:44:28 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id cp18-20020a17090afb9200b001ef79e8484aso5559818pjb.1 for ; Mon, 11 Jul 2022 05:44:28 -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=jAqgnidSDpoMfHQ48ntFpHfwLMi8/zSUgWFTnmNWFcI=; b=cGUyTqxES3tCvRYzYeRy2FxmlVKl8rLby3hSgmXI3mi2KMJt+ZhURBPwVfy3PmaGN6 BuNpsc6dQPkVFz7eacpZJpuusp7lUpty2O33ncZbq0Nr4rWj/u7xQA3sFA5CveC9vu7b +TkijtHPJFIKMOKQDbHaXl7xdNKh3KJQlurDKuYBhQrJMnsDNlAwe16Wx5sOaBugE91G bxSQociKYH9Z3EsfrjXoSahECrvSpXWN9E636oQoTpDriTU4YqLPSfSYKovFrojRkcw2 lrPgJNaiUOvg8vfI9wvtIKGJIz16aicvbimN3OvPJ2nErHPAA/Q+Y5hl1XCBBtrvGYLr Esqg== 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=jAqgnidSDpoMfHQ48ntFpHfwLMi8/zSUgWFTnmNWFcI=; b=bIJre9acXHhAU1M+nOL5WAtEDdIUrA7Lo75IgmmZ1guA+i/D6w64WFWrw4kXBFtKMH F86QP9Yo58T2HluNQPxDUp4Bxn4hOllfUM26xG4SxU9AnOZnJEFps8Nb0PsoJm9u90oG WaDQsxdRLIU2lp3ImKaqaeYU+0053sUXIOFPqUooSjyqcJ7/+J97AUyrNpg4E7562XvG qLUC3BFE9FbAi/DdpMbiUPxoMzgBLm7rFd3udcV6ELsLs8DKODjsrsmHZySJdfcMA8wQ fSVrWb/VDan4KhHojyAf7gzLWhJwuqpROGtwzf2QlYD16xlQjyMFp9pIiNQp934OKfP1 dZug== X-Gm-Message-State: AJIora/1znD74FFMANlWJ9wlnvBTOa6759IxfE/zbRcj30k4HfAn4nRy bU+ctmhiUo0WGL5hmAmiSKk= X-Google-Smtp-Source: AGRyM1vANPfd1BcitbJ37PoDfz7RFZnh06LXuuTeAFKcCK1ncFKOoJzMpetXb9h1IJ6RazQ+uu5BHg== X-Received: by 2002:a17:902:e54e:b0:16c:33f7:55f7 with SMTP id n14-20020a170902e54e00b0016c33f755f7mr11803460plf.111.1657543467483; Mon, 11 Jul 2022 05:44:27 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:27 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 4/7] pack-bitmap.c: don't ignore ENOENT silently Date: Mon, 11 Jul 2022 20:44:00 +0800 Message-Id: <009cc49a18f2846c24256102e07437894ac16908.1657540174.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When finished call git_open(), instead of ignoring ENOENT silently and return error_errno(_("cannot stat...")), it's better to check the ENOENT before then output the warning. Signed-off-by: Teng Long --- pack-bitmap.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 7d8cc063fc..319eb721d8 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -317,10 +317,13 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, char *bitmap_name = midx_bitmap_filename(midx); int fd = git_open(bitmap_name); - free(bitmap_name); - - if (fd < 0) + if (fd < 0) { + if (errno != ENOENT) + warning("'%s' cannot open '%s'", strerror(errno), bitmap_name); + free(bitmap_name); return -1; + } + free(bitmap_name); if (fstat(fd, &st)) { close(fd); @@ -376,10 +379,14 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git bitmap_name = pack_bitmap_filename(packfile); fd = git_open(bitmap_name); - free(bitmap_name); - if (fd < 0) + if (fd < 0) { + if (errno != ENOENT) + warning("'%s' cannot open '%s'", strerror(errno), bitmap_name); + free(bitmap_name); return -1; + } + free(bitmap_name); if (fstat(fd, &st)) { close(fd); From patchwork Mon Jul 11 12:44: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: 12913657 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 C883DC43334 for ; Mon, 11 Jul 2022 12:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbiGKMpW (ORCPT ); Mon, 11 Jul 2022 08:45:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232048AbiGKMol (ORCPT ); Mon, 11 Jul 2022 08:44:41 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD6E64E2A for ; Mon, 11 Jul 2022 05:44:30 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id bh13so4631380pgb.4 for ; Mon, 11 Jul 2022 05:44:30 -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=df9ewZOSiQvm0vC5SkR0ilADluZ9ks2y49P7DgI8hyI=; b=MazZ/FBIw9zYeNGTfG4Xo+Vhu8M9LFMrDHLETBeEbTFnWUD56DieBeIr/S2QUd1sf+ i3DJ+ocvX+kXUHdbob7sQxWMvy7Ip9oi4SZXx5jMY9h6BMyQSPVaRTbgZ7mIceBX9fft f8MPPqYO+T4IOgtdozkb52KgRoOxDznklkvft2MWrMhifhHl0JskU3KfxXe1wdUdqqGH JAn0kP4KaUttVwrlMCET9efSyISbr+xypGBz24BBr+ClshGqhfwhaehFihttutsxBeAo WdOq3rsmXkXAo5/HubYN/+5jXNk+qJZy2LbBF0U2a3f8+OPGlM+xMWqyiTTS/xkYjdtx twaA== 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=df9ewZOSiQvm0vC5SkR0ilADluZ9ks2y49P7DgI8hyI=; b=YNX7DV1Ys4jpHta1BFOHlUrhTiZUID2QICkvrIiNOeuSTyCCsX7pku1P1JzViGdhQL ZPJxnx/8ksf4Z0ZhYn3znuOHEymrXvawmY5Drfg/MBNUkgTEDFsBo4ykABkmMznDUuzq PDUYKTTtB/X10XokW2f/Lml62H60vSB12ecSu1fcjTo0jcf5LFynFXUqfOEMPLIzfQre dkhjx7XU8eJhEkswkuUKeqwtvHN1oN9H7pV1EytY7ryequOzqqyHUJ4e6JEd7e9RUxS/ hNxulkH7DiC+z8lui9adPba/TW8HfmJ3GzS1mxE+80+zHMt11FT/DQuontN8dfmV0zL/ KPAg== X-Gm-Message-State: AJIora/k4Z7EpTXJ0dg16/VAMU9IXvLCztGrWYbzGe8YVuyUnHxPZEsE 3PCee858ZzIXcLfb79/pob0= X-Google-Smtp-Source: AGRyM1vz+Rmgo94gVKHj99NoJBGlVMWVaXrF4xSmW8/eISPMJ2xEaHMJHT94Jt8AcVztcldvAbY/rg== X-Received: by 2002:a63:8ac4:0:b0:414:df9b:45c6 with SMTP id y187-20020a638ac4000000b00414df9b45c6mr15502265pgd.560.1657543469849; Mon, 11 Jul 2022 05:44:29 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:29 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 5/7] pack-bitmap.c: using error() instead of silently returning -1 Date: Mon, 11 Jul 2022 20:44:01 +0800 Message-Id: <52783555e206060465743b5587580a6bd4a1f008.1657540174.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 319eb721d8..fbe3f58aff 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -327,7 +327,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, if (fstat(fd, &st)) { close(fd); - return -1; + return error_errno(_("cannot fstat bitmap file")); } if (bitmap_git->pack || bitmap_git->midx) { @@ -350,8 +350,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(_("checksum doesn't match in MIDX and bitmap")); goto cleanup; + } if (load_midx_revindex(bitmap_git->midx) < 0) { warning(_("multi-pack bitmap is missing required reverse index")); @@ -390,7 +392,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 fstat bitmap file")); } if (bitmap_git->pack || bitmap_git->midx) { From patchwork Mon Jul 11 12:44: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: 12913658 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 BDE11C43334 for ; Mon, 11 Jul 2022 12:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232129AbiGKMp3 (ORCPT ); Mon, 11 Jul 2022 08:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbiGKMou (ORCPT ); Mon, 11 Jul 2022 08:44:50 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3038B11152 for ; Mon, 11 Jul 2022 05:44:32 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 145so4606480pga.12 for ; Mon, 11 Jul 2022 05:44:32 -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=falzEKBgGDPv/P5KOgkBl0kQztInYCV/JAGAERoEarQ=; b=XAmNeOl+kovf1/R6ju0suavQNJ+xOIgdhorZGR4cK35w0Alma4817dLKAxnZAsN8Tj Ya4TjOK4/zpBGqrOHQqO2YhtPDDiduPvBmBW/gly2of69bK6vGKUboaNrzu5tjSjrkz4 VbB2WnYt4nRmaYNNltEfBLylUm59NebdzPiZwQPcNW+tXVINjs15E08s1o9UNIEDGPT3 XWXbT4l+44np6eDdavn4SyXOdgqVMc/EXy9CX5cfAS3GAKs52zxVBTnHOP2Cf4DxPKVZ F86PLIRQdd4GDLBD2ujfkdzH/iTk1bZKKEwlccglMxpIEzsH5rE/Vw9y0eV9df2FgzIp zB5w== 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=falzEKBgGDPv/P5KOgkBl0kQztInYCV/JAGAERoEarQ=; b=RQYYQwK2YtxH6QqJIjsoOgDWTDcUnq1GzvHsPlVOhfUxJ682fAJU9FS+AoIRJFZcoV L67ZsHRXPmLyfmmJ+Mni7cB86MoEYWj7KCfzYszRe4pClcZfijvT7KBcxIvfZcGIN+HJ 7JZtYsO+mwA+FLCvwtZN3jpi8u/ayie+rdW1ZlBHP67Hih7X4/FJIhM5w89PQda3wqL4 ets89aM+AvsD+XSSCJ+ml5mTKHStlez3W13/q8gbitKQxz4VPQICtep9v7wsg/k0hzSn c1DMboRn/fa3KMvVJkhYk0Ddx1sSoatlqlhdkvkCW30GxYYonitUVf7eVOBwlHWwROL9 FdCQ== X-Gm-Message-State: AJIora9xgBb9KK5fxQ+Sa1K0msSgQ75Q1qIfqkVZXoM+GyjKJGXF+eE4 g6c1pUf9t+Unup7p58ZnbeE= X-Google-Smtp-Source: AGRyM1tVEUgYK4x5sYiqwFWawwELfOAW7CgB7KlxXb5h3pShsMZjtBMVql/BRXab8CDxZ2Oapc8P1g== X-Received: by 2002:a05:6a00:134e:b0:52a:d5b4:19bb with SMTP id k14-20020a056a00134e00b0052ad5b419bbmr3070588pfu.45.1657543472310; Mon, 11 Jul 2022 05:44:32 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:31 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 6/7] pack-bitmap.c: continue looping when first MIDX bitmap is found Date: Mon, 11 Jul 2022 20:44:02 +0800 Message-Id: <95832190b8bba72622ffe1474e99990a29706db8.1657540174.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.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 fbe3f58aff..7e69093d5a 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -504,15 +504,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 Mon Jul 11 12:44:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12913659 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 2A6B9C433EF for ; Mon, 11 Jul 2022 12:45:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232083AbiGKMpb (ORCPT ); Mon, 11 Jul 2022 08:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232087AbiGKMow (ORCPT ); Mon, 11 Jul 2022 08:44:52 -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 4854F6302 for ; Mon, 11 Jul 2022 05:44:35 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id x184so4675094pfx.2 for ; Mon, 11 Jul 2022 05:44:35 -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=HeCfvWUxOThV/EfkESGLoJlxn2nTjBhLtC5JGLuwpK4=; b=GtjKE3wg0z0b7RCT1KhjXsMaZJyxVQzzkBJSDBHT7l5Ze6Y/qQRFNYENfsWRxIppoH 74A4OLvKbIf93l3fbCJnKBy3GfLmX+nsAXNYa8t8cQP3rxEdmNNaMX5/aw7IPr90Ef3I vxgO1P/UE6CHPYB3xKNn10KPFptyeseUot9Jsm/xV7ival7fUQyYrA1NowIVkxY7eN1p IiuKGwcLT0uIGfmiAJYk3hbjFQVPEVBhe+af7+M7Ua2U8lgXggtZMrqe6ogMXb+wnF5b /00gk49aQkIwOipDAwnpiOLV1aJ06j2oKP31mQXvyMgGANZe6lUTN0FTT7STjy6bJjbv CssA== 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=HeCfvWUxOThV/EfkESGLoJlxn2nTjBhLtC5JGLuwpK4=; b=z+70igqqxQBE74jpax5rCKX2vSnS6RmbNMHtAprjSjXmdwESbSUMV+5JtO3CgWFnP7 h5F7iK9KR6BYKHrusV14z9S+YM2sQV4f6tP+RPvnPm6sCsss5eYgf+rDEvUxI6I7eLuo 3XSB4u0QbXjE4Cpot/C3jEG0N7xlL3GPur2QbT97LeD0D3GBJ0kOK30MDZxbmrHHEFwv aSfZIN+aVIeutP46pOThZp8zTBP0GE1csGXmi6C/iQ5X5SHdeROhvWYM2dZo/t4K2L2z iylnO67x2qUlgcp2DkDpvJSZj00SCxR2rIet7hXREl3UQt0Qoc5773n8fZ08HqqGzX6f qquw== X-Gm-Message-State: AJIora/89Un3vf0G40PUePx9Qd0E00w9deLLBDRXs/1es92It7XZsanh Jef6qAvH2/wn8LTN8Kb+9T4= X-Google-Smtp-Source: AGRyM1txNwTVqvW4ZS4I5AWRArbPiDCYjOEYnUSzsgVOI26ci9mRgynMRl3fydGsU8xM2S9sFyuVPg== X-Received: by 2002:a63:4b20:0:b0:401:ae11:2593 with SMTP id y32-20020a634b20000000b00401ae112593mr16186193pga.375.1657543474807; Mon, 11 Jul 2022 05:44:34 -0700 (PDT) Received: from localhost.localdomain ([205.204.117.102]) by smtp.gmail.com with ESMTPSA id d22-20020a17090a02d600b001ef95232570sm6866084pjd.52.2022.07.11.05.44.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 05:44:34 -0700 (PDT) From: Teng Long To: dyroneteng@gmail.com Cc: avarab@gmail.com, derrickstolee@github.com, git@jeffhostetler.com, git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com, tenglong.tl@alibaba-inc.com Subject: [PATCH v6 7/7] tr2: dump names if config exist in multiple scopes Date: Mon, 11 Jul 2022 20:44:03 +0800 Message-Id: X-Mailer: git-send-email 2.35.0.rc0.676.g60105b7097.dirty In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When we specify GIT_TRACE2_CONFIG_PARAMS or trace2.configparams, trace2 will prints "interesting" config values to log. Sometimes, when a config set in multiple scope files, the following output looks like (the irrelevant fields are omitted here as "..."): ...| def_param | ... | core.multipackindex:false ...| def_param | ... | core.multipackindex:false ...| def_param | ... | core.multipackindex:false As the log shows, even each config in different scope is dumped, but we don't know which scope it comes from. Therefore, it's better to add the scope names as well to make them be more recognizable. For example, when execute: $ GIT_TRACE2_PERF=1 \ > GIT_TRACE2_CONFIG_PARAMS=core.multipackIndex \ > git rev-list --test-bitmap HEAD" The following is the ouput (the irrelevant fields are omitted here as "..."): Format normal: ... git.c:461 ... def_param scope:system core.multipackindex=false ... git.c:461 ... def_param scope:global core.multipackindex=false ... git.c:461 ... def_param scope:local core.multipackindex=false Format perf: ... | def_param | ... | scope:system | core.multipackindex:false ... | def_param | ... | scope:global | core.multipackindex:false ... | def_param | ... | scope:local | core.multipackindex:false Format event: {"event":"def_param", ... ,"scope":"system","param":"core.multipackindex","value":"false"} {"event":"def_param", ... ,"scope":"global","param":"core.multipackindex","value":"false"} {"event":"def_param", ... ,"scope":"local","param":"core.multipackindex","value":"false"} Signed-off-by: Teng Long --- trace2/tr2_tgt_event.c | 3 +++ trace2/tr2_tgt_normal.c | 5 ++++- trace2/tr2_tgt_perf.c | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c index c5c8cfbbaa..37a3163be1 100644 --- a/trace2/tr2_tgt_event.c +++ b/trace2/tr2_tgt_event.c @@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param, { const char *event_name = "def_param"; struct json_writer jw = JSON_WRITER_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); jw_object_begin(&jw, 0); event_fmt_prepare(event_name, file, line, NULL, &jw); + jw_object_string(&jw, "scope", scope_name); jw_object_string(&jw, "param", param); jw_object_string(&jw, "value", value); jw_end(&jw); diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c index c42fbade7f..69f8033077 100644 --- a/trace2/tr2_tgt_normal.c +++ b/trace2/tr2_tgt_normal.c @@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param, const char *value) { struct strbuf buf_payload = STRBUF_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); - strbuf_addf(&buf_payload, "def_param %s=%s", param, value); + strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param, + value); normal_io_write_fl(file, line, &buf_payload); strbuf_release(&buf_payload); } diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c index a1eff8bea3..8cb792488c 100644 --- a/trace2/tr2_tgt_perf.c +++ b/trace2/tr2_tgt_perf.c @@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param, { const char *event_name = "def_param"; struct strbuf buf_payload = STRBUF_INIT; + struct strbuf scope_payload = STRBUF_INIT; + enum config_scope scope = current_config_scope(); + const char *scope_name = config_scope_name(scope); strbuf_addf(&buf_payload, "%s:%s", param, value); + strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name); - perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL, - &buf_payload); + perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, + scope_payload.buf, &buf_payload); strbuf_release(&buf_payload); + strbuf_release(&scope_payload); } static void fn_repo_fl(const char *file, int line,