Skip to content

Commit 72c0c53

Browse files
committed
In --auto-exclude mode, only look for each commit at most once.
Once we auto-exclude it, add it to the excludes list so we can abort quickly in future runs.
1 parent aaf3328 commit 72c0c53

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

subtrac.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewCache(rdir string, r *git.Repository, excludes []string,
6060
}
6161
for _, x := range excludes {
6262
hash := plumbing.NewHash(x)
63-
c.excludes[hash] = true
63+
c.exclude(hash)
6464
}
6565
return &c
6666
}
@@ -82,6 +82,13 @@ func (c *Cache) String() string {
8282
return strings.Join(out, "\n")
8383
}
8484

85+
func (c *Cache) exclude(hash plumbing.Hash) {
86+
if !c.excludes[hash] {
87+
c.excludes[hash] = true
88+
c.infof("Excluding %v\n", hash)
89+
}
90+
}
91+
8592
func (c *Cache) UpdateBranchRefs() error {
8693
branchIter, err := c.repo.Branches()
8794
if err != nil {
@@ -376,9 +383,10 @@ func (c *Cache) tracTree(path string, tree *object.Tree) (*Trac, error) {
376383
err = c.tryFetchFromSubmodules(subpath, e.Hash)
377384
if err != nil {
378385
if c.autoexclude {
386+
c.exclude(e.Hash)
379387
continue
380388
}
381-
return nil, fmt.Errorf("%v (maybe fetch it manually?)", err)
389+
return nil, fmt.Errorf("%v (fetch it manually? or try --exclude)", err)
382390
}
383391
}
384392
sc, err = c.repo.CommitObject(e.Hash)

0 commit comments

Comments
 (0)