@@ -37,7 +37,6 @@ func objects(
37
37
) ([]plumbing.Hash , error ) {
38
38
seen := hashListToSet (ignore )
39
39
result := make (map [plumbing.Hash ]bool )
40
- visited := make (map [plumbing.Hash ]bool )
41
40
42
41
walkerFunc := func (h plumbing.Hash ) {
43
42
if ! seen [h ] {
@@ -47,7 +46,7 @@ func objects(
47
46
}
48
47
49
48
for _ , h := range objects {
50
- if err := processObject (s , h , seen , visited , ignore , walkerFunc ); err != nil {
49
+ if err := processObject (s , h , seen , ignore , walkerFunc ); err != nil {
51
50
if allowMissingObjects && err == plumbing .ErrObjectNotFound {
52
51
continue
53
52
}
@@ -64,7 +63,6 @@ func processObject(
64
63
s storer.EncodedObjectStorer ,
65
64
h plumbing.Hash ,
66
65
seen map [plumbing.Hash ]bool ,
67
- visited map [plumbing.Hash ]bool ,
68
66
ignore []plumbing.Hash ,
69
67
walkerFunc func (h plumbing.Hash ),
70
68
) error {
@@ -84,12 +82,12 @@ func processObject(
84
82
85
83
switch do := do .(type ) {
86
84
case * object.Commit :
87
- return reachableObjects (do , seen , visited , ignore , walkerFunc )
85
+ return reachableObjects (do , seen , ignore , walkerFunc )
88
86
case * object.Tree :
89
87
return iterateCommitTrees (seen , do , walkerFunc )
90
88
case * object.Tag :
91
89
walkerFunc (do .Hash )
92
- return processObject (s , do .Target , seen , visited , ignore , walkerFunc )
90
+ return processObject (s , do .Target , seen , ignore , walkerFunc )
93
91
case * object.Blob :
94
92
walkerFunc (do .Hash )
95
93
default :
@@ -104,14 +102,9 @@ func processObject(
104
102
// objects from the specified commit. To avoid to iterate over seen commits,
105
103
// if a commit hash is into the 'seen' set, we will not iterate all his trees
106
104
// and blobs objects.
107
- // We assume all commits have the same parents, unless a commit has no parents.
108
- // So when we've visited a commit before, we can stop iterating commits, as we've
109
- // already processed all its ancestors before as well. `visited` keeps track of
110
- // all the commits that have been visited that had parents.
111
105
func reachableObjects (
112
106
commit * object.Commit ,
113
107
seen map [plumbing.Hash ]bool ,
114
- visited map [plumbing.Hash ]bool ,
115
108
ignore []plumbing.Hash ,
116
109
cb func (h plumbing.Hash ),
117
110
) error {
@@ -126,18 +119,11 @@ func reachableObjects(
126
119
return err
127
120
}
128
121
129
- if visited [commit .Hash ] {
130
- break
131
- }
132
-
133
122
if seen [commit .Hash ] {
134
123
continue
135
124
}
136
125
137
126
cb (commit .Hash )
138
- if commit .NumParents () > 0 {
139
- visited [commit .Hash ] = true
140
- }
141
127
142
128
tree , err := commit .Tree ()
143
129
if err != nil {
0 commit comments