Skip to content

Commit 262b04f

Browse files
committed
verify-pack -v: do not report "chain length 0"
When making a histogram of delta chain length in the pack, the program collects number of objects whose delta depth exceeds the MAX_CHAIN limit in histogram[0], and showed it as the number of items that exceeds the limit correctly. HOWEVER, it also showed the same number labeled as "chain length = 0". In fact, we are not showing the number of objects whose chain length is zero, i.e. the base objects. Correct this. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e674a9 commit 262b04f

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

builtin-verify-pack.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
static void show_pack_info(struct packed_git *p)
99
{
10-
uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
10+
uint32_t nr_objects, i;
11+
int cnt;
12+
unsigned long chain_histogram[MAX_CHAIN+1], baseobjects;
1113

1214
nr_objects = p->num_objects;
1315
memset(chain_histogram, 0, sizeof(chain_histogram));
16+
baseobjects = 0;
1417

1518
for (i = 0; i < nr_objects; i++) {
1619
const unsigned char *sha1;
@@ -29,9 +32,11 @@ static void show_pack_info(struct packed_git *p)
2932
&delta_chain_length,
3033
base_sha1);
3134
printf("%s ", sha1_to_hex(sha1));
32-
if (!delta_chain_length)
35+
if (!delta_chain_length) {
3336
printf("%-6s %lu %lu %"PRIuMAX"\n",
3437
type, size, store_size, (uintmax_t)offset);
38+
baseobjects++;
39+
}
3540
else {
3641
printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
3742
type, size, store_size, (uintmax_t)offset,
@@ -43,15 +48,21 @@ static void show_pack_info(struct packed_git *p)
4348
}
4449
}
4550

46-
for (i = 0; i <= MAX_CHAIN; i++) {
47-
if (!chain_histogram[i])
51+
if (baseobjects)
52+
printf("non delta: %lu object%s\n",
53+
baseobjects, baseobjects > 1 ? "s" : "");
54+
55+
for (cnt = 1; cnt <= MAX_CHAIN; cnt++) {
56+
if (!chain_histogram[cnt])
4857
continue;
49-
printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
50-
chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
58+
printf("chain length = %d: %lu object%s\n", cnt,
59+
chain_histogram[cnt],
60+
chain_histogram[cnt] > 1 ? "s" : "");
5161
}
5262
if (chain_histogram[0])
53-
printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
54-
chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
63+
printf("chain length > %d: %lu object%s\n", MAX_CHAIN,
64+
chain_histogram[0],
65+
chain_histogram[0] > 1 ? "s" : "");
5566
}
5667

5768
static int verify_one_pack(const char *path, int verbose)

0 commit comments

Comments
 (0)