{"thread":{"id":"43461","subject":"[PATCH] Add git-count-packs, like git-count-objects.","startedAt":"2006-10-28T04:00:56Z","lastAt":"2006-11-03T12:53:08Z","messageCount":6,"participants":["Shawn Pearce","Jakub Narebski","Junio C Hamano","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294897","messageId":"20061028040056.GA14191@spearce.org","threadId":"43461","inReplyTo":null,"subject":"[PATCH] Add git-count-packs, like git-count-objects.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-10-28T04:00:56Z","receivedAt":"2006-10-28T04:00:56Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Now that we are starting to save packs rather than unpacking into\nloose objects its nice to have a way to list the number of current\npacks and their total size.  This can help the user in deciding\nwhen its time to run `git repack -a -d`.\n\nIn the future when we actually start to support historical packs\nvs. active packs we probably should be reporting by default on the\nnumber of active packs and ignoring the historical packs.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n .gitignore                        |    1 +\n Documentation/git-count-packs.txt |   29 +++++++++++++++++++++++++++++\n Makefile                          |    1 +\n builtin-count-packs.c             |   29 +++++++++++++++++++++++++++++\n builtin.h                         |    1 +\n git.c                             |    1 +\n 6 files changed, 62 insertions(+), 0 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex b670877..31be347 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -23,6 +23,7 @@ git-commit\n git-commit-tree\n git-convert-objects\n git-count-objects\n+git-count-packs\n git-cvsexportcommit\n git-cvsimport\n git-cvsserver\ndiff --git a/Documentation/git-count-packs.txt b/Documentation/git-count-packs.txt\nnew file mode 100644\nindex 0000000..1420241\n--- /dev/null\n+++ b/Documentation/git-count-packs.txt\n@@ -0,0 +1,29 @@\n+git-count-packs(1)\n+====================\n+\n+NAME\n+----\n+git-count-packs - Reports on packs\n+\n+SYNOPSIS\n+--------\n+'git-count-packs'\n+\n+DESCRIPTION\n+-----------\n+This counts the number of pack files and disk space consumed by\n+them, to help you decide when it is a good time to repack.\n+\n+\n+Author\n+------\n+Written by Shawn O. Pearce <spearce@spearce.org>\n+\n+Documentation\n+--------------\n+Documentation by Shawn O. Pearce.\n+\n+GIT\n+---\n+Part of the gitlink:git[7] suite\n+\ndiff --git a/Makefile b/Makefile\nindex 2d62efb..b7fd558 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -275,6 +275,7 @@ BUILTIN_OBJS = \\\n \tbuiltin-check-ref-format.o \\\n \tbuiltin-commit-tree.o \\\n \tbuiltin-count-objects.o \\\n+\tbuiltin-count-packs.o \\\n \tbuiltin-diff.o \\\n \tbuiltin-diff-files.o \\\n \tbuiltin-diff-index.o \\\ndiff --git a/builtin-count-packs.c b/builtin-count-packs.c\nnew file mode 100644\nindex 0000000..f5a5940\n--- /dev/null\n+++ b/builtin-count-packs.c\n@@ -0,0 +1,29 @@\n+/*\n+ * Builtin \"git count-packs\".\n+ *\n+ * Copyright (c) 2006 Shawn Pearce\n+ */\n+\n+#include \"cache.h\"\n+#include \"builtin.h\"\n+\n+static const char count_packs_usage[] = \"git-count-packs\";\n+\n+int cmd_count_packs(int ac, const char **av, const char *prefix)\n+{\n+\tstruct packed_git *p;\n+\tunsigned long packs = 0, pack_size = 0;\n+\n+\tif (!ac)\n+\t\tusage(count_packs_usage);\n+\n+\tprepare_packed_git();\n+\tfor (p = packed_git; p; p = p->next) {\n+\t\tif (!p->pack_local)\n+\t\t\tcontinue;\n+\t\tpacks++;\n+\t\tpack_size += p->pack_size / (1024 * 1024);\n+\t}\n+\tprintf(\"%lu packs, %lu megabytes\\n\", packs, pack_size);\n+\treturn 0;\n+}\ndiff --git a/builtin.h b/builtin.h\nindex 708a2f2..410577e 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -22,6 +22,7 @@ extern int cmd_checkout_index(int argc,\n extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);\n extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);\n extern int cmd_count_objects(int argc, const char **argv, const char *prefix);\n+extern int cmd_count_packs(int argc, const char **argv, const char *prefix);\n extern int cmd_diff_files(int argc, const char **argv, const char *prefix);\n extern int cmd_diff_index(int argc, const char **argv, const char *prefix);\n extern int cmd_diff(int argc, const char **argv, const char *prefix);\ndiff --git a/git.c b/git.c\nindex 6475847..9ad0f01 100644\n--- a/git.c\n+++ b/git.c\n@@ -227,6 +227,7 @@ static void handle_internal_command(int\n \t\t{ \"check-ref-format\", cmd_check_ref_format },\n \t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP },\n \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n+\t\t{ \"count-packs\", cmd_count_packs, RUN_SETUP },\n \t\t{ \"diff\", cmd_diff, RUN_SETUP | USE_PAGER },\n \t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP },\n \t\t{ \"diff-index\", cmd_diff_index, RUN_SETUP },\n-- \n1.4.3.3.g7d63\n"},{"id":"295931","messageId":"7v8xj1axlm.fsf@assigned-by-dhcp.cox.net","threadId":"43461","inReplyTo":"20061028040056.GA14191@spearce.org","subject":"Re: [PATCH] Add git-count-packs, like git-count-objects.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-28T04:11:17Z","receivedAt":"2006-10-28T04:11:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shawn Pearce <spearce@spearce.org> writes:\n\n> Now that we are starting to save packs rather than unpacking into\n> loose objects its nice to have a way to list the number of current\n> packs and their total size.  This can help the user in deciding\n> when its time to run `git repack -a -d`.\n\nWhy not just do \"ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack\"???\n"},{"id":"297966","messageId":"20061028065143.GA14607@spearce.org","threadId":"43461","inReplyTo":"7v8xj1axlm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Add git-count-packs, like git-count-objects.","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-10-28T06:51:43Z","receivedAt":"2006-10-28T06:51:43Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Shawn Pearce <spearce@spearce.org> writes:\n> \n> > Now that we are starting to save packs rather than unpacking into\n> > loose objects its nice to have a way to list the number of current\n> > packs and their total size.  This can help the user in deciding\n> > when its time to run `git repack -a -d`.\n> \n> Why not just do \"ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack\"???\n\nBecause whatever we decide to use to make a pack 'active' may not\nbe that simple.\n\nWhatever.  It was clearly a very tiny patch put together quickly\nbefore dinner tonight, perhaps not worth including at this point.\nLets see what comes out of the other pack oriented discussion first.\n\n-- \n"},{"id":"294931","messageId":"ehvpcs$20j$2@sea.gmane.org","threadId":"43461","inReplyTo":"20061028065143.GA14607@spearce.org","subject":"Re: [PATCH] Add git-count-packs, like git-count-objects.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-28T14:28:29Z","receivedAt":"2006-10-28T14:28:29Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Shawn Pearce wrote:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> Shawn Pearce <spearce@spearce.org> writes:\n>> \n>> > Now that we are starting to save packs rather than unpacking into\n>> > loose objects its nice to have a way to list the number of current\n>> > packs and their total size.  This can help the user in deciding\n>> > when its time to run `git repack -a -d`.\n>> \n>> Why not just do \"ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack\"???\n> \n> Because whatever we decide to use to make a pack 'active' may not\n> be that simple.\n> \n> Whatever.  It was clearly a very tiny patch put together quickly\n> before dinner tonight, perhaps not worth including at this point.\n> Lets see what comes out of the other pack oriented discussion first.\n\nPerhaps to nod add yet another command to already large set, rename\ngit-count-objects to git-count end enhance it to count both loose objects\nand packs (or not, and use git-count-objects name).\n\nBTW what does \"garbage:\" in git-count-objects -v mean? And in what units\ngit-count-objects -v returns \"size:\" (git-count-objects says \"kilobytes\",\nwhy git-count-objects -v doesn't do the same)?\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"298576","messageId":"fcaeb9bf0611020130r70ed6f4cnf67586deff36452e@mail.gmail.com","threadId":"43461","inReplyTo":"ehvpcs$20j$2@sea.gmane.org","subject":"Re: [PATCH] Add git-count-packs, like git-count-objects.","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2006-11-02T09:30:16Z","receivedAt":"2006-11-02T09:30:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 10/28/06, Jakub Narebski <jnareb@gmail.com> wrote:\n> Perhaps to nod add yet another command to already large set, rename\n> git-count-objects to git-count end enhance it to count both loose objects\n> and packs (or not, and use git-count-objects name).\n\nOh if so, I'd suggest git-stats over git-count :-)\n-- \n"},{"id":"296310","messageId":"eife2p$qqq$1@sea.gmane.org","threadId":"43461","inReplyTo":"fcaeb9bf0611020130r70ed6f4cnf67586deff36452e@mail.gmail.com","subject":"Re: [PATCH] Add git-count-packs, like git-count-objects.","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-11-03T12:53:08Z","receivedAt":"2006-11-03T12:53:08Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> On 10/28/06, Jakub Narebski <jnareb@gmail.com> wrote:\n\n>> Perhaps to not to add yet another command to already large set, rename\n>> git-count-objects to git-count, and enhance it to count both loose objects\n>> and packs (or not, and use git-count-objects as command name).\n> \n> Oh if so, I'd suggest git-stats over git-count :-)\n\nOr even git-db-stats (as companion to git-db-init).\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"}]}