From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nicolas Pitre" <nico@fluxnic.net>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 10/10] count-objects: report pack v4 usage
Date: Thu, 26 Sep 2013 09:26:49 +0700 [thread overview]
Message-ID: <1380162409-18224-11-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1380162409-18224-1-git-send-email-pclouds@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2013-09-26 2:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-26 2:26 [PATCH 00/10] pack v4 UI support Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 01/10] test-dump: new test program to examine binary data Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 02/10] config: add core.preferredPackVersion Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 03/10] upload-pack: new capability to send pack v4 Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 04/10] fetch: new option to set preferred pack version for transfer Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 05/10] clone: " Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 06/10] fetch: pack v4 support on smart http Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 07/10] receive-pack: request for packv4 if it's the preferred version Nguyễn Thái Ngọc Duy
2013-10-17 17:26 ` Junio C Hamano
2013-09-26 2:26 ` [PATCH 08/10] send-pack: support pack v4 Nguyễn Thái Ngọc Duy
2013-09-26 2:26 ` [PATCH 09/10] repack: add --pack-version and fall back to core.preferredPackVersion Nguyễn Thái Ngọc Duy
2013-09-26 8:32 ` [PATCH] repack: Add --version parameter Stefan Beller
2013-09-26 10:17 ` Felipe Contreras
2013-09-28 8:53 ` Stefan Beller
2013-09-26 11:42 ` Duy Nguyen
2013-09-28 8:54 ` Stefan Beller
2013-09-26 2:26 ` Nguyễn Thái Ngọc Duy [this message]
2013-09-26 4:51 ` [PATCH 00/10] pack v4 UI support Nicolas Pitre
2013-09-26 5:09 ` Duy Nguyen
2013-09-27 2:59 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380162409-18224-11-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=nico@fluxnic.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).