Skip to content

Commit

Permalink
Merge pull request #26 from github/less-depth
Browse files Browse the repository at this point in the history
Don't include the root tree in `MaxPathDepth`
  • Loading branch information
mhagger authored Mar 11, 2018
2 parents 58369ef + 1e05b25 commit 4fd6315
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ Is your Git repository bursting at the seams?

## Getting started

1. Make sure that you have the [Git command-line client](https://git-scm.com/) installed, **version >= 2.6**. NOTE: `git-sizer` invokes `git` commands to examine the contents of your repository, so **it is required that the `git` command be in your `PATH`** when you run `git-sizer`.
1. Make sure that you have the [Git command-line client](https://git-scm.com/) installed, **version >= 2.6**. NOTE: `git-sizer` invokes `git` commands to examine the contents of your repository, so **it is required that the `git` command be in your `PATH`** when you run `git-sizer`.

2. Install `git-sizer`. Either:

a. Install a released version of `git-sizer`(recommended):
1. Go to [the releases page](https://github.com/github/git-sizer/releases) and download the ZIP file corresponding to your platform.
2. Unzip the file.
3. Move the executable file (`git-sizer` or `git-sizer.exe`) into your `PATH`.
1. Go to [the releases page](https://github.com/github/git-sizer/releases) and download the ZIP file corresponding to your platform.
2. Unzip the file.
3. Move the executable file (`git-sizer` or `git-sizer.exe`) into your `PATH`.

b. Build and install from source. See the instructions in [`docs/BUILDING.md`](docs/BUILDING.md).

3. Change to the directory containing the Git repository that you'd like to analyze, then run
Expand Down Expand Up @@ -132,15 +132,15 @@ Processing references: 539
| | | |
| Biggest checkouts | | |
| * Number of directories [6] | 4.38 k | ** |
| * Maximum path depth [7] | 14 | * |
| * Maximum path depth [7] | 13 | * |
| * Maximum path length [8] | 134 B | * |
| * Number of files [9] | 62.3 k | * |
| * Total size of files [9] | 747 MiB | |
| * Number of symlinks [10] | 40 | |
| * Number of submodules | 0 | |
[1] 91cc53b0c78596a73fa708cceb7313e7168bb146 (91cc53b0c78596a73fa708cceb7313e7168bb146)
[2] 2cde51fbd0f310c8a2c5f977e665c0ac3945b46d (2cde51fbd0f310c8a2c5f977e665c0ac3945b46d)
[1] 91cc53b0c78596a73fa708cceb7313e7168bb146
[2] 2cde51fbd0f310c8a2c5f977e665c0ac3945b46d
[3] 4f86eed5893207aca2c2da86b35b38f2e1ec1fc8 (refs/heads/master:arch/arm/boot/dts)
[4] a02b6794337286bc12c907c33d5d75537c240bd0 (refs/heads/master:drivers/gpu/drm/amd/include/asic_reg/vega10/NBIO/nbio_6_1_sh_mask.h)
[5] 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c (refs/tags/v2.6.11)
Expand Down
5 changes: 3 additions & 2 deletions git_sizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func TestBomb(t *testing.T) {

assert.Equal(counts.Count32(1), h.ReferenceCount, "reference count")

assert.Equal(counts.Count32(11), h.MaxPathDepth, "max path depth")
assert.Equal(counts.Count32(10), h.MaxPathDepth, "max path depth")
assert.Equal("refs/heads/master^{tree}", h.MaxPathDepthTree.Path(), "max path depth tree")
assert.Equal(counts.Count32(29), h.MaxPathLength, "max path length")
assert.Equal("refs/heads/master^{tree}", h.MaxPathLengthTree.Path(), "max path length tree")
Expand Down Expand Up @@ -272,10 +272,11 @@ func TestFromSubdir(t *testing.T) {

repo2, err := git.NewRepository(filepath.Join(path, "subdir"))
require.NoError(t, err, "creating Repository object in subdirectory")
_, err = sizes.ScanRepositoryUsingGraph(
h, err := sizes.ScanRepositoryUsingGraph(
repo2, git.AllReferencesFilter, sizes.NameStyleNone, false,
)
require.NoError(t, err, "scanning repository")
assert.Equal(t, counts.Count32(2), h.MaxPathDepth, "max path depth")
}

func TestSubmodule(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions sizes/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,6 @@ func (r *treeRecord) initialize(g *Graph, oid git.OID, tree *git.Tree) error {

func (r *treeRecord) maybeFinalize(g *Graph) {
if r.pending == 0 {
// Add one for this tree itself:
r.size.MaxPathDepth.Increment(1)

g.finalizeTreeSize(r.oid, r.size, r.objectSize, r.entryCount)
for _, listener := range r.listeners {
listener(r.size)
Expand Down
6 changes: 3 additions & 3 deletions sizes/sizes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BlobSize struct {

type TreeSize struct {
// The maximum depth of trees and blobs starting at this object
// (including this object).
// (not including this object).
MaxPathDepth counts.Count32 `json:"max_path_depth"`

// The maximum length of any path relative to this object, in
Expand All @@ -41,7 +41,7 @@ type TreeSize struct {
}

func (s *TreeSize) addDescendent(filename string, s2 TreeSize) {
s.MaxPathDepth.AdjustMaxIfNecessary(s2.MaxPathDepth)
s.MaxPathDepth.AdjustMaxIfNecessary(s2.MaxPathDepth.Plus(1))
if s2.MaxPathLength > 0 {
s.MaxPathLength.AdjustMaxIfNecessary(
(counts.NewCount32(uint64(len(filename))) + 1).Plus(s2.MaxPathLength),
Expand Down Expand Up @@ -164,7 +164,7 @@ type HistorySize struct {
// attribute is maximized separately).

// The maximum depth of trees and blobs starting at this object
// (including this object).
// (not including this object).
MaxPathDepth counts.Count32 `json:"max_path_depth"`

// The tree with the maximum path depth.
Expand Down

0 comments on commit 4fd6315

Please sign in to comment.