aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJustin Tobler <jltobler@gmail.com>2025-10-21 13:25:59 -0500
committerJunio C Hamano <gitster@pobox.com>2025-10-21 14:40:38 -0700
commiteb5cf58ffcd4bb117c870d448b0df0193df52c82 (patch)
treeec796697f7aac4082004cf53000cdaa500aeca36 /t
parentbbb2b9334856ae0a2b18e65e5924a42c31a83c6b (diff)
downloadgit-eb5cf58ffcd4bb117c870d448b0df0193df52c82.tar.xz
builtin/repo: add object counts in structure output
The amount of objects in a repository can provide insight regarding its shape. To surface this information, use the path-walk API to count the number of reachable objects in the repository by object type. All regular references are used to determine the reachable set of objects. The object counts are appended to the same table containing the reference information. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t1901-repo-structure.sh19
1 files changed, 17 insertions, 2 deletions
diff --git a/t/t1901-repo-structure.sh b/t/t1901-repo-structure.sh
index e592eea0eb..c32cf4e239 100755
--- a/t/t1901-repo-structure.sh
+++ b/t/t1901-repo-structure.sh
@@ -18,6 +18,13 @@ test_expect_success 'empty repository' '
| * Tags | 0 |
| * Remotes | 0 |
| * Others | 0 |
+ | | |
+ | * Reachable objects | |
+ | * Count | 0 |
+ | * Commits | 0 |
+ | * Trees | 0 |
+ | * Blobs | 0 |
+ | * Tags | 0 |
EOF
git repo structure >out 2>err &&
@@ -27,17 +34,18 @@ test_expect_success 'empty repository' '
)
'
-test_expect_success 'repository with references' '
+test_expect_success 'repository with references and objects' '
test_when_finished "rm -rf repo" &&
git init repo &&
(
cd repo &&
- git commit --allow-empty -m init &&
+ test_commit_bulk 42 &&
git tag -a foo -m bar &&
oid="$(git rev-parse HEAD)" &&
git update-ref refs/remotes/origin/foo "$oid" &&
+ # Also creates a commit, tree, and blob.
git notes add -m foo &&
cat >expect <<-\EOF &&
@@ -49,6 +57,13 @@ test_expect_success 'repository with references' '
| * Tags | 1 |
| * Remotes | 1 |
| * Others | 1 |
+ | | |
+ | * Reachable objects | |
+ | * Count | 130 |
+ | * Commits | 43 |
+ | * Trees | 43 |
+ | * Blobs | 43 |
+ | * Tags | 1 |
EOF
git repo structure >out 2>err &&