git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add git-count-packs, like git-count-objects.
@ 2006-10-28  4:00 Shawn Pearce
  2006-10-28  4:11 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Shawn Pearce @ 2006-10-28  4:00 UTC (permalink / raw)
  To: Junio C Hamano, git; +Cc: Nicolas Pitre

Now that we are starting to save packs rather than unpacking into
loose objects its nice to have a way to list the number of current
packs and their total size.  This can help the user in deciding
when its time to run `git repack -a -d`.

In the future when we actually start to support historical packs
vs. active packs we probably should be reporting by default on the
number of active packs and ignoring the historical packs.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .gitignore                        |    1 +
 Documentation/git-count-packs.txt |   29 +++++++++++++++++++++++++++++
 Makefile                          |    1 +
 builtin-count-packs.c             |   29 +++++++++++++++++++++++++++++
 builtin.h                         |    1 +
 git.c                             |    1 +
 6 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index b670877..31be347 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ git-commit
 git-commit-tree
 git-convert-objects
 git-count-objects
+git-count-packs
 git-cvsexportcommit
 git-cvsimport
 git-cvsserver
diff --git a/Documentation/git-count-packs.txt b/Documentation/git-count-packs.txt
new file mode 100644
index 0000000..1420241
--- /dev/null
+++ b/Documentation/git-count-packs.txt
@@ -0,0 +1,29 @@
+git-count-packs(1)
+====================
+
+NAME
+----
+git-count-packs - Reports on packs
+
+SYNOPSIS
+--------
+'git-count-packs'
+
+DESCRIPTION
+-----------
+This counts the number of pack files and disk space consumed by
+them, to help you decide when it is a good time to repack.
+
+
+Author
+------
+Written by Shawn O. Pearce <spearce@spearce.org>
+
+Documentation
+--------------
+Documentation by Shawn O. Pearce.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
diff --git a/Makefile b/Makefile
index 2d62efb..b7fd558 100644
--- a/Makefile
+++ b/Makefile
@@ -275,6 +275,7 @@ BUILTIN_OBJS = \
 	builtin-check-ref-format.o \
 	builtin-commit-tree.o \
 	builtin-count-objects.o \
+	builtin-count-packs.o \
 	builtin-diff.o \
 	builtin-diff-files.o \
 	builtin-diff-index.o \
diff --git a/builtin-count-packs.c b/builtin-count-packs.c
new file mode 100644
index 0000000..f5a5940
--- /dev/null
+++ b/builtin-count-packs.c
@@ -0,0 +1,29 @@
+/*
+ * Builtin "git count-packs".
+ *
+ * Copyright (c) 2006 Shawn Pearce
+ */
+
+#include "cache.h"
+#include "builtin.h"
+
+static const char count_packs_usage[] = "git-count-packs";
+
+int cmd_count_packs(int ac, const char **av, const char *prefix)
+{
+	struct packed_git *p;
+	unsigned long packs = 0, pack_size = 0;
+
+	if (!ac)
+		usage(count_packs_usage);
+
+	prepare_packed_git();
+	for (p = packed_git; p; p = p->next) {
+		if (!p->pack_local)
+			continue;
+		packs++;
+		pack_size += p->pack_size / (1024 * 1024);
+	}
+	printf("%lu packs, %lu megabytes\n", packs, pack_size);
+	return 0;
+}
diff --git a/builtin.h b/builtin.h
index 708a2f2..410577e 100644
--- a/builtin.h
+++ b/builtin.h
@@ -22,6 +22,7 @@ extern int cmd_checkout_index(int argc,
 extern int cmd_check_ref_format(int argc, const char **argv, const char *prefix);
 extern int cmd_commit_tree(int argc, const char **argv, const char *prefix);
 extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
+extern int cmd_count_packs(int argc, const char **argv, const char *prefix);
 extern int cmd_diff_files(int argc, const char **argv, const char *prefix);
 extern int cmd_diff_index(int argc, const char **argv, const char *prefix);
 extern int cmd_diff(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 6475847..9ad0f01 100644
--- a/git.c
+++ b/git.c
@@ -227,6 +227,7 @@ static void handle_internal_command(int
 		{ "check-ref-format", cmd_check_ref_format },
 		{ "commit-tree", cmd_commit_tree, RUN_SETUP },
 		{ "count-objects", cmd_count_objects, RUN_SETUP },
+		{ "count-packs", cmd_count_packs, RUN_SETUP },
 		{ "diff", cmd_diff, RUN_SETUP | USE_PAGER },
 		{ "diff-files", cmd_diff_files, RUN_SETUP },
 		{ "diff-index", cmd_diff_index, RUN_SETUP },
-- 
1.4.3.3.g7d63

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add git-count-packs, like git-count-objects.
  2006-10-28  4:00 [PATCH] Add git-count-packs, like git-count-objects Shawn Pearce
@ 2006-10-28  4:11 ` Junio C Hamano
  2006-10-28  6:51   ` Shawn Pearce
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2006-10-28  4:11 UTC (permalink / raw)
  To: Shawn Pearce; +Cc: git, Nicolas Pitre

Shawn Pearce <spearce@spearce.org> writes:

> Now that we are starting to save packs rather than unpacking into
> loose objects its nice to have a way to list the number of current
> packs and their total size.  This can help the user in deciding
> when its time to run `git repack -a -d`.

Why not just do "ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack"???

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add git-count-packs, like git-count-objects.
  2006-10-28  4:11 ` Junio C Hamano
@ 2006-10-28  6:51   ` Shawn Pearce
  2006-10-28 14:28     ` Jakub Narebski
  0 siblings, 1 reply; 6+ messages in thread
From: Shawn Pearce @ 2006-10-28  6:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Nicolas Pitre

Junio C Hamano <junkio@cox.net> wrote:
> Shawn Pearce <spearce@spearce.org> writes:
> 
> > Now that we are starting to save packs rather than unpacking into
> > loose objects its nice to have a way to list the number of current
> > packs and their total size.  This can help the user in deciding
> > when its time to run `git repack -a -d`.
> 
> Why not just do "ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack"???

Because whatever we decide to use to make a pack 'active' may not
be that simple.

Whatever.  It was clearly a very tiny patch put together quickly
before dinner tonight, perhaps not worth including at this point.
Lets see what comes out of the other pack oriented discussion first.

-- 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add git-count-packs, like git-count-objects.
  2006-10-28  6:51   ` Shawn Pearce
@ 2006-10-28 14:28     ` Jakub Narebski
  2006-11-02  9:30       ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Narebski @ 2006-10-28 14:28 UTC (permalink / raw)
  To: git

Shawn Pearce wrote:

> Junio C Hamano <junkio@cox.net> wrote:
>> Shawn Pearce <spearce@spearce.org> writes:
>> 
>> > Now that we are starting to save packs rather than unpacking into
>> > loose objects its nice to have a way to list the number of current
>> > packs and their total size.  This can help the user in deciding
>> > when its time to run `git repack -a -d`.
>> 
>> Why not just do "ls -lh $GIT_OBJECT_DIR/pack/pack-*.pack"???
> 
> Because whatever we decide to use to make a pack 'active' may not
> be that simple.
> 
> Whatever.  It was clearly a very tiny patch put together quickly
> before dinner tonight, perhaps not worth including at this point.
> Lets see what comes out of the other pack oriented discussion first.

Perhaps to nod add yet another command to already large set, rename
git-count-objects to git-count end enhance it to count both loose objects
and packs (or not, and use git-count-objects name).

BTW what does "garbage:" in git-count-objects -v mean? And in what units
git-count-objects -v returns "size:" (git-count-objects says "kilobytes",
why git-count-objects -v doesn't do the same)?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add git-count-packs, like git-count-objects.
  2006-10-28 14:28     ` Jakub Narebski
@ 2006-11-02  9:30       ` Nguyen Thai Ngoc Duy
  2006-11-03 12:53         ` Jakub Narebski
  0 siblings, 1 reply; 6+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2006-11-02  9:30 UTC (permalink / raw)
  To: git

On 10/28/06, Jakub Narebski <jnareb@gmail.com> wrote:
> Perhaps to nod add yet another command to already large set, rename
> git-count-objects to git-count end enhance it to count both loose objects
> and packs (or not, and use git-count-objects name).

Oh if so, I'd suggest git-stats over git-count :-)
-- 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add git-count-packs, like git-count-objects.
  2006-11-02  9:30       ` Nguyen Thai Ngoc Duy
@ 2006-11-03 12:53         ` Jakub Narebski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2006-11-03 12:53 UTC (permalink / raw)
  To: git

Nguyen Thai Ngoc Duy wrote:

> On 10/28/06, Jakub Narebski <jnareb@gmail.com> wrote:

>> Perhaps to not to add yet another command to already large set, rename
>> git-count-objects to git-count, and enhance it to count both loose objects
>> and packs (or not, and use git-count-objects as command name).
> 
> Oh if so, I'd suggest git-stats over git-count :-)

Or even git-db-stats (as companion to git-db-init).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-11-03 12:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-28  4:00 [PATCH] Add git-count-packs, like git-count-objects Shawn Pearce
2006-10-28  4:11 ` Junio C Hamano
2006-10-28  6:51   ` Shawn Pearce
2006-10-28 14:28     ` Jakub Narebski
2006-11-02  9:30       ` Nguyen Thai Ngoc Duy
2006-11-03 12:53         ` Jakub Narebski

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).