#include "builtin.h"
#include "environment.h"
+#include "hex.h"
+#include "odb.h"
#include "parse-options.h"
#include "path-walk.h"
#include "progress.h"
struct object_stats {
struct object_values type_counts;
+ struct object_values inflated_sizes;
};
struct repo_structure {
printf("objects.tags.count%c%" PRIuMAX "%c", key_delim,
(uintmax_t)stats->objects.type_counts.tags, value_delim);
+ printf("objects.commits.inflated_size%c%" PRIuMAX "%c", key_delim,
+ (uintmax_t)stats->objects.inflated_sizes.commits, value_delim);
+ printf("objects.trees.inflated_size%c%" PRIuMAX "%c", key_delim,
+ (uintmax_t)stats->objects.inflated_sizes.trees, value_delim);
+ printf("objects.blobs.inflated_size%c%" PRIuMAX "%c", key_delim,
+ (uintmax_t)stats->objects.inflated_sizes.blobs, value_delim);
+ printf("objects.tags.inflated_size%c%" PRIuMAX "%c", key_delim,
+ (uintmax_t)stats->objects.inflated_sizes.tags, value_delim);
+
fflush(stdout);
}
}
struct count_objects_data {
+ struct object_database *odb;
struct object_stats *stats;
struct progress *progress;
};
{
struct count_objects_data *data = cb_data;
struct object_stats *stats = data->stats;
+ size_t inflated_total = 0;
size_t object_count;
+ for (size_t i = 0; i < oids->nr; i++) {
+ struct object_info oi = OBJECT_INFO_INIT;
+ unsigned long inflated;
+
+ oi.sizep = &inflated;
+
+ if (odb_read_object_info_extended(data->odb, &oids->oid[i], &oi,
+ OBJECT_INFO_SKIP_FETCH_OBJECT |
+ OBJECT_INFO_QUICK) < 0)
+ continue;
+
+ inflated_total += inflated;
+ }
+
switch (type) {
case OBJ_TAG:
stats->type_counts.tags += oids->nr;
+ stats->inflated_sizes.tags += inflated_total;
break;
case OBJ_COMMIT:
stats->type_counts.commits += oids->nr;
+ stats->inflated_sizes.commits += inflated_total;
break;
case OBJ_TREE:
stats->type_counts.trees += oids->nr;
+ stats->inflated_sizes.trees += inflated_total;
break;
case OBJ_BLOB:
stats->type_counts.blobs += oids->nr;
+ stats->inflated_sizes.blobs += inflated_total;
break;
default:
BUG("invalid object type");
{
struct path_walk_info info = PATH_WALK_INFO_INIT;
struct count_objects_data data = {
+ .odb = repo->objects,
.stats = stats,
};