mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
builtin/repo: add object disk size info to structure table
Similar to a prior commit, update the table output format for the git-repo(1) structure commdn to display the total object disk usage by object type. Since disk size may vary between platforms, tests do not validate actual values and only check that size info is printed in an empty repository. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
3eae248ded
commit
b8cacabfa5
@@ -371,6 +371,7 @@ static void stats_table_setup_structure(struct stats_table *table,
|
|||||||
struct ref_stats *refs = &stats->refs;
|
struct ref_stats *refs = &stats->refs;
|
||||||
size_t inflated_object_total;
|
size_t inflated_object_total;
|
||||||
size_t object_count_total;
|
size_t object_count_total;
|
||||||
|
size_t disk_object_total;
|
||||||
size_t ref_total;
|
size_t ref_total;
|
||||||
|
|
||||||
ref_total = get_total_reference_count(refs);
|
ref_total = get_total_reference_count(refs);
|
||||||
@@ -405,6 +406,18 @@ static void stats_table_setup_structure(struct stats_table *table,
|
|||||||
" * %s", _("Blobs"));
|
" * %s", _("Blobs"));
|
||||||
stats_table_size_addf(table, objects->inflated_sizes.tags,
|
stats_table_size_addf(table, objects->inflated_sizes.tags,
|
||||||
" * %s", _("Tags"));
|
" * %s", _("Tags"));
|
||||||
|
|
||||||
|
disk_object_total = get_total_object_values(&objects->disk_sizes);
|
||||||
|
stats_table_size_addf(table, disk_object_total,
|
||||||
|
" * %s", _("Disk size"));
|
||||||
|
stats_table_size_addf(table, objects->disk_sizes.commits,
|
||||||
|
" * %s", _("Commits"));
|
||||||
|
stats_table_size_addf(table, objects->disk_sizes.trees,
|
||||||
|
" * %s", _("Trees"));
|
||||||
|
stats_table_size_addf(table, objects->disk_sizes.blobs,
|
||||||
|
" * %s", _("Blobs"));
|
||||||
|
stats_table_size_addf(table, objects->disk_sizes.tags,
|
||||||
|
" * %s", _("Tags"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stats_table_print_structure(const struct stats_table *table)
|
static void stats_table_print_structure(const struct stats_table *table)
|
||||||
|
|||||||
@@ -4,6 +4,15 @@ test_description='test git repo structure'
|
|||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
strip_object_disk_usage() {
|
||||||
|
awk '
|
||||||
|
/^\| \* Disk size/ { skip=1; next }
|
||||||
|
skip && /^\| \* / { next }
|
||||||
|
skip && !/^\| \* / { skip=0 }
|
||||||
|
{ print }
|
||||||
|
' $1
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success 'empty repository' '
|
test_expect_success 'empty repository' '
|
||||||
test_when_finished "rm -rf repo" &&
|
test_when_finished "rm -rf repo" &&
|
||||||
git init repo &&
|
git init repo &&
|
||||||
@@ -30,6 +39,11 @@ test_expect_success 'empty repository' '
|
|||||||
| * Trees | 0 B |
|
| * Trees | 0 B |
|
||||||
| * Blobs | 0 B |
|
| * Blobs | 0 B |
|
||||||
| * Tags | 0 B |
|
| * Tags | 0 B |
|
||||||
|
| * Disk size | 0 B |
|
||||||
|
| * Commits | 0 B |
|
||||||
|
| * Trees | 0 B |
|
||||||
|
| * Blobs | 0 B |
|
||||||
|
| * Tags | 0 B |
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
git repo structure >out 2>err &&
|
git repo structure >out 2>err &&
|
||||||
@@ -107,7 +121,10 @@ test_expect_success SHA1 'repository with references and objects' '
|
|||||||
| * Tags | 132 B |
|
| * Tags | 132 B |
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
git repo structure >out 2>err &&
|
git repo structure >out.raw 2>err &&
|
||||||
|
|
||||||
|
# Skip object disk sizes due to platform variance.
|
||||||
|
strip_object_disk_usage out.raw >out &&
|
||||||
|
|
||||||
test_cmp expect out &&
|
test_cmp expect out &&
|
||||||
test_line_count = 0 err
|
test_line_count = 0 err
|
||||||
|
|||||||
Reference in New Issue
Block a user