pack-bitmap.c: fix formatting of error messages
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 <dyroneteng@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fd59c5bdee
commit
baf20c39a7
@ -1,5 +1,6 @@
|
|||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "commit.h"
|
#include "commit.h"
|
||||||
|
#include "strbuf.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "diff.h"
|
#include "diff.h"
|
||||||
#include "revision.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);
|
index->map_size - index->map_pos);
|
||||||
|
|
||||||
if (bitmap_size < 0) {
|
if (bitmap_size < 0) {
|
||||||
error("Failed to load bitmap index (corrupted?)");
|
error("failed to load bitmap index (corrupted?)");
|
||||||
ewah_pool_free(b);
|
ewah_pool_free(b);
|
||||||
return NULL;
|
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;
|
size_t header_size = sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz;
|
||||||
|
|
||||||
if (index->map_size < header_size + 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)
|
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);
|
index->version = ntohs(header->version);
|
||||||
if (index->version != 1)
|
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 */
|
/* 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;
|
unsigned char *index_end = index->map + index->map_size - the_hash_algo->rawsz;
|
||||||
|
|
||||||
if ((flags & BITMAP_OPT_FULL_DAG) == 0)
|
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)");
|
"(Git requires BITMAP_OPT_FULL_DAG)");
|
||||||
|
|
||||||
if (flags & BITMAP_OPT_HASH_CACHE) {
|
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
|
* because the SHA1 already existed on the map. this is bad, there
|
||||||
* shouldn't be duplicated commits in the index */
|
* shouldn't be duplicated commits in the index */
|
||||||
if (ret == 0) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,13 +275,13 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xor_offset > MAX_XOR_OFFSET || xor_offset > i)
|
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) {
|
if (xor_offset > 0) {
|
||||||
xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
|
xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
|
||||||
|
|
||||||
if (xor_bitmap == NULL)
|
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(
|
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;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
get_midx_filename(&buf, midx->object_dir);
|
get_midx_filename(&buf, midx->object_dir);
|
||||||
/* ignore extra bitmap file; we can only handle one */
|
/* 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);
|
close(fd);
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
return -1;
|
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) {
|
if (bitmap_git->pack || bitmap_git->midx) {
|
||||||
/* ignore extra bitmap file; we can only handle one */
|
/* 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);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1626,15 +1627,15 @@ static void test_bitmap_type(struct bitmap_test_data *tdata,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap_type == OBJ_NONE)
|
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));
|
oid_to_hex(&obj->oid));
|
||||||
|
|
||||||
if (bitmaps_nr > 1)
|
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));
|
oid_to_hex(&obj->oid));
|
||||||
|
|
||||||
if (bitmap_type != obj->type)
|
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),
|
oid_to_hex(&obj->oid),
|
||||||
type_name(obj->type),
|
type_name(obj->type),
|
||||||
type_name(bitmap_type));
|
type_name(bitmap_type));
|
||||||
@ -1648,7 +1649,7 @@ static void test_show_object(struct object *object, const char *name,
|
|||||||
|
|
||||||
bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
|
bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
|
||||||
if (bitmap_pos < 0)
|
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);
|
test_bitmap_type(tdata, object, bitmap_pos);
|
||||||
|
|
||||||
bitmap_set(tdata->base, bitmap_pos);
|
bitmap_set(tdata->base, bitmap_pos);
|
||||||
@ -1663,7 +1664,7 @@ static void test_show_commit(struct commit *commit, void *data)
|
|||||||
bitmap_pos = bitmap_position(tdata->bitmap_git,
|
bitmap_pos = bitmap_position(tdata->bitmap_git,
|
||||||
&commit->object.oid);
|
&commit->object.oid);
|
||||||
if (bitmap_pos < 0)
|
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);
|
test_bitmap_type(tdata, &commit->object, bitmap_pos);
|
||||||
|
|
||||||
bitmap_set(tdata->base, bitmap_pos);
|
bitmap_set(tdata->base, bitmap_pos);
|
||||||
@ -1685,21 +1686,21 @@ void test_bitmap_walk(struct rev_info *revs)
|
|||||||
if (revs->pending.nr != 1)
|
if (revs->pending.nr != 1)
|
||||||
die("you must specify exactly one commit to test");
|
die("you must specify exactly one commit to test");
|
||||||
|
|
||||||
fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n",
|
fprintf_ln(stderr, "Bitmap v%d test (%d entries loaded)",
|
||||||
bitmap_git->version, bitmap_git->entry_count);
|
bitmap_git->version, bitmap_git->entry_count);
|
||||||
|
|
||||||
root = revs->pending.objects[0].item;
|
root = revs->pending.objects[0].item;
|
||||||
bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
|
bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
|
||||||
|
|
||||||
if (bm) {
|
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));
|
oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm));
|
||||||
|
|
||||||
result = ewah_to_bitmap(bm);
|
result = ewah_to_bitmap(bm);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == NULL)
|
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->tag_objects = 1;
|
||||||
revs->tree_objects = 1;
|
revs->tree_objects = 1;
|
||||||
@ -1724,7 +1725,7 @@ void test_bitmap_walk(struct rev_info *revs)
|
|||||||
stop_progress(&tdata.prg);
|
stop_progress(&tdata.prg);
|
||||||
|
|
||||||
if (bitmap_equals(result, tdata.base))
|
if (bitmap_equals(result, tdata.base))
|
||||||
fprintf(stderr, "OK!\n");
|
fprintf_ln(stderr, "OK!");
|
||||||
else
|
else
|
||||||
die("mismatch in bitmap results");
|
die("mismatch in bitmap results");
|
||||||
|
|
||||||
@ -1747,7 +1748,7 @@ int test_bitmap_commits(struct repository *r)
|
|||||||
die("failed to load bitmap indexes");
|
die("failed to load bitmap indexes");
|
||||||
|
|
||||||
kh_foreach(bitmap_git->bitmaps, oid, value, {
|
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);
|
free_bitmap_index(bitmap_git);
|
||||||
@ -1772,7 +1773,7 @@ int test_bitmap_hashes(struct repository *r)
|
|||||||
|
|
||||||
nth_bitmap_object_oid(bitmap_git, &oid, index_pos);
|
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));
|
oid_to_hex(&oid), get_be32(bitmap_git->hashes + index_pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1934,7 +1935,7 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
|
|||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
nth_midxed_object_oid(&oid, bitmap_git->midx, midx_pos);
|
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),
|
oid_to_hex(&oid),
|
||||||
pack->pack_name,
|
pack->pack_name,
|
||||||
(uintmax_t)offset);
|
(uintmax_t)offset);
|
||||||
@ -1970,7 +1971,7 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
|
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));
|
oid_to_hex(&obj->oid));
|
||||||
|
|
||||||
total += object_size;
|
total += object_size;
|
||||||
|
Reference in New Issue
Block a user