Skip to content

Commit d59a289

Browse files
authored
Merge branch 'master' into feature/skip-non-commit-tags
2 parents b31c52b + c5dfbe8 commit d59a289

File tree

10 files changed

+89
-45
lines changed

10 files changed

+89
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ _cgo_export.*
2020
_testmain.go
2121

2222
main
23+
gitbase
2324
*.exe
2425
*.test
2526
*.prof

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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package gitbase
33
import (
44
"io"
55

6-
git "gopkg.in/src-d/go-git.v4"
76
"gopkg.in/src-d/go-mysql-server.v0/sql"
87

98
"gopkg.in/src-d/go-git.v4/plumbing"
@@ -409,10 +408,7 @@ func newCommitsKeyValueIter(
409408
return nil, err
410409
}
411410

412-
commits, err :=
413-
repo.Log(&git.LogOptions{
414-
All: true,
415-
})
411+
commits, err := newCommitIter(repo, false)
416412
if err != nil {
417413
return nil, err
418414
}

gitbase

-40.5 MB
Binary file not shown.

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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,14 @@ func (i *refCommitsRowIter) Close() error {
370370
i.refs.Close()
371371
}
372372

373+
if i.repo != nil {
374+
i.repo.Close()
375+
}
376+
373377
if i.index != nil {
374378
return i.index.Close()
375379
}
376380

377-
i.repo.Close()
378-
379381
return nil
380382
}
381383

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

references.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,14 @@ func (i *refRowIter) Close() error {
330330
i.iter.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
}
341343

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
}

squash_iterator.go

Lines changed: 59 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ func NewAllReposIter(filters sql.Expression) ReposIter {
5656
}
5757

5858
func (i *squashReposIter) Repo() *Repository { return i.repo }
59-
func (i *squashReposIter) Close() error { return nil }
59+
func (i *squashReposIter) Close() error {
60+
if i.repo != nil {
61+
i.repo.Close()
62+
}
63+
64+
return nil
65+
}
6066
func (i *squashReposIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
6167
session, err := getSession(ctx)
6268
if err != nil {
@@ -140,7 +146,13 @@ func NewAllRemotesIter(filters sql.Expression) RemotesIter {
140146
}
141147

142148
func (i *squashRemoteIter) Remote() *Remote { return i.remote }
143-
func (i *squashRemoteIter) Close() error { return nil }
149+
func (i *squashRemoteIter) Close() error {
150+
if i.repo != nil {
151+
i.repo.Close()
152+
}
153+
154+
return nil
155+
}
144156
func (i *squashRemoteIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
145157
session, err := getSession(ctx)
146158
if err != nil {
@@ -403,6 +415,9 @@ func (i *squashRefIter) Close() error {
403415
if i.refs != nil {
404416
i.refs.Close()
405417
}
418+
if i.repo != nil {
419+
i.repo.Close()
420+
}
406421
return i.repos.Close()
407422
}
408423
func (i *squashRefIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -532,6 +547,10 @@ func NewIndexRefsIter(filters sql.Expression, index sql.IndexLookup) RefsIter {
532547
func (i *squashRefIndexIter) Repository() *Repository { return i.repo }
533548
func (i *squashRefIndexIter) Ref() *Ref { return i.ref }
534549
func (i *squashRefIndexIter) Close() error {
550+
if i.repo != nil {
551+
i.repo.Close()
552+
}
553+
535554
return i.iter.Close()
536555
}
537556
func (i *squashRefIndexIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -792,8 +811,6 @@ func NewRemoteRefsIter(
792811
func (i *squashRemoteRefsIter) Repository() *Repository { return i.remotes.Repository() }
793812
func (i *squashRemoteRefsIter) Ref() *Ref { return i.ref }
794813
func (i *squashRemoteRefsIter) Close() error {
795-
i.Repository().Close()
796-
797814
if i.refs != nil {
798815
i.refs.Close()
799816
}
@@ -952,7 +969,9 @@ func (i *squashRefRefCommitsIter) Close() error {
952969
i.refs.Close()
953970
}
954971

955-
i.Repository().Close()
972+
if i.commits != nil {
973+
i.commits.Close()
974+
}
956975
return nil
957976
}
958977
func (i *squashRefRefCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1225,7 +1244,9 @@ func (i *squashRefCommitsIndexIter) Schema() sql.Schema {
12251244
return RefCommitsSchema
12261245
}
12271246
func (i *squashRefCommitsIndexIter) Close() error {
1228-
i.repo.Close()
1247+
if i.repo != nil {
1248+
i.repo.Close()
1249+
}
12291250
return i.iter.Close()
12301251
}
12311252

@@ -1249,7 +1270,6 @@ func (i *squashRefCommitCommitsIter) Close() error {
12491270
i.refCommits.Close()
12501271
}
12511272

1252-
i.Repository().Close()
12531273
return nil
12541274
}
12551275
func (i *squashRefCommitCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1320,8 +1340,10 @@ func (i *squashCommitsIter) Close() error {
13201340
if i.commits != nil {
13211341
i.commits.Close()
13221342
}
1343+
if i.repo != nil {
1344+
i.repo.Close()
1345+
}
13231346

1324-
i.repo.Close()
13251347
return nil
13261348
}
13271349
func (i *squashCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1495,7 +1517,10 @@ func (i *squashCommitsIndexIter) Schema() sql.Schema {
14951517
return CommitsSchema
14961518
}
14971519
func (i *squashCommitsIndexIter) Close() error {
1498-
i.repo.Close()
1520+
if i.repo != nil {
1521+
i.repo.Close()
1522+
}
1523+
14991524
return i.iter.Close()
15001525
}
15011526

@@ -1522,8 +1547,6 @@ func (i *squashRepoCommitsIter) Close() error {
15221547
i.commits.Close()
15231548
}
15241549

1525-
i.Repository().Close()
1526-
15271550
if i.repos != nil {
15281551
return i.repos.Close()
15291552
}
@@ -1634,8 +1657,6 @@ func NewRefHEADCommitsIter(
16341657
func (i *squashRefHeadCommitsIter) Repository() *Repository { return i.refs.Repository() }
16351658
func (i *squashRefHeadCommitsIter) Commit() *object.Commit { return i.commit }
16361659
func (i *squashRefHeadCommitsIter) Close() error {
1637-
i.Repository().Close()
1638-
16391660
if i.refs != nil {
16401661
return i.refs.Close()
16411662
}
@@ -1828,7 +1849,10 @@ func (i *squashCommitTreesIndexIter) Schema() sql.Schema {
18281849
return CommitTreesSchema
18291850
}
18301851
func (i *squashCommitTreesIndexIter) Close() error {
1831-
i.repo.Close()
1852+
if i.repo != nil {
1853+
i.repo.Close()
1854+
}
1855+
18321856
return i.iter.Close()
18331857
}
18341858

@@ -1860,6 +1884,9 @@ func NewCommitTreesIter(
18601884
func (i *squashCommitTreesIter) Repository() *Repository { return i.commits.Repository() }
18611885
func (i *squashCommitTreesIter) Tree() *object.Tree { return i.tree }
18621886
func (i *squashCommitTreesIter) Close() error {
1887+
if i.trees != nil {
1888+
i.trees.Close()
1889+
}
18631890
if i.commits != nil {
18641891
return i.commits.Close()
18651892
}
@@ -1976,8 +2003,6 @@ func (i *squashRepoTreeEntriesIter) Close() error {
19762003
i.trees.Close()
19772004
}
19782005

1979-
i.Repository().Close()
1980-
19812006
if i.repos != nil {
19822007
return i.repos.Close()
19832008
}
@@ -2106,8 +2131,6 @@ func NewCommitMainTreeIter(
21062131
func (i *squashCommitMainTreeIter) Repository() *Repository { return i.commits.Repository() }
21072132
func (i *squashCommitMainTreeIter) Tree() *object.Tree { return i.tree }
21082133
func (i *squashCommitMainTreeIter) Close() error {
2109-
i.Repository().Close()
2110-
21112134
if i.commits != nil {
21122135
return i.commits.Close()
21132136
}
@@ -2270,6 +2293,12 @@ func (i *commitTreeIter) Next() (*object.Tree, error) {
22702293
}
22712294
}
22722295

2296+
func (i *commitTreeIter) Close() {
2297+
if i.repo != nil {
2298+
i.repo.Close()
2299+
}
2300+
}
2301+
22732302
// TreeEntriesIter is a chainable iterator that operates on Tree Entries.
22742303
type TreeEntriesIter interface {
22752304
ChainableIter
@@ -2300,7 +2329,9 @@ func NewAllTreeEntriesIter(filters sql.Expression) TreeEntriesIter {
23002329
func (i *squashTreeEntriesIter) Repository() *Repository { return i.repo }
23012330
func (i *squashTreeEntriesIter) TreeEntry() *TreeEntry { return i.entry }
23022331
func (i *squashTreeEntriesIter) Close() error {
2303-
i.Repository().Close()
2332+
if i.repo != nil {
2333+
i.repo.Close()
2334+
}
23042335

23052336
if i.trees != nil {
23062337
i.trees.Close()
@@ -2471,7 +2502,9 @@ func (i *squashTreeEntriesIndexIter) Schema() sql.Schema {
24712502
return TreeEntriesSchema
24722503
}
24732504
func (i *squashTreeEntriesIndexIter) Close() error {
2474-
i.Repository().Close()
2505+
if i.repo != nil {
2506+
i.repo.Close()
2507+
}
24752508
return i.iter.Close()
24762509
}
24772510

@@ -2503,8 +2536,6 @@ func NewTreeTreeEntriesIter(
25032536
func (i *squashTreeTreeEntriesIter) Repository() *Repository { return i.trees.Repository() }
25042537
func (i *squashTreeTreeEntriesIter) TreeEntry() *TreeEntry { return i.entry }
25052538
func (i *squashTreeTreeEntriesIter) Close() error {
2506-
i.Repository().Close()
2507-
25082539
if i.trees != nil {
25092540
return i.trees.Close()
25102541
}
@@ -2674,7 +2705,9 @@ func (i *squashCommitBlobsIndexIter) Schema() sql.Schema {
26742705
return CommitBlobsSchema
26752706
}
26762707
func (i *squashCommitBlobsIndexIter) Close() error {
2677-
i.Repository().Close()
2708+
if i.repo != nil {
2709+
i.repo.Close()
2710+
}
26782711
return i.iter.Close()
26792712
}
26802713

@@ -2712,8 +2745,6 @@ func (i *squashCommitBlobsIter) Close() error {
27122745
i.files.Close()
27132746
}
27142747

2715-
i.Repository().Close()
2716-
27172748
if i.commits != nil {
27182749
return i.commits.Close()
27192750
}
@@ -2844,8 +2875,6 @@ func (i *squashRepoBlobsIter) Close() error {
28442875
i.blobs.Close()
28452876
}
28462877

2847-
i.Repository().Close()
2848-
28492878
if i.repos != nil {
28502879
return i.repos.Close()
28512880
}
@@ -3230,7 +3259,6 @@ func (i *squashCommitFilesIter) Close() error {
32303259
i.files.Close()
32313260
}
32323261

3233-
i.Repository().Close()
32343262
return i.commits.Close()
32353263
}
32363264
func (i *squashCommitFilesIter) Schema() sql.Schema {
@@ -3338,7 +3366,9 @@ func (i *squashIndexCommitFilesIter) Row() sql.Row { return i.row }
33383366
func (i *squashIndexCommitFilesIter) Schema() sql.Schema { return CommitFilesSchema }
33393367

33403368
func (i *squashIndexCommitFilesIter) Close() error {
3341-
i.repo.Close()
3369+
if i.repo != nil {
3370+
i.repo.Close()
3371+
}
33423372
return i.iter.Close()
33433373
}
33443374

@@ -3414,7 +3444,6 @@ func (i *squashCommitFileFilesIter) Schema() sql.Schema {
34143444
return append(i.files.Schema(), FilesSchema...)
34153445
}
34163446
func (i *squashCommitFileFilesIter) Close() error {
3417-
i.Repository().Close()
34183447
return i.files.Close()
34193448
}
34203449

tree_entries.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ func (i *treeEntriesRowIter) Close() error {
239239
if i.iter != nil {
240240
i.iter.Close()
241241
}
242-
243-
i.repo.Close()
244-
242+
if i.repo != nil {
243+
i.repo.Close()
244+
}
245245
return nil
246246
}
247247

0 commit comments

Comments
 (0)