From patchwork Mon Jul 18 16:46: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: 12921464 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 A3AFDC433EF for ; Mon, 18 Jul 2022 16:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbiGRQqn (ORCPT ); Mon, 18 Jul 2022 12:46:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiGRQqm (ORCPT ); Mon, 18 Jul 2022 12:46:42 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FCF1F33 for ; Mon, 18 Jul 2022 09:46:41 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id b2so9539309plx.7 for ; Mon, 18 Jul 2022 09:46:41 -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=OvDC7ADlsa/OmkeYj6EAOVVtjwrG5czMyxKpvrJfeQc=; b=g2flSsseZLWdU7YgrwdChc00t8pb8xAR+tDGGBCHnpvYFhdnrAHogQrgdXV4q/yGYS b4U3n/+L+B4siJw8TBSmJx25enMdINZXMOzbnZFzxYoEdeugmR7kSkaJ5WZixgOr1dVf zhy1rp8/yZJxwMPWD09bQSV8lLKYI7X8TAjoQw2XyI8fZedoHbtyFIpTmyl8cy3IKu/D cQZfbO0mHIZJn0KKv9Gj/+ZKyPVuAWkxvO0Www73gjxTsdDkyB+z1fERncK6F9Ib7Htc xmRgkZLFbh1M6GplX33kFQGhej4Ftuu8QX7uNKPHDvp1NG8wGDBzT37KhqSdK8aiNgux NzRQ== 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=OvDC7ADlsa/OmkeYj6EAOVVtjwrG5czMyxKpvrJfeQc=; b=fXITwKiMzBY5zwU/HAOgOy//XVn6AQIiIpAvpJy09Umull0+xcobWehC1HCIyywWRu uQfuh9tkFYM5AguDiz5e+ChpphtMkkmr3wcYwnAz18ufaR4pEUSPV4a+MTHGCRW53G6X eHuCCKnkQrC1zM83RSZrHAc+ohvP3+Bh2htijIaE1p/Kpc3TNMXfthIsAbKhOF8rFu/C WwTbD/fdUeqxkr+P4HdEgbb4IBB/c0hJfqs+YjPKdhoR52cN5StEdmymNG6VOQrFhZ6c XQbd2SGopi270bFA3q9Kz7EwrDjF1bi2OClZBTXk0c0/rLihTNx5EQKqFE2DcxaZwG1N x+hw== X-Gm-Message-State: AJIora9qPtMNenPihVfEomsK7tyNpGYQizDLqkdFosPeCP9MpZsyqZuR +Q2Jcsh28kU+l8o1mfgKAzU= X-Google-Smtp-Source: AGRyM1vvY1+Nqgq8qBl90tMQSL+tZ3u8h+BVda86Y6feDaMO9TFgMHtO7DA/kxuIQ6QDDbFFH8SD1Q== X-Received: by 2002:a17:902:b10a:b0:16c:51cd:a6f with SMTP id q10-20020a170902b10a00b0016c51cd0a6fmr28626252plr.42.1658162800443; Mon, 18 Jul 2022 09:46:40 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.46.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:46:33 -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 v7 1/7] pack-bitmap.c: fix formatting of error messages Date: Tue, 19 Jul 2022 00:46:00 +0800 Message-Id: <7426b277baed2df132fcb6bc75f0650769a5c7a1.1658159746.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 18 16:46: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: 12921465 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 D78DCC433EF for ; Mon, 18 Jul 2022 16:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232115AbiGRQq7 (ORCPT ); Mon, 18 Jul 2022 12:46:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQq6 (ORCPT ); Mon, 18 Jul 2022 12:46:58 -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 193D2101D4 for ; Mon, 18 Jul 2022 09:46:57 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id g4so11117468pgc.1 for ; Mon, 18 Jul 2022 09:46:57 -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=qXIE721zUM9neztC9QiczBb1Fx50qwgkQI2N/D9+TV4=; b=QQfPCiwwH7rmQ2I57tpYkExCJ0wn0idgR3xDPtpznVOak+mDnvX9H7450AsinTJFbD 09mCeHKQnIGO7nAdmYv5/xpiz0C1wWXunBxAZ4NkjunvLcB6Q0hw5AzZ5A+pPyaJWvS2 xIhIzDN6quhuiO5pKSFHTS4FVH4KvC/Jq+twOJQPltAVnKCHwkJIo/3eshU2dPaLh/y0 SCnSqkU3To8w4hiH2dsxFVSmQV9fxWOLTdgpKTnxG5+9OHjLHsoW/3p9wEvjMJJxRe3z xvzr2oQTfjOpkw2EvZCkgDEAiDOLMbNHanJhJiU4wLIbqf3nh19RjN5qCIqwAanzqbXo VeCw== 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=qXIE721zUM9neztC9QiczBb1Fx50qwgkQI2N/D9+TV4=; b=PzPVsF1x81Iwk2IUksoxT5/g57/8C/yJNdLs7oxkC1MZod86zJfNrfTTwhQMi4vLFH l9jF7vovXUpprnh6HG6zxs3kHvwfs/8OBjMHbPtzruhiT7Z7D7Pjgxn5VXT8cUYqUW69 /f0clCpE7X/0Lvd0F1+o3wxGEQVRTis69ylSF8D9D1JNn1rxw/5+cSm2Za8JR9gHFr63 qJkUf95gXX+U3pZg4BxUhE4sC8Nx4rhL36jcEssJzSd3s0WI75XGqKLMNCHSPrQ3voDq ZwTffn/shMHCtl8j5AHZ/KkDBoQdCfZJc/kLksyENIOYUSBVlwB+0jGeP+HlabugYyq9 u7LA== X-Gm-Message-State: AJIora/An1tdZFzwjM4Y6UMJTclM14WSTuxJ/5W63S78+TManEGnhNae 30QOnug5Q4+Pt3lJIEsvDf8= X-Google-Smtp-Source: AGRyM1tO5etvCAFlgWrsBYhQBXykRCG6VXtqhBWuPfZ9p+o6nhjj/obsX5zQ5pYh62qAAbY8P2oGUQ== X-Received: by 2002:a63:3181:0:b0:417:b4b5:df09 with SMTP id x123-20020a633181000000b00417b4b5df09mr25816165pgx.398.1658162816544; Mon, 18 Jul 2022 09:46:56 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.46.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:46:55 -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 v7 2/7] pack-bitmap.c: mark more strings for translations Date: Tue, 19 Jul 2022 00:46:01 +0800 Message-Id: <4e493426a0049854c7eec64029928e10ad2b414c.1658159746.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 18 16:46: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: 12921466 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 5D7FBC43334 for ; Mon, 18 Jul 2022 16:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbiGRQrN (ORCPT ); Mon, 18 Jul 2022 12:47:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQrM (ORCPT ); Mon, 18 Jul 2022 12:47:12 -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 92E8724BDC for ; Mon, 18 Jul 2022 09:47:11 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 72so11123152pge.0 for ; Mon, 18 Jul 2022 09:47: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=Bst8E8h+dF8iMucpBvTZiCuHwRVw+FPUE4OQZ4F98mQ=; b=N8PA3+fs0UlJxxn+LfJfQkG7ebKZoJlAcUAu22vDBSZZF5wwRzRI3Qx3/i/Tuct7j6 i8VD9cnjOqj+SR5qQ3MaKhAIBLUbT6qUPeandNSIDUyFzXPzUCiRXvpg1XptGFiNN/1B 8x1vdCOPfXb6GYyL668T8f9FX9lWKGooPra1i1/m6CVZMMVVssmnxkdODfTYWh2NYLWJ 4h5xmnxBFP5/88ZBL0tOW2yHZcMsUD1T4vG0q8V/9QUapFBd1OkPKJ8fmOlgEpncNFkv qVtb93642nwK8CV4FLEeHtNQlrmizr+MDKw6zFf0a8boQAqw+b3qx07HK+Y3M67+MzkM bihg== 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=Bst8E8h+dF8iMucpBvTZiCuHwRVw+FPUE4OQZ4F98mQ=; b=zgs6an5VrY3kKr5JfH9JO4PADFs7v+98bl8QT4mA9MMGECJU2kGbNqWa7mqUhtAsIp dahiQC7OobImQf+KM+oyXuhTd7AcE/qIbOBERdmw9YSrYP48jm1y11MGyj/XIGMzBC9s +g5f74V9FA4m0dfU3L6jKKVo0hPP9VEPb+xfC4Dqkllhh7ZBB7mZCvu4mHFmrl+2RXD7 bevRYGc5Er2+SFr55edZ3A4IkYx1X+btC8WAP4gBPSD6GZWmqL/uvy1iLsIABBuF77bW ybUPVu1gK5PF9dPgwWjFWvMDZ0JvY4VMKOo/SXW0U3/NRW1Bwlif2efPW1DDMbCkBFVy MhHA== X-Gm-Message-State: AJIora+bvBPW9oHd7JJCYNi5S0zQxboeZ9mM2JhHEBrQMT+kLYpseSZF BPOlvF2uUpHs9hIHBwqfuOs= X-Google-Smtp-Source: AGRyM1s+SGqyKMIzJEhiWNcpgUogGLCcPcSzYLmhDcZ/LPIlbQb3IXdqLLghN0FmZ3ZYMUDCGjE3wQ== X-Received: by 2002:aa7:8887:0:b0:52b:17e8:fc7 with SMTP id z7-20020aa78887000000b0052b17e80fc7mr25359124pfe.35.1658162831019; Mon, 18 Jul 2022 09:47:11 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.46.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:47:04 -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 v7 3/7] pack-bitmap.c: rename "idx_name" to "bitmap_name" Date: Tue, 19 Jul 2022 00:46:02 +0800 Message-Id: <263f45ba96c322665f102e22e1899c93541d87c4.1658159746.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 18 16:46: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: 12921467 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 68A58C433EF for ; Mon, 18 Jul 2022 16:47:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233257AbiGRQr2 (ORCPT ); Mon, 18 Jul 2022 12:47:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQr0 (ORCPT ); Mon, 18 Jul 2022 12:47:26 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC81101CF for ; Mon, 18 Jul 2022 09:47:26 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id x18-20020a17090a8a9200b001ef83b332f5so18853936pjn.0 for ; Mon, 18 Jul 2022 09:47:26 -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=ZJx/V/nrLUszyemmolNuLCsZ/8Ak6DnplUOHq/zOo0M=; b=PGWQjYgpGmEFcrzbin+oDVPkZukX7v6Kcqjwy8mFnPK1XtONDFdhwddbpFeoWTL4tW dorVjbhENVj0BITiQgUOr4dD4UXW8FJ/RWO8Z7aiuGvoeIDxb5H2W9sSaTqf+u1EZRy/ lNHASI3e5ihIuZsTMPdAX0wKw5ijTbvymDnvI8sm3wMFODrR6ekpAi2gKMOGZ3FM2C+X VPFKHiQO7++AudjlYMyM/6M3z7ZlRT4SHfvYlHZB7jcKov7Qm1TYamJKgrxZWM7Fo3f3 8rsGMpo3CjS6aicIVdMoHalcsEEbxak1oDXP+WP5rwu2d6ks0dPOOf+QX6iNsnn09oOm 3nag== 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=ZJx/V/nrLUszyemmolNuLCsZ/8Ak6DnplUOHq/zOo0M=; b=iwFDMLUuObk/K/FA+clI8T4Nn5jUXBTzpv7CB+ptV+XfZnJe94Sl2nSV00Umk/WzNj IG5eoB1BzVnF508BIaGVe1OV12bq6uaZvMv7xtJX/i2s217KDSom+K6mNm6PMhNWanaO bZlkc8Gzzc9n5hBht7ejunFFW/hikV5kYzlQRxbDcHLeMOmhUlWm4k0/dUP4bs7hQcjV wV18FH4M7WaJUu9Z68fTgmznkNBX9+tIuk7hw6WGLByJHwB21oSZbWqqRWJgfPntW33+ 0BigcvULjE7kCZER97meceUSoTzBqI+1uQiCGuLshthBgL3mDMBNIYvTqikGXL+2IFnt pkkg== X-Gm-Message-State: AJIora++zJAU3myRDw4/YYRRGCDWgbv3ebKcyZDWeYfhDplgPzaQQWW0 nfsJN3aCwawZh1DVwJ1p/+g= X-Google-Smtp-Source: AGRyM1sex9s/1v6ksiO/DbbR9uPfpthNVu1EPXaQdlZ2oQ4Ihv4a1i9i22zk5ENg9815ssi0aADjEg== X-Received: by 2002:a17:902:d487:b0:16c:509a:ac16 with SMTP id c7-20020a170902d48700b0016c509aac16mr29429448plg.105.1658162845578; Mon, 18 Jul 2022 09:47:25 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.47.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:47: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 v7 4/7] pack-bitmap.c: do not ignore error when opening a bitmap file Date: Tue, 19 Jul 2022 00:46:03 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.581.g7a5d018042 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Calls to git_open() to open the pack bitmap file and multi-pack bitmap file do not report any error when they fail. These files are optional and it is not an error if open failed due to ENOENT, but we shouldn't be ignoring other kinds of errors. 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..f8f9937c9e 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_errno("cannot open '%s'", 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_errno("cannot open '%s'", bitmap_name); + free(bitmap_name); return -1; + } + free(bitmap_name); if (fstat(fd, &st)) { close(fd); From patchwork Mon Jul 18 16:46: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: 12921468 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 BD920C433EF for ; Mon, 18 Jul 2022 16:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233352AbiGRQru (ORCPT ); Mon, 18 Jul 2022 12:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQrs (ORCPT ); Mon, 18 Jul 2022 12:47:48 -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 719D120BCC for ; Mon, 18 Jul 2022 09:47:48 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id n4-20020a17090a73c400b001f1e87432c2so464654pjk.3 for ; Mon, 18 Jul 2022 09:47:48 -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=mojweoBCdHalvPf+rMPhrsaOy6k/QJExYDYcvloXRxs=; b=AEEE9F+1Bc1eUo/yxaTgEWBlu1bE+vvMQpkB0HzK5q8Jo6IvGyWVQcW3FEmWRnIhtK hswzq/z6O94dypO3CUtckjQTbfxtva2DFyE5bL3CB2MXdf17NNc7qo0aCKRe8FykOs4u BbnIxKasJUfZjWPWoBERJZ2ETVNiVGrE7UfW0HEzJPj1ipVLKoFS6DflOJHzCAgKKt+T 0kzfpCVXVBeGGrqFMPrNltvn2Z7+z7KwaNm/QLOM8yjqPf86yQnledGFJzVlAi/dBRFB sDE14WLVPt7Ghwis1vDoztK3QZ5LUFBbgSgR/fILyQEnNFQA46oeOKQlxvx+7XGAsgO3 rT1A== 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=mojweoBCdHalvPf+rMPhrsaOy6k/QJExYDYcvloXRxs=; b=UqouUk48t2hQERtGOyXZxp8IcWBmzEdjpWQ1TrKiXnAkbQDx4uZpmq0EBYjUL3LbQe H96fW707jQZ/2Fdb0qP1jvJZ/mA3LgYdfwNWjkbFQ/AbO4PMNTTg/Dh/b1HmguSEN2LV NweVTuuX6d//OHJ5CqxbciZLcK43vS2J0ntkCeHviGBUcMD+RiqVGq6QbiwTcOtwjQtf EeFzUTJvsZMTQIBNRCeU1JLqoGDE/FUht87ucOZoDBSsKHaKbdqlzlU0Tab8507ubSkB 58SJzxYy5R1ibQevFGKgbkHPhfCALO/O5vH6ThkfzYpbxYECuTx+BpRsNOhyIxl1LQ3Z 0u+g== X-Gm-Message-State: AJIora9x3XSQcrv/OL+9DGxdiYIZnNx2xhuoGlGVYt+/qrsdZI0MMLyd gxQvsfH8qzAsbU8h2WIXHH0= X-Google-Smtp-Source: AGRyM1tPiGYiq4V0Ug5T6KJ+28W+RoMLX06X/GyORbUHzR4//EMs/dhi5mZ3B5SnhHEFB+uzkZs+TQ== X-Received: by 2002:a17:902:8bcb:b0:16c:a264:77ae with SMTP id r11-20020a1709028bcb00b0016ca26477aemr25159484plo.130.1658162867913; Mon, 18 Jul 2022 09:47:47 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.47.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:47:39 -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 v7 5/7] pack-bitmap.c: using error() instead of silently returning -1 Date: Tue, 19 Jul 2022 00:46:04 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index f8f9937c9e..318edd8e0d 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -326,6 +326,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git, free(bitmap_name); if (fstat(fd, &st)) { + error_errno(_("cannot fstat bitmap file")); close(fd); return -1; } @@ -350,8 +351,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")); @@ -389,6 +392,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git free(bitmap_name); if (fstat(fd, &st)) { + error_errno(_("cannot fstat bitmap file")); close(fd); return -1; } From patchwork Mon Jul 18 16:46: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: 12921469 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 7BE60C43334 for ; Mon, 18 Jul 2022 16:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233366AbiGRQsY (ORCPT ); Mon, 18 Jul 2022 12:48:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQsX (ORCPT ); Mon, 18 Jul 2022 12:48:23 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E9002AC7D for ; Mon, 18 Jul 2022 09:48:23 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id g4so11120881pgc.1 for ; Mon, 18 Jul 2022 09:48: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=CM42Ot848eprLj08Np8l8RYtncjprn826AsYP6mnDm0=; b=I3GherC68YcsSoOJCtT49Y15W41t+2bvumZBgolyr6fp/6DQQ2cL1JdZNv6R9i7+m2 pGOyvZvNTvDcK5SRkE9tEa0SBuGuEpNueghYGcg7Gki4DNfGgjVQEVe5UA0XvZz6t24b H3BEQt6Kw+CIwDj7yX0DU1t1C/vLD/aleRj9vn71vhVNMdmn3L/43pOo5kt6WrOC0bKp i//5Afk9e8zXkQWQ0t3E5sJh476+pWEqCeG5N1/ojUWSsaIsmgKrW2fVHjsgIG4cZlDc 4liLxRXDDowkRL74bako+dlR9blYBVvCv8e6oNQXKBGwCPLGgb0EOnvBvjXq5YcAEC/6 9ovg== 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=CM42Ot848eprLj08Np8l8RYtncjprn826AsYP6mnDm0=; b=cDxdF7b+Iwi2D8BDBuJMhTBEhpE2rILvAVqYK+j60sx2IYP/lgTVjOq8hZYYGivs4c WyyXYoG/X2+AjjMRhHWERRmLzW3/WS50vMyYEUU3GvgtALkIE8U1QR8sG4HakjwQtUXt I+ZUh/2rOml1az3KhigrPLjZRyO837LGVeSWUU+HiaG9aMq6NhMeCVz8TNHmRvxAxfBR iwe1ZfASX05WD7Tqq3QJxSr5o5Iyysd+yWS4X6wLfEFqi76nZREYH0YLBIpaDaanGWJk McW8bcQTwRoVTcQTJXYuhCldLi9cpUCeQ4Jpl5UQkUNRcgGAgQEDrcwgXOqRUC6AK2Jv gvTg== X-Gm-Message-State: AJIora92sHZxnBsJez3gTycTxU7kMuCIWTZxYyKfO3yAcrKjtqksnvhd EcgjtnqD8gCckt+YYRTS8xmi1Zywj/xoJQ== X-Google-Smtp-Source: AGRyM1t42mqnpwJNvQegydet0UjaLf7W5UW9wtx+45oQ3eqz8l1unlUCcamEdJncUXif56JiX08ISw== X-Received: by 2002:aa7:82ca:0:b0:51b:cf43:d00a with SMTP id f10-20020aa782ca000000b0051bcf43d00amr28979382pfn.58.1658162902683; Mon, 18 Jul 2022 09:48:22 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.47.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:47:56 -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 v7 6/7] pack-bitmap.c: continue looping when first MIDX bitmap is found Date: Tue, 19 Jul 2022 00:46:05 +0800 Message-Id: <83090308ad63543c9becfb4cec9c1cedcffb1fdc.1658159746.git.dyroneteng@gmail.com> X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 318edd8e0d..d013ea0277 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -506,15 +506,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 18 16:46:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teng Long X-Patchwork-Id: 12921470 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 D84FEC433EF for ; Mon, 18 Jul 2022 16:48:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233431AbiGRQsq (ORCPT ); Mon, 18 Jul 2022 12:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiGRQsm (ORCPT ); Mon, 18 Jul 2022 12:48:42 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 975D12B18F for ; Mon, 18 Jul 2022 09:48:41 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 23so11090601pgc.8 for ; Mon, 18 Jul 2022 09:48:41 -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=WU3CM1MNuCvkNaElfJEnoIZQtpivC3RDsNeR1HXDTOE=; b=Aql9DnPRWiImBzB6laJW7+5ASEfOFEljKnXI615Mf39zDxe3wkkID1UhNTmXCJNBqo 0kfydcpL022INomUcUKATLsGCFog1FPxX8B5cCXRPVahe7oJEMI7mN7sTO1o5WNM176F UhNIfJyAAli42McN8/lz5lo6i++va/2P4Ii1+NFKc3W7T4W3xIiABCUQoRBPSPdea6O/ C7xYJwn+XwiajGP++mhlq1pIUbFudxV3Lzn9MikHIZe+aasLUmxm0IKnxtMnamcSRsYN M7stkvP2xC4okqoE0kDR4nimogIiEC7f+YWlxQceUxW0FfCCWMWNdNBam5BtjjlkKxY3 8NYQ== 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=WU3CM1MNuCvkNaElfJEnoIZQtpivC3RDsNeR1HXDTOE=; b=DWFmzw/pr2YVCk9pWpS/a+5ZKZzAHgixRCKTKJelHCpuK5bNle1GcIG0BHrPrdETft 5gT/QFyj1z9P6zv6DEgmWiwQp4zp8/o7zgbg8pyN4jUGf8RyHk4Ygmyos9elkMgKzAQ4 RfvA4MfORUOMvB1aS4kl5Ka9Vi7w8VuV8NtsFfPiOytADoH3QlJ5vTgVLzxDIIOgOKGG xZ627/HGczewVvaTJv45y5duG1WCEfIYwmmwNjEdEzng28DWxlp5s7fEZhX4NqX1S8FG ARNWVTVfc1sEne727Bj0O3Jq2YPi2gqWYP/MmgZCJvd4OOdG5k2G9EXEB7Gz3JyBPoHu u/gg== X-Gm-Message-State: AJIora9c+hnrbzcEPhgqHhT+VXOv5pL7Kv0Jxojpfcjcn8f320rDOybd cuV7Rsl7LeHo/aBXgq3jImoFntXWYADUSQ== X-Google-Smtp-Source: AGRyM1vtTn2T+QOVqLcybyisBxPujJRWLdgc+6cHyguUBNZXuLOm/KxubEhyCJlvjFvJkNg6wedPIA== X-Received: by 2002:a63:195d:0:b0:412:50b8:c410 with SMTP id 29-20020a63195d000000b0041250b8c410mr24174553pgz.520.1658162921059; Mon, 18 Jul 2022 09:48:41 -0700 (PDT) Received: from code-infra-dev-cbj.ea134 ([140.205.70.36]) by smtp.gmail.com with ESMTPSA id d66-20020a621d45000000b00528669a770esm9671074pfd.90.2022.07.18.09.48.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2022 09:48:32 -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 v7 7/7] tr2: dump names if config exist in multiple scopes Date: Tue, 19 Jul 2022 00:46:06 +0800 Message-Id: X-Mailer: git-send-email 2.35.1.581.g7a5d018042 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 --- Documentation/technical/api-trace2.txt | 45 ++++++++++++++++++++++++++ trace2/tr2_tgt_event.c | 3 ++ trace2/tr2_tgt_normal.c | 5 ++- trace2/tr2_tgt_perf.c | 9 ++++-- 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt index bb13ca3db8..48205a5ac5 100644 --- a/Documentation/technical/api-trace2.txt +++ b/Documentation/technical/api-trace2.txt @@ -1207,6 +1207,51 @@ at offset 508. This example also shows that thread names are assigned in a racy manner as each thread starts and allocates TLS storage. +Print Configs:: + + Dump "interesting" config values to trace2 log. ++ +The environment variable `GIT_TRACE2_CONFIG_PARAMS` and configuration +`trace2.configparams` can be used to output config values which you care +about. For example, assume that we want to config different `color.ui` +values in multiple scopes, such as: ++ +---------------- +$ git config --system color.ui never +$ git config --global color.ui always +$ git config --local color.ui auto +$ git config --list --show-scope | grep 'color.ui' +system color.ui=never +global color.ui=always +local color.ui=auto +---------------- ++ +Then, mark the config `color.ui` as "interesting" config with +`GIT_TRACE2_CONFIG_PARAMS`: ++ +---------------- +$ export GIT_TRACE2_PERF_BRIEF=1 +$ export GIT_TRACE2_PERF=~/log.perf +$ export GIT_TRACE2_CONFIG_PARAMS=color.ui +$ git version +... +$ cat ~/log.perf +d0 | main | version | | | | | ... +d0 | main | start | | 0.000284 | | | /opt/git/master/bin/git version +d0 | main | cmd_ancestry | | | | | ancestry:[bash sshd sshd sshd systemd] +d0 | main | cmd_name | | | | | version (version) +d0 | main | exit | | 0.000419 | | | code:0 +d0 | main | atexit | | 0.000426 | | | code:0 +d0 | main | version | | | | | ... +d0 | main | start | | 0.000275 | | | /opt/git/master/bin/git version +d0 | main | cmd_ancestry | | | | | ancestry:[bash sshd sshd sshd systemd] +d0 | main | cmd_name | | | | | version (version) +d0 | main | def_param | | | | | color.ui:never +d0 | main | def_param | | | | | color.ui:always +d0 | main | def_param | | | | | color.ui:auto +d0 | main | exit | | 0.000543 | | | code:0 +d0 | main | atexit | | 0.000549 | | | code:0 +---------------- == Future Work === Relationship to the Existing Trace Api (api-trace.txt) 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,