@@ -37,7 +37,6 @@ func objects(
3737) ([]plumbing.Hash , error ) {
3838 seen := hashListToSet (ignore )
3939 result := make (map [plumbing.Hash ]bool )
40- visited := make (map [plumbing.Hash ]bool )
4140
4241 walkerFunc := func (h plumbing.Hash ) {
4342 if ! seen [h ] {
@@ -47,7 +46,7 @@ func objects(
4746 }
4847
4948 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 {
5150 if allowMissingObjects && err == plumbing .ErrObjectNotFound {
5251 continue
5352 }
@@ -64,7 +63,6 @@ func processObject(
6463 s storer.EncodedObjectStorer ,
6564 h plumbing.Hash ,
6665 seen map [plumbing.Hash ]bool ,
67- visited map [plumbing.Hash ]bool ,
6866 ignore []plumbing.Hash ,
6967 walkerFunc func (h plumbing.Hash ),
7068) error {
@@ -84,12 +82,12 @@ func processObject(
8482
8583 switch do := do .(type ) {
8684 case * object.Commit :
87- return reachableObjects (do , seen , visited , ignore , walkerFunc )
85+ return reachableObjects (do , seen , ignore , walkerFunc )
8886 case * object.Tree :
8987 return iterateCommitTrees (seen , do , walkerFunc )
9088 case * object.Tag :
9189 walkerFunc (do .Hash )
92- return processObject (s , do .Target , seen , visited , ignore , walkerFunc )
90+ return processObject (s , do .Target , seen , ignore , walkerFunc )
9391 case * object.Blob :
9492 walkerFunc (do .Hash )
9593 default :
@@ -104,14 +102,9 @@ func processObject(
104102// objects from the specified commit. To avoid to iterate over seen commits,
105103// if a commit hash is into the 'seen' set, we will not iterate all his trees
106104// 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.
111105func reachableObjects (
112106 commit * object.Commit ,
113107 seen map [plumbing.Hash ]bool ,
114- visited map [plumbing.Hash ]bool ,
115108 ignore []plumbing.Hash ,
116109 cb func (h plumbing.Hash ),
117110) error {
@@ -126,18 +119,11 @@ func reachableObjects(
126119 return err
127120 }
128121
129- if visited [commit .Hash ] {
130- break
131- }
132-
133122 if seen [commit .Hash ] {
134123 continue
135124 }
136125
137126 cb (commit .Hash )
138- if commit .NumParents () > 0 {
139- visited [commit .Hash ] = true
140- }
141127
142128 tree , err := commit .Tree ()
143129 if err != nil {
0 commit comments