@matheusbsbs / matheus-bagliano / commits / 262b04fa8d
Fork 0

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 <gitster@pobox.com>

Junio C Hamano committed Aug 7, 2009 at 15:36 UTC 262b04fa8dce84596738fd8c0dbff52994388efa
1 file changed +19 -8
builtin-verify-pack.c
+19 -8
@@ -7,10 +7,13 @@
7
8 static void show_pack_info(struct packed_git *p)
9 {
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;
13
14 nr_objects = p->num_objects;
15 memset(chain_histogram, 0, sizeof(chain_histogram));
16 + baseobjects = 0;
17
18 for (i = 0; i < nr_objects; i++) {
19 const unsigned char *sha1;
@@ -29,9 +32,11 @@ static void show_pack_info(struct packed_git *p)
32 &delta_chain_length,
33 base_sha1);
34 printf("%s ", sha1_to_hex(sha1));
32 - if (!delta_chain_length)
35 + if (!delta_chain_length) {
36 printf("%-6s %lu %lu %"PRIuMAX"\n",
37 type, size, store_size, (uintmax_t)offset);
38 + baseobjects++;
39 + }
40 else {
41 printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
42 type, size, store_size, (uintmax_t)offset,
@@ -43,15 +48,21 @@ static void show_pack_info(struct packed_git *p)
48 }
49 }
50
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])
57 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" : "");
61 }
62 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" : "");
66 }
67
68 static int verify_one_pack(const char *path, int verbose)