aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMiguel Molina <miguel@erizocosmi.co>2017-09-08 11:09:41 +0200
committerMiguel Molina <miguel@erizocosmi.co>2017-09-08 11:09:41 +0200
commit0debae11c26dca0e50a56f2b9a3b5e8cca99faac (patch)
treef5c4d095cf6708a838e371988415c15c913ae184 /plumbing
parente34443b595ec386081981a39ed2064e9d5f272b5 (diff)
downloadgo-git-0debae11c26dca0e50a56f2b9a3b5e8cca99faac.tar.gz
revert: revlist: do not revisit already visited ancestors
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/revlist/revlist.go20
1 files changed, 3 insertions, 17 deletions
diff --git a/plumbing/revlist/revlist.go b/plumbing/revlist/revlist.go
index 3071584..10a5813 100644
--- a/plumbing/revlist/revlist.go
+++ b/plumbing/revlist/revlist.go
@@ -37,7 +37,6 @@ func objects(
) ([]plumbing.Hash, error) {
seen := hashListToSet(ignore)
result := make(map[plumbing.Hash]bool)
- visited := make(map[plumbing.Hash]bool)
walkerFunc := func(h plumbing.Hash) {
if !seen[h] {
@@ -47,7 +46,7 @@ func objects(
}
for _, h := range objects {
- if err := processObject(s, h, seen, visited, ignore, walkerFunc); err != nil {
+ if err := processObject(s, h, seen, ignore, walkerFunc); err != nil {
if allowMissingObjects && err == plumbing.ErrObjectNotFound {
continue
}
@@ -64,7 +63,6 @@ func processObject(
s storer.EncodedObjectStorer,
h plumbing.Hash,
seen map[plumbing.Hash]bool,
- visited map[plumbing.Hash]bool,
ignore []plumbing.Hash,
walkerFunc func(h plumbing.Hash),
) error {
@@ -84,12 +82,12 @@ func processObject(
switch do := do.(type) {
case *object.Commit:
- return reachableObjects(do, seen, visited, ignore, walkerFunc)
+ return reachableObjects(do, seen, ignore, walkerFunc)
case *object.Tree:
return iterateCommitTrees(seen, do, walkerFunc)
case *object.Tag:
walkerFunc(do.Hash)
- return processObject(s, do.Target, seen, visited, ignore, walkerFunc)
+ return processObject(s, do.Target, seen, ignore, walkerFunc)
case *object.Blob:
walkerFunc(do.Hash)
default:
@@ -104,14 +102,9 @@ func processObject(
// objects from the specified commit. To avoid to iterate over seen commits,
// if a commit hash is into the 'seen' set, we will not iterate all his trees
// and blobs objects.
-// We assume all commits have the same parents, unless a commit has no parents.
-// So when we've visited a commit before, we can stop iterating commits, as we've
-// already processed all its ancestors before as well. `visited` keeps track of
-// all the commits that have been visited that had parents.
func reachableObjects(
commit *object.Commit,
seen map[plumbing.Hash]bool,
- visited map[plumbing.Hash]bool,
ignore []plumbing.Hash,
cb func(h plumbing.Hash),
) error {
@@ -126,18 +119,11 @@ func reachableObjects(
return err
}
- if visited[commit.Hash] {
- break
- }
-
if seen[commit.Hash] {
continue
}
cb(commit.Hash)
- if commit.NumParents() > 0 {
- visited[commit.Hash] = true
- }
tree, err := commit.Tree()
if err != nil {