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 4.1.2.201602141800-r

 * Q: Does it consider only reachable objects?
   A: No. Any git object present in the repository is accounted in the
      final calculation.

 * 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.

Change-Id: Icc5bc6fdf8fa5c4635eabc1cd61870890e5277c9
2 files changed
tree: d109e27d7cacb2d0c535f4fd8ee73ebee7bba03f
  1. .settings/
  2. lib/
  3. src/
  4. .buckconfig
  5. .gitignore
  6. BUCK
  7. LICENSE
  8. pom.xml
  9. VERSION