Skip to content

Commit 4fd6315

Browse files
authored
Merge pull request #26 from github/less-depth
Don't include the root tree in `MaxPathDepth`
2 parents 58369ef + 1e05b25 commit 4fd6315

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ Is your Git repository bursting at the seams?
6767

6868
## Getting started
6969

70-
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`.
70+
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`.
7171

7272
2. Install `git-sizer`. Either:
7373

7474
a. Install a released version of `git-sizer`(recommended):
75-
1. Go to [the releases page](https://github.com/github/git-sizer/releases) and download the ZIP file corresponding to your platform.
76-
2. Unzip the file.
77-
3. Move the executable file (`git-sizer` or `git-sizer.exe`) into your `PATH`.
78-
75+
1. Go to [the releases page](https://github.com/github/git-sizer/releases) and download the ZIP file corresponding to your platform.
76+
2. Unzip the file.
77+
3. Move the executable file (`git-sizer` or `git-sizer.exe`) into your `PATH`.
78+
7979
b. Build and install from source. See the instructions in [`docs/BUILDING.md`](docs/BUILDING.md).
8080

8181
3. Change to the directory containing the Git repository that you'd like to analyze, then run
@@ -132,15 +132,15 @@ Processing references: 539
132132
| | | |
133133
| Biggest checkouts | | |
134134
| * Number of directories [6] | 4.38 k | ** |
135-
| * Maximum path depth [7] | 14 | * |
135+
| * Maximum path depth [7] | 13 | * |
136136
| * Maximum path length [8] | 134 B | * |
137137
| * Number of files [9] | 62.3 k | * |
138138
| * Total size of files [9] | 747 MiB | |
139139
| * Number of symlinks [10] | 40 | |
140140
| * Number of submodules | 0 | |
141141
142-
[1] 91cc53b0c78596a73fa708cceb7313e7168bb146 (91cc53b0c78596a73fa708cceb7313e7168bb146)
143-
[2] 2cde51fbd0f310c8a2c5f977e665c0ac3945b46d (2cde51fbd0f310c8a2c5f977e665c0ac3945b46d)
142+
[1] 91cc53b0c78596a73fa708cceb7313e7168bb146
143+
[2] 2cde51fbd0f310c8a2c5f977e665c0ac3945b46d
144144
[3] 4f86eed5893207aca2c2da86b35b38f2e1ec1fc8 (refs/heads/master:arch/arm/boot/dts)
145145
[4] a02b6794337286bc12c907c33d5d75537c240bd0 (refs/heads/master:drivers/gpu/drm/amd/include/asic_reg/vega10/NBIO/nbio_6_1_sh_mask.h)
146146
[5] 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c (refs/tags/v2.6.11)

git_sizer_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestBomb(t *testing.T) {
190190

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

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

273273
repo2, err := git.NewRepository(filepath.Join(path, "subdir"))
274274
require.NoError(t, err, "creating Repository object in subdirectory")
275-
_, err = sizes.ScanRepositoryUsingGraph(
275+
h, err := sizes.ScanRepositoryUsingGraph(
276276
repo2, git.AllReferencesFilter, sizes.NameStyleNone, false,
277277
)
278278
require.NoError(t, err, "scanning repository")
279+
assert.Equal(t, counts.Count32(2), h.MaxPathDepth, "max path depth")
279280
}
280281

281282
func TestSubmodule(t *testing.T) {

sizes/graph.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,6 @@ func (r *treeRecord) initialize(g *Graph, oid git.OID, tree *git.Tree) error {
609609

610610
func (r *treeRecord) maybeFinalize(g *Graph) {
611611
if r.pending == 0 {
612-
// Add one for this tree itself:
613-
r.size.MaxPathDepth.Increment(1)
614-
615612
g.finalizeTreeSize(r.oid, r.size, r.objectSize, r.entryCount)
616613
for _, listener := range r.listeners {
617614
listener(r.size)

sizes/sizes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type BlobSize struct {
1717

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

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

4343
func (s *TreeSize) addDescendent(filename string, s2 TreeSize) {
44-
s.MaxPathDepth.AdjustMaxIfNecessary(s2.MaxPathDepth)
44+
s.MaxPathDepth.AdjustMaxIfNecessary(s2.MaxPathDepth.Plus(1))
4545
if s2.MaxPathLength > 0 {
4646
s.MaxPathLength.AdjustMaxIfNecessary(
4747
(counts.NewCount32(uint64(len(filename))) + 1).Plus(s2.MaxPathLength),
@@ -164,7 +164,7 @@ type HistorySize struct {
164164
// attribute is maximized separately).
165165

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

170170
// The tree with the maximum path depth.

0 commit comments

Comments
 (0)