aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/revlist/revlist.go
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2019-02-07 17:01:46 -0800
committerJeremy Stribling <strib@alum.mit.edu>2019-02-11 15:13:11 -0800
commitefe6c8be74a942c902f4812146ff016827ad9626 (patch)
tree36529c5a378bc0385bf665d44e6b1144a2165443 /plumbing/revlist/revlist.go
parentdcc9f375f4daedfef61e7ff2fbbfd851d42a72d8 (diff)
downloadgo-git-efe6c8be74a942c902f4812146ff016827ad9626.tar.gz
revlist: add `ObjectsWithStorageForIgnores` method
`ObjectsWithStorageForIgnores` is the same as `Objects`, but a secondary storage layer can be provided, to be used to finding the full set of objects to be ignored while finding the reachable objects. This is useful when the main `s` storage layer is slow and/or remote, while the ignore list is available somewhere local. Issue: #909 Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
Diffstat (limited to 'plumbing/revlist/revlist.go')
-rw-r--r--plumbing/revlist/revlist.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/plumbing/revlist/revlist.go b/plumbing/revlist/revlist.go
index 0a9d1e8..7ad71ac 100644
--- a/plumbing/revlist/revlist.go
+++ b/plumbing/revlist/revlist.go
@@ -21,7 +21,20 @@ func Objects(
objs,
ignore []plumbing.Hash,
) ([]plumbing.Hash, error) {
- ignore, err := objects(s, ignore, nil, true)
+ return ObjectsWithStorageForIgnores(s, s, objs, ignore)
+}
+
+// ObjectsWithStorageForIgnores is the same as Objects, but a
+// secondary storage layer can be provided, to be used to finding the
+// full set of objects to be ignored while finding the reachable
+// objects. This is useful when the main `s` storage layer is slow
+// and/or remote, while the ignore list is available somewhere local.
+func ObjectsWithStorageForIgnores(
+ s, ignoreStore storer.EncodedObjectStorer,
+ objs,
+ ignore []plumbing.Hash,
+) ([]plumbing.Hash, error) {
+ ignore, err := objects(ignoreStore, ignore, nil, true)
if err != nil {
return nil, err
}
@@ -114,7 +127,6 @@ func reachableObjects(
i := object.NewCommitPreorderIter(commit, seen, ignore)
pending := make(map[plumbing.Hash]bool)
addPendingParents(pending, visited, commit)
-
for {
commit, err := i.Next()
if err == io.EOF {