Skip to content

Commit

Permalink
verify-pack -v: do not report "chain length 0"
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gitster committed Aug 8, 2009
1 parent 2e674a9 commit 262b04f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions builtin-verify-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@

static void show_pack_info(struct packed_git *p)
{
uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
uint32_t nr_objects, i;
int cnt;
unsigned long chain_histogram[MAX_CHAIN+1], baseobjects;

nr_objects = p->num_objects;
memset(chain_histogram, 0, sizeof(chain_histogram));
baseobjects = 0;

for (i = 0; i < nr_objects; i++) {
const unsigned char *sha1;
Expand All @@ -29,9 +32,11 @@ static void show_pack_info(struct packed_git *p)
&delta_chain_length,
base_sha1);
printf("%s ", sha1_to_hex(sha1));
if (!delta_chain_length)
if (!delta_chain_length) {
printf("%-6s %lu %lu %"PRIuMAX"\n",
type, size, store_size, (uintmax_t)offset);
baseobjects++;
}
else {
printf("%-6s %lu %lu %"PRIuMAX" %u %s\n",
type, size, store_size, (uintmax_t)offset,
Expand All @@ -43,15 +48,21 @@ static void show_pack_info(struct packed_git *p)
}
}

for (i = 0; i <= MAX_CHAIN; i++) {
if (!chain_histogram[i])
if (baseobjects)
printf("non delta: %lu object%s\n",
baseobjects, baseobjects > 1 ? "s" : "");

for (cnt = 1; cnt <= MAX_CHAIN; cnt++) {
if (!chain_histogram[cnt])
continue;
printf("chain length = %"PRIu32": %"PRIu32" object%s\n", i,
chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
printf("chain length = %d: %lu object%s\n", cnt,
chain_histogram[cnt],
chain_histogram[cnt] > 1 ? "s" : "");
}
if (chain_histogram[0])
printf("chain length > %d: %"PRIu32" object%s\n", MAX_CHAIN,
chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
printf("chain length > %d: %lu object%s\n", MAX_CHAIN,
chain_histogram[0],
chain_histogram[0] > 1 ? "s" : "");
}

static int verify_one_pack(const char *path, int verbose)
Expand Down

0 comments on commit 262b04f

Please sign in to comment.