git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] count-objects: Add total pack size to verbose output

From
Marcus Griep <marcus@griep.us>
Date
Aug 13, 2008, 20:05 UTC
Message-ID
<1218657910-22096-1-git-send-email-marcus@griep.us>

Adds the total pack size (including indexes) the verbose count-objects output, floored to the nearest kilobyte.

Signed-off-by: Marcus Griep <marcus@griep.us>
---
 I used the pack size including the size of the associated indexes in
 computing total pack size since it more closely represents the disk
 usage of each pack. If separate reporting is preferred, they can be
 split apart.
 builtin-count-objects.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/builtin-count-objects.c b/builtin-count-objects.c
index 91b5487..249040b 100644
--- a/builtin-count-objects.c
+++ b/builtin-count-objects.c
@@ -104,6 +104,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
 	if (verbose) {
 		struct packed_git *p;
 		unsigned long num_pack = 0;
+		unsigned long size_pack = 0;
 		if (!packed_git)
 			prepare_packed_git();
 		for (p = packed_git; p; p = p->next) {
@@ -112,12 +113,14 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
 			if (open_pack_index(p))
 				continue;
 			packed += p->num_objects;
+			size_pack += p->pack_size + p->index_size;
 			num_pack++;
 		}
 		printf("count: %lu\n", loose);
 		printf("size: %lu\n", loose_size / 2);
 		printf("in-pack: %lu\n", packed);
 		printf("packs: %lu\n", num_pack);
+		printf("size-pack: %lu\n", size_pack / 1024);
 		printf("prune-packable: %lu\n", packed_loose);
 		printf("garbage: %lu\n", garbage);
 	}
-- 
1.6.0.rc2.6.g8eda3
Next: Marcus Griep
Message 1 of 18 in “count-objects: Add total pack size to verbose output”
  1. count-objects: Add total pack size to verbose outputMarcus Griep, Aug 13, 2008
  2. count-objects: add human-readable size optionMarcus Griep, Aug 14, 2008
  3. Shawn O. PearceAug 14, 2008
  4. Marcus GriepAug 14, 2008
  5. Junio C HamanoAug 14, 2008
  6. Johannes SchindelinAug 14, 2008
  7. Marcus GriepAug 14, 2008
  8. Alex RiesenAug 14, 2008
  9. Marcus GriepAug 14, 2008
  10. Alex RiesenAug 14, 2008
  11. Pierre HabouzitAug 15, 2008
  12. Alex RiesenAug 18, 2008
  13. Johannes SixtAug 14, 2008
  14. Marcus GriepAug 14, 2008
  15. Petr BaudisAug 14, 2008
  16. Marcus GriepAug 14, 2008
  17. Petr BaudisAug 14, 2008
  18. Marcus GriepAug 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.