Skip to content

Commit ca58a36

Browse files
authored
Merge branch 'master' into fix/oniguruma-not-default
2 parents 42b586e + fe8ac2b commit ca58a36

File tree

9 files changed

+154
-57
lines changed

9 files changed

+154
-57
lines changed

commit_trees.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,13 @@ func (i *commitTreesRowIter) Close() error {
330330
i.trees.Close()
331331
}
332332

333+
if i.repo != nil {
334+
i.repo.Close()
335+
}
336+
333337
if i.index != nil {
334338
return i.index.Close()
335339
}
336340

337-
i.repo.Close()
338-
339341
return nil
340342
}

commits.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,7 @@ func (i *commitIter) loadNextRef() (err error) {
229229
return err
230230
}
231231

232-
if i.ref.Type() != plumbing.HashReference {
233-
i.ref = nil
234-
continue
235-
}
236-
237-
obj, err := i.repo.Object(plumbing.AnyObject, i.ref.Hash())
232+
ignored, err := isIgnoredReference(i.repo.Repository, i.ref)
238233
if err != nil {
239234
if i.skipGitErrors {
240235
continue
@@ -243,7 +238,7 @@ func (i *commitIter) loadNextRef() (err error) {
243238
return err
244239
}
245240

246-
if obj.Type() != plumbing.CommitObject {
241+
if ignored {
247242
continue
248243
}
249244

integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ func TestMissingHeadRefs(t *testing.T) {
594594

595595
rows, err := sql.RowIterToRows(iter)
596596
require.NoError(err)
597-
require.Len(rows, 56)
597+
require.Len(rows, 54)
598598
}
599599

600600
func BenchmarkQueries(b *testing.B) {

partition.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,8 @@ func (i *partitionedIndexKeyValueIter) Next() (sql.Partition, sql.IndexKeyValueI
227227
}
228228

229229
func (i *partitionedIndexKeyValueIter) Close() error {
230-
return i.partitions.Close()
230+
if i.partitions != nil {
231+
return i.partitions.Close()
232+
}
233+
return nil
231234
}

ref_commits.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,16 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
306306
return nil, err
307307
}
308308

309-
if ref.Type() != plumbing.HashReference {
309+
ignored, err := isIgnoredReference(i.repo.Repository, ref)
310+
if err != nil {
311+
if i.skipGitErrors {
312+
continue
313+
}
314+
315+
return nil, err
316+
}
317+
318+
if ignored {
310319
continue
311320
}
312321
} else {
@@ -361,12 +370,14 @@ func (i *refCommitsRowIter) Close() error {
361370
i.refs.Close()
362371
}
363372

373+
if i.repo != nil {
374+
i.repo.Close()
375+
}
376+
364377
if i.index != nil {
365378
return i.index.Close()
366379
}
367380

368-
i.repo.Close()
369-
370381
return nil
371382
}
372383

@@ -443,3 +454,9 @@ func (i *indexedCommitIter) Next() (*object.Commit, int, error) {
443454
return c, frame.idx, nil
444455
}
445456
}
457+
458+
func (i *indexedCommitIter) Close() {
459+
if i.repo != nil {
460+
i.repo.Close()
461+
}
462+
}

references.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"io"
77
"strings"
88

9+
git "gopkg.in/src-d/go-git.v4"
910
"gopkg.in/src-d/go-mysql-server.v0/sql"
1011

1112
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -299,7 +300,16 @@ func (i *refRowIter) next() (sql.Row, error) {
299300
return nil, err
300301
}
301302

302-
if o.Type() != plumbing.HashReference {
303+
ignored, err := isIgnoredReference(i.repo.Repository, o)
304+
if err != nil {
305+
if i.skipGitErrors {
306+
continue
307+
}
308+
309+
return nil, err
310+
}
311+
312+
if ignored {
303313
continue
304314
}
305315

@@ -320,12 +330,14 @@ func (i *refRowIter) Close() error {
320330
i.iter.Close()
321331
}
322332

333+
if i.repo != nil {
334+
i.repo.Close()
335+
}
336+
323337
if i.index != nil {
324338
return i.index.Close()
325339
}
326340

327-
i.repo.Close()
328-
329341
return nil
330342
}
331343

@@ -338,3 +350,16 @@ func referenceToRow(repositoryID string, c *plumbing.Reference) sql.Row {
338350
hash,
339351
)
340352
}
353+
354+
func isIgnoredReference(repo *git.Repository, ref *plumbing.Reference) (bool, error) {
355+
if ref.Type() != plumbing.HashReference {
356+
return true, nil
357+
}
358+
359+
obj, err := repo.Object(plumbing.AnyObject, ref.Hash())
360+
if err != nil {
361+
return false, err
362+
}
363+
364+
return obj.Type() != plumbing.CommitObject, nil
365+
}

repositories.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,8 @@ func (i *repositoriesRowIter) Next() (sql.Row, error) {
151151

152152
func (i *repositoriesRowIter) Close() error {
153153
i.visited = true
154+
if i.repo != nil {
155+
i.repo.Close()
156+
}
154157
return nil
155158
}

0 commit comments

Comments
 (0)