Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 81cff89

Browse files
committedDec 20, 2016
Overload Base.close instead of Base.finalize for LibGit2
Fixes #17414.
1 parent c604d05 commit 81cff89

19 files changed

+119
-108
lines changed
 

‎base/deprecated.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1154,4 +1154,9 @@ for (dep, f, op) in [(:sumabs!, :sum!, :abs),
11541154
end
11551155
end
11561156

1157+
@deprecate finalize(sa::LibGit2.StrArrayStruct) close(sa)
1158+
@deprecate finalize(sa::LibGit2.Buffer) close(sa)
1159+
@deprecate finalize(sa::LibGit2.AbstractGitObject) close(sa)
1160+
1161+
11571162
# End deprecations scheduled for 0.6

‎base/libgit2/callbacks.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function mirror_callback(remote::Ptr{Ptr{Void}}, repo_ptr::Ptr{Void},
1818
name_str = unsafe_string(name)
1919
err= try set!(config, "remote.$name_str.mirror", true)
2020
catch -1
21-
finally finalize(config)
21+
finally close(config)
2222
end
2323
err != 0 && return Cint(err)
2424
return Cint(0)

‎base/libgit2/commit.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ function commit(repo::GitRepo, msg::AbstractString;
7979
commit_id = commit(repo, refname, msg, auth_sig, comm_sig, tree, parents...)
8080
finally
8181
for parent in parents
82-
finalize(parent)
82+
close(parent)
8383
end
84-
finalize(tree)
85-
finalize(auth_sig)
86-
finalize(comm_sig)
84+
close(tree)
85+
close(auth_sig)
86+
close(comm_sig)
8787
end
8888
return commit_id
8989
end

‎base/libgit2/config.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function GitConfig(path::AbstractString,
1010
try
1111
addfile(cfg, path, level, force)
1212
catch ex
13-
finalize(cfg)
14-
throw(ex)
13+
close(cfg)
14+
rethrow(ex)
1515
end
1616
return cfg
1717
end
@@ -37,7 +37,7 @@ function GitConfig(level::Consts.GIT_CONFIG = Consts.CONFIG_LEVEL_DEFAULT)
3737
glb_cfg_ptr_ptr, cfg.ptr, Cint(level))
3838
cfg = GitConfig(glb_cfg_ptr_ptr[])
3939
finally
40-
finalize(tmpcfg)
40+
close(tmpcfg)
4141
end
4242
end
4343
return cfg

‎base/libgit2/diff.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function diff_tree(repo::GitRepo, tree::GitTree, pathspecs::AbstractString=""; c
1818
diff_ptr_ptr, repo.ptr, tree.ptr, emptypathspec ? C_NULL : Ref(diff_opts))
1919
end
2020
finally
21-
!emptypathspec && finalize(sa)
21+
!emptypathspec && close(sa)
2222
end
2323
return GitDiff(diff_ptr_ptr[])
2424
end

‎base/libgit2/index.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function read_tree!(idx::GitIndex, tree_id::Oid)
3737
@check ccall((:git_index_read_tree, :libgit2), Cint,
3838
(Ptr{Void}, Ptr{Void}), idx.ptr, tree.ptr)
3939
finally
40-
finalize(tree)
40+
close(tree)
4141
end
4242
end
4343

@@ -49,7 +49,7 @@ function add!{T<:AbstractString}(idx::GitIndex, files::T...;
4949
(Ptr{Void}, Ptr{StrArrayStruct}, Cuint, Ptr{Void}, Ptr{Void}),
5050
idx.ptr, Ref(sa), flags, C_NULL, C_NULL)
5151
finally
52-
finalize(sa)
52+
close(sa)
5353
end
5454
end
5555

@@ -60,7 +60,7 @@ function update!{T<:AbstractString}(idx::GitIndex, files::T...)
6060
(Ptr{Void}, Ptr{StrArrayStruct}, Ptr{Void}, Ptr{Void}),
6161
idx.ptr, Ref(sa), C_NULL, C_NULL)
6262
finally
63-
finalize(sa)
63+
close(sa)
6464
end
6565
end
6666

@@ -71,7 +71,7 @@ function remove!{T<:AbstractString}(idx::GitIndex, files::T...)
7171
(Ptr{Void}, Ptr{StrArrayStruct}, Ptr{Void}, Ptr{Void}),
7272
idx.ptr, Ref(sa), C_NULL, C_NULL)
7373
finally
74-
finalize(sa)
74+
close(sa)
7575
end
7676
end
7777

‎base/libgit2/libgit2.jl

+40-34
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function iscommit(id::AbstractString, repo::GitRepo)
6363
if c === nothing
6464
res = false
6565
else
66-
finalize(c)
66+
close(c)
6767
end
6868
catch
6969
res = false
@@ -84,11 +84,11 @@ function isdiff(repo::GitRepo, treeish::AbstractString, paths::AbstractString=""
8484
try
8585
diff = diff_tree(repo, tree, paths)
8686
result = count(diff) > 0
87-
finalize(diff)
87+
close(diff)
8888
catch err
8989
result = true
9090
finally
91-
finalize(tree)
91+
close(tree)
9292
end
9393
return result
9494
end
@@ -110,10 +110,10 @@ function diff_files(repo::GitRepo, branch1::AbstractString, branch2::AbstractStr
110110
push!(files, unsafe_string(delta.new_file.path))
111111
end
112112
end
113-
finalize(diff)
113+
close(diff)
114114
finally
115-
finalize(tree1)
116-
finalize(tree2)
115+
close(tree1)
116+
close(tree2)
117117
end
118118
return files
119119
end
@@ -163,7 +163,7 @@ function fetch{T<:AbstractString, P<:AbstractCredentials}(repo::GitRepo;
163163
fo = FetchOptions(callbacks=RemoteCallbacks(credentials_cb(), payload))
164164
fetch(rmt, refspecs, msg="from $(url(rmt))", options = fo)
165165
finally
166-
finalize(rmt)
166+
close(rmt)
167167
end
168168
end
169169

@@ -184,7 +184,7 @@ function push{T<:AbstractString, P<:AbstractCredentials}(repo::GitRepo;
184184
push_opts=PushOptions(callbacks=RemoteCallbacks(credentials_cb(), payload))
185185
push(rmt, refspecs, force=force, options=push_opts)
186186
finally
187-
finalize(rmt)
187+
close(rmt)
188188
end
189189
end
190190

@@ -194,7 +194,7 @@ function branch(repo::GitRepo)
194194
try
195195
branch(head_ref)
196196
finally
197-
finalize(head_ref)
197+
close(head_ref)
198198
end
199199
end
200200

@@ -220,7 +220,7 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
220220
tmpcmt = with(peel(GitCommit, branch_rmt_ref)) do hrc
221221
Oid(hrc)
222222
end
223-
finalize(branch_rmt_ref)
223+
close(branch_rmt_ref)
224224
tmpcmt
225225
end
226226
else
@@ -232,7 +232,7 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
232232
try
233233
new_branch_ref = create_branch(repo, branch_name, cmt, force=force)
234234
finally
235-
finalize(cmt)
235+
close(cmt)
236236
new_branch_ref === nothing && throw(GitError(Error.Object, Error.ERROR, "cannot create branch `$branch_name` with `$commit_id`"))
237237
branch_ref = new_branch_ref
238238
end
@@ -260,7 +260,7 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
260260
head!(repo, branch_ref)
261261
end
262262
finally
263-
finalize(branch_ref)
263+
close(branch_ref)
264264
end
265265
return
266266
end
@@ -296,15 +296,15 @@ function checkout!(repo::GitRepo, commit::AbstractString = "";
296296
obj_oid = Oid(peeled)
297297
ref = GitReference(repo, obj_oid, force=force,
298298
msg="libgit2.checkout: moving from $head_name to $(string(obj_oid))")
299-
finalize(ref)
299+
close(ref)
300300

301301
# checkout commit
302302
checkout_tree(repo, peeled, options = opts)
303303
finally
304-
finalize(peeled)
304+
close(peeled)
305305
end
306306
finally
307-
finalize(obj)
307+
close(obj)
308308
end
309309
end
310310

@@ -335,7 +335,7 @@ function reset!(repo::GitRepo, committish::AbstractString, pathspecs::AbstractSt
335335
try
336336
reset!(repo, Nullable(obj), pathspecs...)
337337
finally
338-
finalize(obj)
338+
close(obj)
339339
end
340340
end
341341

@@ -347,7 +347,7 @@ function reset!(repo::GitRepo, commit::Oid, mode::Cint = Consts.RESET_MIXED)
347347
try
348348
reset!(repo, obj, mode)
349349
finally
350-
finalize(obj)
350+
close(obj)
351351
end
352352
end
353353

@@ -409,12 +409,15 @@ function merge!(repo::GitRepo;
409409
throw(GitError(Error.Merge, Error.ERROR,
410410
"Repository HEAD is detached. Remote tracking branch cannot be used."))
411411
end
412-
with(upstream(head_ref)) do tr_brn_ref
413-
if tr_brn_ref === nothing
414-
throw(GitError(Error.Merge, Error.ERROR,
415-
"There is no tracking information for the current branch."))
416-
end
412+
tr_brn_ref = upstream(head_ref)
413+
if tr_brn_ref === nothing
414+
throw(GitError(Error.Merge, Error.ERROR,
415+
"There is no tracking information for the current branch."))
416+
end
417+
try
417418
[GitAnnotated(repo, tr_brn_ref)]
419+
finally
420+
close(tr_brn_ref)
418421
end
419422
end
420423
end
@@ -424,7 +427,7 @@ function merge!(repo::GitRepo;
424427
merge_opts=merge_opts,
425428
checkout_opts=checkout_opts)
426429
finally
427-
map(finalize, upst_anns)
430+
map(close, upst_anns)
428431
end
429432
end
430433
end
@@ -434,12 +437,15 @@ function rebase!(repo::GitRepo, upstream::AbstractString="", newbase::AbstractSt
434437
with(head(repo)) do head_ref
435438
head_ann = GitAnnotated(repo, head_ref)
436439
upst_ann = if isempty(upstream)
437-
with(LibGit2.upstream(head_ref)) do brn_ref
438-
if brn_ref === nothing
439-
throw(GitError(Error.Rebase, Error.ERROR,
440-
"There is no tracking information for the current branch."))
441-
end
440+
brn_ref = LibGit2.upstream(head_ref)
441+
if brn_ref === nothing
442+
throw(GitError(Error.Rebase, Error.ERROR,
443+
"There is no tracking information for the current branch."))
444+
end
445+
try
442446
GitAnnotated(repo, brn_ref)
447+
finally
448+
close(brn_ref)
443449
end
444450
else
445451
GitAnnotated(repo, upstream)
@@ -456,15 +462,15 @@ function rebase!(repo::GitRepo, upstream::AbstractString="", newbase::AbstractSt
456462
catch err
457463
abort(rbs)
458464
finally
459-
finalize(rbs)
465+
close(rbs)
460466
end
461467
finally
462-
#!isnull(onto_ann) && finalize(get(onto_ann))
463-
finalize(sig)
468+
#!isnull(onto_ann) && close(get(onto_ann))
469+
close(sig)
464470
end
465471
finally
466-
finalize(upst_ann)
467-
finalize(head_ann)
472+
close(upst_ann)
473+
close(head_ann)
468474
end
469475
end
470476
return nothing
@@ -522,7 +528,7 @@ function transact(f::Function, repo::GitRepo)
522528
restore(state, repo)
523529
rethrow()
524530
finally
525-
finalize(repo)
531+
close(repo)
526532
end
527533
end
528534

‎base/libgit2/merge.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function GitAnnotated(repo::GitRepo, comittish::AbstractString)
3131
cmt === nothing && return nothing
3232
return GitAnnotated(repo, Oid(cmt))
3333
finally
34-
finalize(obj)
34+
close(obj)
3535
end
3636
end
3737

@@ -65,10 +65,10 @@ function ffmerge!(repo::GitRepo, ann::GitAnnotated)
6565
else
6666
GitReference(repo, cmt_oid, fullname(head_ref), msg=msg)
6767
end
68-
finalize(new_head_ref)
68+
close(new_head_ref)
6969
end
7070
finally
71-
finalize(cmt)
71+
close(cmt)
7272
end
7373
return true
7474
end

‎base/libgit2/reference.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function peel{T <: GitObject}(::Type{T}, ref::GitReference)
9696
return Oid()
9797
elseif err != Int(Error.GIT_OK)
9898
if obj_ptr_ptr[] != C_NULL
99-
finalize(GitAnyObject(obj_ptr_ptr[]))
99+
close(GitAnyObject(obj_ptr_ptr[]))
100100
end
101101
throw(Error.GitError(err))
102102
end
@@ -146,7 +146,7 @@ function lookup_branch(repo::GitRepo,
146146
return nothing
147147
elseif err != Int(Error.GIT_OK)
148148
if ref_ptr_ptr[] != C_NULL
149-
finalize(GitReference(ref_ptr_ptr[]))
149+
close(GitReference(ref_ptr_ptr[]))
150150
end
151151
throw(Error.GitError(err))
152152
end
@@ -162,7 +162,7 @@ function upstream(ref::GitReference)
162162
return nothing
163163
elseif err != Int(Error.GIT_OK)
164164
if ref_ptr_ptr[] != C_NULL
165-
finalize(GitReference(ref_ptr_ptr[]))
165+
close(GitReference(ref_ptr_ptr[]))
166166
end
167167
throw(Error.GitError(err))
168168
end

‎base/libgit2/remote.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function fetch_refspecs(rmt::GitRemote)
4545
(Ptr{LibGit2.StrArrayStruct}, Ptr{Void}), sa_ref, rmt.ptr)
4646
convert(Vector{AbstractString}, sa_ref[])
4747
finally
48-
finalize(sa_ref[])
48+
close(sa_ref[])
4949
end
5050
end
5151

@@ -56,7 +56,7 @@ function push_refspecs(rmt::GitRemote)
5656
(Ptr{LibGit2.StrArrayStruct}, Ptr{Void}), sa_ref, rmt.ptr)
5757
convert(Vector{AbstractString}, sa_ref[])
5858
finally
59-
finalize(sa_ref[])
59+
close(sa_ref[])
6060
end
6161
end
6262

@@ -71,7 +71,7 @@ function fetch{T<:AbstractString}(rmt::GitRemote, refspecs::Vector{T};
7171
(Ptr{Void}, Ptr{StrArrayStruct}, Ptr{FetchOptions}, Cstring),
7272
rmt.ptr, no_refs ? C_NULL : Ref(sa), Ref(options), msg)
7373
finally
74-
!no_refs && finalize(sa)
74+
!no_refs && close(sa)
7575
end
7676
end
7777

@@ -85,6 +85,6 @@ function push{T<:AbstractString}(rmt::GitRemote, refspecs::Vector{T};
8585
(Ptr{Void}, Ptr{StrArrayStruct}, Ptr{PushOptions}),
8686
rmt.ptr, no_refs ? C_NULL : Ref(sa), Ref(options))
8787
finally
88-
!no_refs && finalize(sa)
88+
!no_refs && close(sa)
8989
end
9090
end

‎base/libgit2/repository.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function GitRepo(path::AbstractString)
66
(Ptr{Ptr{Void}}, Cstring), repo_ptr_ptr, path)
77
if err != Int(Error.GIT_OK)
88
if repo_ptr_ptr[] != C_NULL
9-
finalize(GitRepo(repo_ptr_ptr[]))
9+
close(GitRepo(repo_ptr_ptr[]))
1010
end
1111
throw(Error.GitError(err))
1212
end
@@ -21,7 +21,7 @@ function GitRepoExt(path::AbstractString, flags::Cuint = Cuint(Consts.REPOSITORY
2121
repo_ptr_ptr, path, flags, separator)
2222
if err != Int(Error.GIT_OK)
2323
if repo_ptr_ptr[] != C_NULL
24-
finalize(GitRepo(repo_ptr_ptr[]))
24+
close(GitRepo(repo_ptr_ptr[]))
2525
end
2626
throw(Error.GitError(err))
2727
end
@@ -46,7 +46,7 @@ function head_oid(repo::GitRepo)
4646
try
4747
return Oid(head_ref)
4848
finally
49-
finalize(head_ref)
49+
close(head_ref)
5050
end
5151
end
5252

@@ -82,7 +82,7 @@ function revparseid(repo::GitRepo, objname::AbstractString)
8282
obj = revparse(repo, objname)
8383
obj === nothing && return Oid()
8484
oid = Oid(obj.ptr)
85-
finalize(obj)
85+
close(obj)
8686
return oid
8787
end
8888

@@ -104,7 +104,7 @@ function get{T <: GitObject}(::Type{T}, r::GitRepo, oid::Oid, oid_size::Int=OID_
104104
return nothing
105105
elseif err != Int(Error.GIT_OK)
106106
if obj_ptr_ptr[] != C_NULL
107-
finalize(GitAnyObject(obj_ptr_ptr[]))
107+
close(GitAnyObject(obj_ptr_ptr[]))
108108
end
109109
throw(Error.GitError(err))
110110
end
@@ -134,7 +134,7 @@ function peel(obj::GitObject, obj_type::Cint)
134134
return Oid()
135135
elseif err != Int(Error.GIT_OK)
136136
if peeled_ptr_ptr[] != C_NULL
137-
finalize(GitAnyObject(peeled_ptr_ptr[]))
137+
close(GitAnyObject(peeled_ptr_ptr[]))
138138
end
139139
throw(Error.GitError(err))
140140
end

‎base/libgit2/signature.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ function Signature(name::AbstractString, email::AbstractString)
1616
(Ptr{Ptr{SignatureStruct}}, Cstring, Cstring), sig_ptr_ptr, name, email)
1717
sig = GitSignature(sig_ptr_ptr[])
1818
s = Signature(sig.ptr)
19-
finalize(sig)
19+
close(sig)
2020
return s
2121
end
2222

2323
function Signature(repo::GitRepo)
2424
sig = default_signature(repo)
2525
s = Signature(sig.ptr)
26-
finalize(sig)
26+
close(sig)
2727
return s
2828
end
2929

‎base/libgit2/types.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ immutable StrArrayStruct
3232
count::Csize_t
3333
end
3434
StrArrayStruct() = StrArrayStruct(Ptr{Cstring}(C_NULL), zero(Csize_t))
35-
function Base.finalize(sa::StrArrayStruct)
35+
function Base.close(sa::StrArrayStruct)
3636
sa_ptr = Ref(sa)
3737
ccall((:git_strarray_free, :libgit2), Void, (Ptr{StrArrayStruct},), sa_ptr)
3838
return sa_ptr[]
@@ -44,7 +44,7 @@ immutable Buffer
4444
size::Csize_t
4545
end
4646
Buffer() = Buffer(Ptr{Cchar}(C_NULL), zero(Csize_t), zero(Csize_t))
47-
function Base.finalize(buf::Buffer)
47+
function Base.close(buf::Buffer)
4848
buf_ptr = Ref(buf)
4949
ccall((:git_buf_free, :libgit2), Void, (Ptr{Buffer},), buf_ptr)
5050
return buf_ptr[]
@@ -574,7 +574,7 @@ abstract AbstractGitObject
574574
Base.isempty(obj::AbstractGitObject) = (obj.ptr == C_NULL)
575575

576576
abstract GitObject <: AbstractGitObject
577-
function Base.finalize(obj::GitObject)
577+
function Base.close(obj::GitObject)
578578
if obj.ptr != C_NULL
579579
ccall((:git_object_free, :libgit2), Void, (Ptr{Void},), obj.ptr)
580580
obj.ptr = C_NULL
@@ -613,7 +613,7 @@ for (typ, ref, sup, fnc) in (
613613
end
614614

615615
if fnc !== nothing
616-
@eval function Base.finalize(obj::$typ)
616+
@eval function Base.close(obj::$typ)
617617
if obj.ptr != C_NULL
618618
ccall(($fnc, :libgit2), Void, (Ptr{$ref},), obj.ptr)
619619
obj.ptr = C_NULL
@@ -637,7 +637,7 @@ function with(f::Function, obj)
637637
try
638638
f(obj)
639639
finally
640-
finalize(obj)
640+
close(obj)
641641
end
642642
end
643643

‎base/pkg/cache.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function prefetch(pkg::AbstractString, url::AbstractString, sha1s::Vector)
6666
end
6767
sha1s[!in_cache]
6868
finally
69-
finalize(repo) # closing repo opened/created above
69+
close(repo) # closing repo opened/created above
7070
end
7171
end
7272
prefetch(pkg::AbstractString, url::AbstractString, sha1::AbstractString...) =

‎base/pkg/entry.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function status(io::IO, pkg::AbstractString, ver::VersionNumber, fix::Bool)
176176
catch err
177177
print_with_color(Base.error_color(), io, " broken-repo (unregistered)")
178178
finally
179-
finalize(prepo)
179+
close(prepo)
180180
end
181181
else
182182
print_with_color(Base.warn_color(), io, "non-repo (unregistered)")
@@ -329,10 +329,10 @@ function pin(pkg::AbstractString, head::AbstractString)
329329
# switch head to the branch
330330
LibGit2.head!(repo, ref)
331331
finally
332-
finalize(ref)
332+
close(ref)
333333
end
334334
finally
335-
finalize(commit)
335+
close(commit)
336336
end
337337
end
338338
should_resolve && resolve()

‎base/pkg/read.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function isfixed(pkg::AbstractString, prepo::LibGit2.GitRepo, avail::Dict=availa
9595
end
9696
end
9797
finally
98-
cache_has_head && LibGit2.finalize(crepo)
98+
cache_has_head && LibGit2.close(crepo)
9999
end
100100
return res
101101
end
@@ -159,7 +159,7 @@ function installed_version(pkg::AbstractString, prepo::LibGit2.GitRepo, avail::D
159159
string(base) == head && push!(descendants,ver)
160160
end
161161
finally
162-
cache_has_head && LibGit2.finalize(crepo)
162+
cache_has_head && LibGit2.close(crepo)
163163
end
164164
both = sort!(intersect(ancestors,descendants))
165165
isempty(both) || warn("$pkg: some versions are both ancestors and descendants of head: $both")

‎base/pkg/write.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function install(pkg::AbstractString, sha1::AbstractString)
4343
fetch(repo, pkg, sha1)
4444
checkout(repo, pkg, sha1)
4545
finally
46-
finalize(repo)
46+
close(repo)
4747
end
4848
end
4949

‎test/libgit2-online.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mktempdir() do dir
1616
@test isdir(repo_path)
1717
@test isdir(joinpath(repo_path, ".git"))
1818
finally
19-
finalize(repo)
19+
close(repo)
2020
end
2121
end
2222

‎test/libgit2.jl

+30-30
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ end
4343
arr = convert(Vector{AbstractString}, sa1)
4444
@test arr[1] == p1
4545
finally
46-
finalize(sa1)
46+
close(sa1)
4747
end
4848

4949
sa2 = LibGit2.StrArrayStruct(p1, p2)
@@ -55,17 +55,17 @@ end
5555
arr2 = convert(Vector{AbstractString}, sa3)
5656
@test arr1[1] == arr2[1]
5757
@test arr1[2] == arr2[2]
58-
finalize(sa3)
58+
close(sa3)
5959
finally
60-
finalize(sa2)
60+
close(sa2)
6161
end
6262
end
6363

6464
@testset "Signature" begin
6565
sig = LibGit2.Signature("AAA", "AAA@BBB.COM", round(time(), 0), 0)
6666
git_sig = convert(LibGit2.GitSignature, sig)
6767
sig2 = LibGit2.Signature(git_sig)
68-
finalize(git_sig)
68+
close(git_sig)
6969
@test sig.name == sig2.name
7070
@test sig.email == sig2.email
7171
@test sig.time == sig2.time
@@ -159,7 +159,7 @@ mktempdir() do dir
159159
@test LibGit2.get(cfg, "tmp.int64", Int64(0)) == Int64(1)
160160
@test LibGit2.get(cfg, "tmp.bool", false) == true
161161
finally
162-
finalize(cfg)
162+
close(cfg)
163163
end
164164
end
165165

@@ -172,7 +172,7 @@ mktempdir() do dir
172172

173173
# set a remote branch
174174
branch = "upstream"
175-
LibGit2.GitRemote(repo, branch, repo_url) |> finalize
175+
LibGit2.GitRemote(repo, branch, repo_url) |> close
176176

177177
config = joinpath(cache_repo, ".git", "config")
178178
lines = split(open(readstring, config, "r"), "\n")
@@ -181,9 +181,9 @@ mktempdir() do dir
181181
remote = LibGit2.get(LibGit2.GitRemote, repo, branch)
182182
@test LibGit2.url(remote) == repo_url
183183
@test LibGit2.isattached(repo)
184-
finalize(remote)
184+
close(remote)
185185
finally
186-
finalize(repo)
186+
close(repo)
187187
end
188188
end
189189

@@ -195,7 +195,7 @@ mktempdir() do dir
195195
@test isfile(joinpath(path, LibGit2.Consts.HEAD_FILE))
196196
@test LibGit2.isattached(repo)
197197
finally
198-
finalize(repo)
198+
close(repo)
199199
end
200200

201201
path = joinpath("garbagefakery", "Example.Bare")
@@ -220,7 +220,7 @@ mktempdir() do dir
220220
@test LibGit2.isattached(repo)
221221
@test LibGit2.remotes(repo) == ["origin"]
222222
finally
223-
finalize(repo)
223+
close(repo)
224224
end
225225
end
226226
@testset "bare with remote callback" begin
@@ -235,10 +235,10 @@ mktempdir() do dir
235235
@test LibGit2.isattached(repo)
236236
@test LibGit2.remotes(repo) == ["origin"]
237237
finally
238-
finalize(rmt)
238+
close(rmt)
239239
end
240240
finally
241-
finalize(repo)
241+
close(repo)
242242
end
243243
end
244244
@testset "normal" begin
@@ -248,7 +248,7 @@ mktempdir() do dir
248248
@test isdir(joinpath(test_repo, ".git"))
249249
@test LibGit2.isattached(repo)
250250
finally
251-
finalize(repo)
251+
close(repo)
252252
end
253253
end
254254
end
@@ -302,10 +302,10 @@ mktempdir() do dir
302302
@test cmtr.email == test_sig.email
303303
@test LibGit2.message(cmt) == commit_msg1
304304
finally
305-
finalize(cmt)
305+
close(cmt)
306306
end
307307
finally
308-
finalize(repo)
308+
close(repo)
309309
close(repo_file)
310310
end
311311
end
@@ -333,17 +333,17 @@ mktempdir() do dir
333333
@test LibGit2.shortname(tbref) == test_branch
334334
@test LibGit2.upstream(tbref) === nothing
335335
finally
336-
finalize(tbref)
336+
close(tbref)
337337
end
338338
finally
339-
finalize(brref)
339+
close(brref)
340340
end
341341

342342
branches = map(b->LibGit2.shortname(b[1]), LibGit2.GitBranchIter(repo))
343343
@test master_branch in branches
344344
@test test_branch in branches
345345
finally
346-
finalize(repo)
346+
close(repo)
347347
end
348348
end
349349

@@ -365,7 +365,7 @@ mktempdir() do dir
365365
@test sig.email == "BBBB@BBBB.COM"
366366
end
367367
finally
368-
finalize(repo)
368+
close(repo)
369369
end
370370
end
371371

@@ -401,7 +401,7 @@ mktempdir() do dir
401401
@test tag2 tags
402402
@test tag1 tags
403403
finally
404-
finalize(repo)
404+
close(repo)
405405
end
406406
end
407407

@@ -425,7 +425,7 @@ mktempdir() do dir
425425
@test status[1].status == LibGit2.Consts.STATUS_WT_NEW
426426
close(repo_file)
427427
finally
428-
finalize(repo)
428+
close(repo)
429429
end
430430
end
431431
end
@@ -465,7 +465,7 @@ mktempdir() do dir
465465
LibGit2.branch!(repo, master_branch)
466466

467467
finally
468-
finalize(repo)
468+
close(repo)
469469
end
470470
end
471471

@@ -492,11 +492,11 @@ mktempdir() do dir
492492
try
493493
@test_throws LibGit2.Error.GitError LibGit2.upstream(tag2ref)
494494
finally
495-
finalize(tag2ref)
495+
close(tag2ref)
496496
end
497497

498498
finally
499-
finalize(repo)
499+
close(repo)
500500
end
501501
end
502502

@@ -519,8 +519,8 @@ mktempdir() do dir
519519
@test cache_oids[i] == test_oids[i]
520520
end
521521
finally
522-
finalize(repo)
523-
finalize(cache)
522+
close(repo)
523+
close(cache)
524524
end
525525
end
526526
end
@@ -582,7 +582,7 @@ mktempdir() do dir
582582
@test read(io)[end] != 0x41
583583
end
584584
finally
585-
finalize(repo)
585+
close(repo)
586586
end
587587
end
588588

@@ -626,7 +626,7 @@ mktempdir() do dir
626626
# issue #19624
627627
@test LibGit2.head_oid(repo) == newhead
628628
finally
629-
finalize(repo)
629+
close(repo)
630630
end
631631
end
632632

@@ -647,7 +647,7 @@ mktempdir() do dir
647647
@test !isfile(joinpath(test_repo, "BBB"))
648648
@test isfile(joinpath(test_repo, test_file))
649649
finally
650-
finalize(repo)
650+
close(repo)
651651
end
652652
end
653653

@@ -748,7 +748,7 @@ mktempdir() do dir
748748
println(f, err)
749749
end
750750
finally
751-
finalize(repo)
751+
close(repo)
752752
end
753753
"""
754754
# We try to be helpful by desparately looking for

0 commit comments

Comments
 (0)
Please sign in to comment.