Skip to content

Commit 7992eb7

Browse files
authored
Merge branch 'master' into gopkg
2 parents 3ccd45d + c5dfbe8 commit 7992eb7

File tree

7 files changed

+87
-40
lines changed

7 files changed

+87
-40
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
}

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
@@ -361,12 +361,14 @@ func (i *refCommitsRowIter) Close() error {
361361
i.refs.Close()
362362
}
363363

364+
if i.repo != nil {
365+
i.repo.Close()
366+
}
367+
364368
if i.index != nil {
365369
return i.index.Close()
366370
}
367371

368-
i.repo.Close()
369-
370372
return nil
371373
}
372374

@@ -443,3 +445,9 @@ func (i *indexedCommitIter) Next() (*object.Commit, int, error) {
443445
return c, frame.idx, nil
444446
}
445447
}
448+
449+
func (i *indexedCommitIter) Close() {
450+
if i.repo != nil {
451+
i.repo.Close()
452+
}
453+
}

references.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,14 @@ func (i *refRowIter) Close() error {
320320
i.iter.Close()
321321
}
322322

323+
if i.repo != nil {
324+
i.repo.Close()
325+
}
326+
323327
if i.index != nil {
324328
return i.index.Close()
325329
}
326330

327-
i.repo.Close()
328-
329331
return nil
330332
}
331333

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) {
@@ -523,6 +538,10 @@ func NewIndexRefsIter(filters sql.Expression, index sql.IndexLookup) RefsIter {
523538
func (i *squashRefIndexIter) Repository() *Repository { return i.repo }
524539
func (i *squashRefIndexIter) Ref() *Ref { return i.ref }
525540
func (i *squashRefIndexIter) Close() error {
541+
if i.repo != nil {
542+
i.repo.Close()
543+
}
544+
526545
return i.iter.Close()
527546
}
528547
func (i *squashRefIndexIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -778,8 +797,6 @@ func NewRemoteRefsIter(
778797
func (i *squashRemoteRefsIter) Repository() *Repository { return i.remotes.Repository() }
779798
func (i *squashRemoteRefsIter) Ref() *Ref { return i.ref }
780799
func (i *squashRemoteRefsIter) Close() error {
781-
i.Repository().Close()
782-
783800
if i.refs != nil {
784801
i.refs.Close()
785802
}
@@ -929,7 +946,9 @@ func (i *squashRefRefCommitsIter) Close() error {
929946
i.refs.Close()
930947
}
931948

932-
i.Repository().Close()
949+
if i.commits != nil {
950+
i.commits.Close()
951+
}
933952
return nil
934953
}
935954
func (i *squashRefRefCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1202,7 +1221,9 @@ func (i *squashRefCommitsIndexIter) Schema() sql.Schema {
12021221
return RefCommitsSchema
12031222
}
12041223
func (i *squashRefCommitsIndexIter) Close() error {
1205-
i.repo.Close()
1224+
if i.repo != nil {
1225+
i.repo.Close()
1226+
}
12061227
return i.iter.Close()
12071228
}
12081229

@@ -1226,7 +1247,6 @@ func (i *squashRefCommitCommitsIter) Close() error {
12261247
i.refCommits.Close()
12271248
}
12281249

1229-
i.Repository().Close()
12301250
return nil
12311251
}
12321252
func (i *squashRefCommitCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1297,8 +1317,10 @@ func (i *squashCommitsIter) Close() error {
12971317
if i.commits != nil {
12981318
i.commits.Close()
12991319
}
1320+
if i.repo != nil {
1321+
i.repo.Close()
1322+
}
13001323

1301-
i.repo.Close()
13021324
return nil
13031325
}
13041326
func (i *squashCommitsIter) New(ctx *sql.Context, repo *Repository) (ChainableIter, error) {
@@ -1472,7 +1494,10 @@ func (i *squashCommitsIndexIter) Schema() sql.Schema {
14721494
return CommitsSchema
14731495
}
14741496
func (i *squashCommitsIndexIter) Close() error {
1475-
i.repo.Close()
1497+
if i.repo != nil {
1498+
i.repo.Close()
1499+
}
1500+
14761501
return i.iter.Close()
14771502
}
14781503

@@ -1499,8 +1524,6 @@ func (i *squashRepoCommitsIter) Close() error {
14991524
i.commits.Close()
15001525
}
15011526

1502-
i.Repository().Close()
1503-
15041527
if i.repos != nil {
15051528
return i.repos.Close()
15061529
}
@@ -1611,8 +1634,6 @@ func NewRefHEADCommitsIter(
16111634
func (i *squashRefHeadCommitsIter) Repository() *Repository { return i.refs.Repository() }
16121635
func (i *squashRefHeadCommitsIter) Commit() *object.Commit { return i.commit }
16131636
func (i *squashRefHeadCommitsIter) Close() error {
1614-
i.Repository().Close()
1615-
16161637
if i.refs != nil {
16171638
return i.refs.Close()
16181639
}
@@ -1805,7 +1826,10 @@ func (i *squashCommitTreesIndexIter) Schema() sql.Schema {
18051826
return CommitTreesSchema
18061827
}
18071828
func (i *squashCommitTreesIndexIter) Close() error {
1808-
i.repo.Close()
1829+
if i.repo != nil {
1830+
i.repo.Close()
1831+
}
1832+
18091833
return i.iter.Close()
18101834
}
18111835

@@ -1837,6 +1861,9 @@ func NewCommitTreesIter(
18371861
func (i *squashCommitTreesIter) Repository() *Repository { return i.commits.Repository() }
18381862
func (i *squashCommitTreesIter) Tree() *object.Tree { return i.tree }
18391863
func (i *squashCommitTreesIter) Close() error {
1864+
if i.trees != nil {
1865+
i.trees.Close()
1866+
}
18401867
if i.commits != nil {
18411868
return i.commits.Close()
18421869
}
@@ -1953,8 +1980,6 @@ func (i *squashRepoTreeEntriesIter) Close() error {
19531980
i.trees.Close()
19541981
}
19551982

1956-
i.Repository().Close()
1957-
19581983
if i.repos != nil {
19591984
return i.repos.Close()
19601985
}
@@ -2083,8 +2108,6 @@ func NewCommitMainTreeIter(
20832108
func (i *squashCommitMainTreeIter) Repository() *Repository { return i.commits.Repository() }
20842109
func (i *squashCommitMainTreeIter) Tree() *object.Tree { return i.tree }
20852110
func (i *squashCommitMainTreeIter) Close() error {
2086-
i.Repository().Close()
2087-
20882111
if i.commits != nil {
20892112
return i.commits.Close()
20902113
}
@@ -2247,6 +2270,12 @@ func (i *commitTreeIter) Next() (*object.Tree, error) {
22472270
}
22482271
}
22492272

2273+
func (i *commitTreeIter) Close() {
2274+
if i.repo != nil {
2275+
i.repo.Close()
2276+
}
2277+
}
2278+
22502279
// TreeEntriesIter is a chainable iterator that operates on Tree Entries.
22512280
type TreeEntriesIter interface {
22522281
ChainableIter
@@ -2277,7 +2306,9 @@ func NewAllTreeEntriesIter(filters sql.Expression) TreeEntriesIter {
22772306
func (i *squashTreeEntriesIter) Repository() *Repository { return i.repo }
22782307
func (i *squashTreeEntriesIter) TreeEntry() *TreeEntry { return i.entry }
22792308
func (i *squashTreeEntriesIter) Close() error {
2280-
i.Repository().Close()
2309+
if i.repo != nil {
2310+
i.repo.Close()
2311+
}
22812312

22822313
if i.trees != nil {
22832314
i.trees.Close()
@@ -2448,7 +2479,9 @@ func (i *squashTreeEntriesIndexIter) Schema() sql.Schema {
24482479
return TreeEntriesSchema
24492480
}
24502481
func (i *squashTreeEntriesIndexIter) Close() error {
2451-
i.Repository().Close()
2482+
if i.repo != nil {
2483+
i.repo.Close()
2484+
}
24522485
return i.iter.Close()
24532486
}
24542487

@@ -2480,8 +2513,6 @@ func NewTreeTreeEntriesIter(
24802513
func (i *squashTreeTreeEntriesIter) Repository() *Repository { return i.trees.Repository() }
24812514
func (i *squashTreeTreeEntriesIter) TreeEntry() *TreeEntry { return i.entry }
24822515
func (i *squashTreeTreeEntriesIter) Close() error {
2483-
i.Repository().Close()
2484-
24852516
if i.trees != nil {
24862517
return i.trees.Close()
24872518
}
@@ -2651,7 +2682,9 @@ func (i *squashCommitBlobsIndexIter) Schema() sql.Schema {
26512682
return CommitBlobsSchema
26522683
}
26532684
func (i *squashCommitBlobsIndexIter) Close() error {
2654-
i.Repository().Close()
2685+
if i.repo != nil {
2686+
i.repo.Close()
2687+
}
26552688
return i.iter.Close()
26562689
}
26572690

@@ -2689,8 +2722,6 @@ func (i *squashCommitBlobsIter) Close() error {
26892722
i.files.Close()
26902723
}
26912724

2692-
i.Repository().Close()
2693-
26942725
if i.commits != nil {
26952726
return i.commits.Close()
26962727
}
@@ -2821,8 +2852,6 @@ func (i *squashRepoBlobsIter) Close() error {
28212852
i.blobs.Close()
28222853
}
28232854

2824-
i.Repository().Close()
2825-
28262855
if i.repos != nil {
28272856
return i.repos.Close()
28282857
}
@@ -3207,7 +3236,6 @@ func (i *squashCommitFilesIter) Close() error {
32073236
i.files.Close()
32083237
}
32093238

3210-
i.Repository().Close()
32113239
return i.commits.Close()
32123240
}
32133241
func (i *squashCommitFilesIter) Schema() sql.Schema {
@@ -3315,7 +3343,9 @@ func (i *squashIndexCommitFilesIter) Row() sql.Row { return i.row }
33153343
func (i *squashIndexCommitFilesIter) Schema() sql.Schema { return CommitFilesSchema }
33163344

33173345
func (i *squashIndexCommitFilesIter) Close() error {
3318-
i.repo.Close()
3346+
if i.repo != nil {
3347+
i.repo.Close()
3348+
}
33193349
return i.iter.Close()
33203350
}
33213351

@@ -3391,7 +3421,6 @@ func (i *squashCommitFileFilesIter) Schema() sql.Schema {
33913421
return append(i.files.Schema(), FilesSchema...)
33923422
}
33933423
func (i *squashCommitFileFilesIter) Close() error {
3394-
i.Repository().Close()
33953424
return i.files.Close()
33963425
}
33973426

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)