Calculate repository disk usage by adding size of git objects
Originally, the size of a repository is computed by adding up the size
of the files on disk. This calculation can be larger than the size of
the objects in the repository in some cases, like for example:
* Repository folders are mounted on NFS volumes so that files in .nfs
folders are added in quota.
* Size of bitmap files generated by GC are added in quota.
* Garbage files in the repository are added in quota.
This change adds the option of calculating the size of a repository by
adding the size of the git objects in the repository. Even if this
calculation have some limitations (see below), it can give a more
accurate approximation in the cases mentioned before.
This option is also useful to avoid blocking access to a dirty
repository, e.g., when GC does not run in time.
---Limitations & Q&A---
Tested with JGit version 188.8.131.52602141800-r
* Q: Does it consider only reachable objects?
A: No. Any git object present in the repository is accounted in the
* Q: If an object is present in more than one pack file, is its size
computed only once?
A: No. Given JGit calculates the size of the packed objects as the
size of the pack files, if an object is present in two different
packs it will be counted twice.
* Q: If an object is present in a pack file and also as a loose object,
is its size computed only once?
A: No. JGit calculates the size of packed objects as the size of pack
files and the size of loose objects as the sum of the sizes of all
files present in the 'objects' directory excluding 'pack' and
'info' folders. So, if an object is present in a pack file and also
as a loose object it will be counted twice.
2 files changed