An ideal repository is v4 only, no v2 packs. Show pack v4 statistics so people know if the repository is mixed with v2 and repack it. Note that "in-pack" and "size-pack" include all pack versions, not just v2. Only display v4 info when there are v4 packs. It's still experimental so don't polute the output with v4 that's never used by 99.99% of users. We can make it unconditional later when v4 is officially supported and recommended. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- Documentation/git-count-objects.txt | 4 ++++ builtin/count-objects.c | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Documentation/git-count-objects.txt b/Documentation/git-count-objects.txt index b300e84..d15b4dc 100644 --- a/Documentation/git-count-objects.txt +++ b/Documentation/git-count-objects.txt @@ -28,8 +28,12 @@ size: disk space consumed by loose objects, in KiB (unless -H is specified) + in-pack: the number of in-pack objects + +in-packv4: the number of objects in packs version 4 ++ size-pack: disk space consumed by the packs, in KiB (unless -H is specified) + +size-packv4: disk space consumed by the packs version 4 ++ prune-packable: the number of loose objects that are also present in the packs. These objects could be pruned using `git prune-packed`. + diff --git a/builtin/count-objects.c b/builtin/count-objects.c index a7f70cb..db73ce7 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -89,7 +89,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix) const char *objdir = get_object_directory(); int len = strlen(objdir); char *path = xmalloc(len + 50); - unsigned long loose = 0, packed = 0, packed_loose = 0; + unsigned long loose = 0, packed_loose = 0; off_t loose_size = 0; struct option opts[] = { OPT__VERBOSE(&verbose, N_("be verbose")), @@ -119,10 +119,12 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix) } if (verbose) { struct packed_git *p; - unsigned long num_pack = 0; - off_t size_pack = 0; + unsigned long num_pack = 0, num_pack_v4 = 0; + unsigned long packed = 0, packed_v4 = 0; + off_t size_pack = 0, size_pack_v4 = 0; struct strbuf loose_buf = STRBUF_INIT; struct strbuf pack_buf = STRBUF_INIT; + struct strbuf pack_buf_v4 = STRBUF_INIT; struct strbuf garbage_buf = STRBUF_INIT; if (!packed_git) prepare_packed_git(); @@ -134,17 +136,25 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix) packed += p->num_objects; size_pack += p->pack_size + p->index_size; num_pack++; + if (p->version == 4) { + packed_v4 += p->num_objects; + size_pack_v4 += p->pack_size + p->index_size; + num_pack_v4++; + } } if (human_readable) { strbuf_humanise_bytes(&loose_buf, loose_size); strbuf_humanise_bytes(&pack_buf, size_pack); + strbuf_humanise_bytes(&pack_buf_v4, size_pack_v4); strbuf_humanise_bytes(&garbage_buf, size_garbage); } else { strbuf_addf(&loose_buf, "%lu", (unsigned long)(loose_size / 1024)); strbuf_addf(&pack_buf, "%lu", (unsigned long)(size_pack / 1024)); + strbuf_addf(&pack_buf_v4, "%lu", + (unsigned long)(size_pack_v4 / 1024)); strbuf_addf(&garbage_buf, "%lu", (unsigned long)(size_garbage / 1024)); } @@ -152,13 +162,20 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix) printf("count: %lu\n", loose); printf("size: %s\n", loose_buf.buf); printf("in-pack: %lu\n", packed); + if (num_pack_v4) + printf("in-packv4: %lu\n", packed_v4); printf("packs: %lu\n", num_pack); + if (num_pack_v4) + printf("v4-packs: %lu\n", num_pack_v4); printf("size-pack: %s\n", pack_buf.buf); + if (num_pack_v4) + printf("size-packv4: %s\n", pack_buf_v4.buf); printf("prune-packable: %lu\n", packed_loose); printf("garbage: %lu\n", garbage); printf("size-garbage: %s\n", garbage_buf.buf); strbuf_release(&loose_buf); strbuf_release(&pack_buf); + strbuf_release(&pack_buf_v4); strbuf_release(&garbage_buf); } else { struct strbuf buf = STRBUF_INIT; -- 1.8.2.82.gc24b958 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html