]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-count-objects.c
Lazily open pack index files on demand
[thirdparty/git.git] / builtin-count-objects.c
index 73c59824238f58c2dc94544ef67ea51741d834ac..ac65e03e7f5203def8c412da95f254973119c14d 100644 (file)
@@ -44,7 +44,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
                        if (lstat(path, &st) || !S_ISREG(st.st_mode))
                                bad = 1;
                        else
-                               (*loose_size) += st.st_blocks;
+                               (*loose_size) += xsize_t(st.st_blocks);
                }
                if (bad) {
                        if (verbose) {
@@ -105,16 +105,21 @@ int cmd_count_objects(int ac, const char **av, const char *prefix)
        }
        if (verbose) {
                struct packed_git *p;
+               unsigned long num_pack = 0;
                if (!packed_git)
                        prepare_packed_git();
                for (p = packed_git; p; p = p->next) {
                        if (!p->pack_local)
                                continue;
-                       packed += num_packed_objects(p);
+                       if (!p->index_data && open_pack_index(p))
+                               continue;
+                       packed += p->num_objects;
+                       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("prune-packable: %lu\n", packed_loose);
                printf("garbage: %lu\n", garbage);
        }