Skip to content

Commit baf20c3

Browse files
dyronegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd59c5b commit baf20c3

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

pack-bitmap.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "cache.h"
22
#include "commit.h"
3+
#include "strbuf.h"
34
#include "tag.h"
45
#include "diff.h"
56
#include "revision.h"
@@ -138,7 +139,7 @@ static struct ewah_bitmap *read_bitmap_1(struct bitmap_index *index)
138139
index->map_size - index->map_pos);
139140

140141
if (bitmap_size < 0) {
141-
error("Failed to load bitmap index (corrupted?)");
142+
error("failed to load bitmap index (corrupted?)");
142143
ewah_pool_free(b);
143144
return NULL;
144145
}
@@ -160,14 +161,14 @@ static int load_bitmap_header(struct bitmap_index *index)
160161
size_t header_size = sizeof(*header) - GIT_MAX_RAWSZ + the_hash_algo->rawsz;
161162

162163
if (index->map_size < header_size + the_hash_algo->rawsz)
163-
return error("Corrupted bitmap index (too small)");
164+
return error("corrupted bitmap index (too small)");
164165

165166
if (memcmp(header->magic, BITMAP_IDX_SIGNATURE, sizeof(BITMAP_IDX_SIGNATURE)) != 0)
166-
return error("Corrupted bitmap index file (wrong header)");
167+
return error("corrupted bitmap index file (wrong header)");
167168

168169
index->version = ntohs(header->version);
169170
if (index->version != 1)
170-
return error("Unsupported version for bitmap index file (%d)", index->version);
171+
return error("unsupported version '%d' for bitmap index file", index->version);
171172

172173
/* Parse known bitmap format options */
173174
{
@@ -176,7 +177,7 @@ static int load_bitmap_header(struct bitmap_index *index)
176177
unsigned char *index_end = index->map + index->map_size - the_hash_algo->rawsz;
177178

178179
if ((flags & BITMAP_OPT_FULL_DAG) == 0)
179-
return error("Unsupported options for bitmap index file "
180+
BUG("unsupported options for bitmap index file "
180181
"(Git requires BITMAP_OPT_FULL_DAG)");
181182

182183
if (flags & BITMAP_OPT_HASH_CACHE) {
@@ -215,7 +216,7 @@ static struct stored_bitmap *store_bitmap(struct bitmap_index *index,
215216
* because the SHA1 already existed on the map. this is bad, there
216217
* shouldn't be duplicated commits in the index */
217218
if (ret == 0) {
218-
error("Duplicate entry in bitmap index: %s", oid_to_hex(oid));
219+
error("duplicate entry in bitmap index: '%s'", oid_to_hex(oid));
219220
return NULL;
220221
}
221222

@@ -274,13 +275,13 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
274275
return -1;
275276

276277
if (xor_offset > MAX_XOR_OFFSET || xor_offset > i)
277-
return error("Corrupted bitmap pack index");
278+
return error("corrupted bitmap pack index");
278279

279280
if (xor_offset > 0) {
280281
xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
281282

282283
if (xor_bitmap == NULL)
283-
return error("Invalid XOR offset in bitmap pack index");
284+
return error("invalid XOR offset in bitmap pack index");
284285
}
285286

286287
recent_bitmaps[i % MAX_XOR_OFFSET] = store_bitmap(
@@ -330,7 +331,7 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
330331
struct strbuf buf = STRBUF_INIT;
331332
get_midx_filename(&buf, midx->object_dir);
332333
/* ignore extra bitmap file; we can only handle one */
333-
warning("ignoring extra bitmap file: %s", buf.buf);
334+
warning("ignoring extra bitmap file: '%s'", buf.buf);
334335
close(fd);
335336
strbuf_release(&buf);
336337
return -1;
@@ -387,7 +388,7 @@ static int open_pack_bitmap_1(struct bitmap_index *bitmap_git, struct packed_git
387388

388389
if (bitmap_git->pack || bitmap_git->midx) {
389390
/* ignore extra bitmap file; we can only handle one */
390-
warning("ignoring extra bitmap file: %s", packfile->pack_name);
391+
warning("ignoring extra bitmap file: '%s'", packfile->pack_name);
391392
close(fd);
392393
return -1;
393394
}
@@ -1626,15 +1627,15 @@ static void test_bitmap_type(struct bitmap_test_data *tdata,
16261627
}
16271628

16281629
if (bitmap_type == OBJ_NONE)
1629-
die("object %s not found in type bitmaps",
1630+
die("object '%s' not found in type bitmaps",
16301631
oid_to_hex(&obj->oid));
16311632

16321633
if (bitmaps_nr > 1)
1633-
die("object %s does not have a unique type",
1634+
die("object '%s' does not have a unique type",
16341635
oid_to_hex(&obj->oid));
16351636

16361637
if (bitmap_type != obj->type)
1637-
die("object %s: real type %s, expected: %s",
1638+
die("object '%s': real type '%s', expected: '%s'",
16381639
oid_to_hex(&obj->oid),
16391640
type_name(obj->type),
16401641
type_name(bitmap_type));
@@ -1648,7 +1649,7 @@ static void test_show_object(struct object *object, const char *name,
16481649

16491650
bitmap_pos = bitmap_position(tdata->bitmap_git, &object->oid);
16501651
if (bitmap_pos < 0)
1651-
die("Object not in bitmap: %s\n", oid_to_hex(&object->oid));
1652+
die("object not in bitmap: '%s'", oid_to_hex(&object->oid));
16521653
test_bitmap_type(tdata, object, bitmap_pos);
16531654

16541655
bitmap_set(tdata->base, bitmap_pos);
@@ -1663,7 +1664,7 @@ static void test_show_commit(struct commit *commit, void *data)
16631664
bitmap_pos = bitmap_position(tdata->bitmap_git,
16641665
&commit->object.oid);
16651666
if (bitmap_pos < 0)
1666-
die("Object not in bitmap: %s\n", oid_to_hex(&commit->object.oid));
1667+
die("object not in bitmap: '%s'", oid_to_hex(&commit->object.oid));
16671668
test_bitmap_type(tdata, &commit->object, bitmap_pos);
16681669

16691670
bitmap_set(tdata->base, bitmap_pos);
@@ -1685,21 +1686,21 @@ void test_bitmap_walk(struct rev_info *revs)
16851686
if (revs->pending.nr != 1)
16861687
die("you must specify exactly one commit to test");
16871688

1688-
fprintf(stderr, "Bitmap v%d test (%d entries loaded)\n",
1689+
fprintf_ln(stderr, "Bitmap v%d test (%d entries loaded)",
16891690
bitmap_git->version, bitmap_git->entry_count);
16901691

16911692
root = revs->pending.objects[0].item;
16921693
bm = bitmap_for_commit(bitmap_git, (struct commit *)root);
16931694

16941695
if (bm) {
1695-
fprintf(stderr, "Found bitmap for %s. %d bits / %08x checksum\n",
1696+
fprintf_ln(stderr, "Found bitmap for '%s'. %d bits / %08x checksum",
16961697
oid_to_hex(&root->oid), (int)bm->bit_size, ewah_checksum(bm));
16971698

16981699
result = ewah_to_bitmap(bm);
16991700
}
17001701

17011702
if (result == NULL)
1702-
die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
1703+
die("commit '%s' doesn't have an indexed bitmap", oid_to_hex(&root->oid));
17031704

17041705
revs->tag_objects = 1;
17051706
revs->tree_objects = 1;
@@ -1724,7 +1725,7 @@ void test_bitmap_walk(struct rev_info *revs)
17241725
stop_progress(&tdata.prg);
17251726

17261727
if (bitmap_equals(result, tdata.base))
1727-
fprintf(stderr, "OK!\n");
1728+
fprintf_ln(stderr, "OK!");
17281729
else
17291730
die("mismatch in bitmap results");
17301731

@@ -1747,7 +1748,7 @@ int test_bitmap_commits(struct repository *r)
17471748
die("failed to load bitmap indexes");
17481749

17491750
kh_foreach(bitmap_git->bitmaps, oid, value, {
1750-
printf("%s\n", oid_to_hex(&oid));
1751+
printf_ln("%s", oid_to_hex(&oid));
17511752
});
17521753

17531754
free_bitmap_index(bitmap_git);
@@ -1772,7 +1773,7 @@ int test_bitmap_hashes(struct repository *r)
17721773

17731774
nth_bitmap_object_oid(bitmap_git, &oid, index_pos);
17741775

1775-
printf("%s %"PRIu32"\n",
1776+
printf_ln("%s %"PRIu32"",
17761777
oid_to_hex(&oid), get_be32(bitmap_git->hashes + index_pos));
17771778
}
17781779

@@ -1934,7 +1935,7 @@ static off_t get_disk_usage_for_type(struct bitmap_index *bitmap_git,
19341935
struct object_id oid;
19351936
nth_midxed_object_oid(&oid, bitmap_git->midx, midx_pos);
19361937

1937-
die(_("could not find %s in pack %s at offset %"PRIuMAX),
1938+
die(_("could not find '%s' in pack '%s' at offset %"PRIuMAX),
19381939
oid_to_hex(&oid),
19391940
pack->pack_name,
19401941
(uintmax_t)offset);
@@ -1970,7 +1971,7 @@ static off_t get_disk_usage_for_extended(struct bitmap_index *bitmap_git)
19701971
continue;
19711972

19721973
if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
1973-
die(_("unable to get disk usage of %s"),
1974+
die(_("unable to get disk usage of '%s'"),
19741975
oid_to_hex(&obj->oid));
19751976

19761977
total += object_size;

0 commit comments

Comments
 (0)