Skip to content

Commit

Permalink
Fix double-nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Jan 26, 2017
1 parent b46c391 commit 0af7d4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
force::Bool=false, # force branch creation
set_head::Bool=true) # set as head reference on exit
# try to lookup branch first
branch_ref = Nullable{GitReference}(force ? nothing : lookup_branch(repo, branch_name))
branch_ref = force ? Nullable{GitReference}() : lookup_branch(repo, branch_name)
if isnull(branch_ref)
branch_rmt_ref = Nullable{GitReference}(isempty(track) ? nothing : lookup_branch(repo, "$track/$branch_name", true))
branch_rmt_ref = isempty(track) ? Nullable{GitReference}() : lookup_branch(repo, "$track/$branch_name", true)
# if commit is empty get head commit oid
commit_id = if isempty(commit)
if isnull(branch_rmt_ref)
Expand Down
6 changes: 4 additions & 2 deletions base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ function lookup_branch(repo::GitRepo,
if err != Int(Error.GIT_OK)
if err == Int(Error.ENOTFOUND)
return Nullable{GitReference}()
elseif err != Int(Error.ENOTFOUND) && ref_ptr_ptr[] != C_NULL
end
if ref_ptr_ptr[] != C_NULL
close(GitReference(repo, ref_ptr_ptr[]))
end
throw(Error.GitError(err))
Expand All @@ -208,7 +209,8 @@ function upstream(ref::GitReference)
if err != Int(Error.GIT_OK)
if err == Int(Error.ENOTFOUND)
return Nullable{GitReference}()
elseif err != Int(Error.ENOTFOUND) && ref_ptr_ptr[] != C_NULL
end
if ref_ptr_ptr[] != C_NULL
close(GitReference(ref.repo, ref_ptr_ptr[]))
end
throw(Error.GitError(err))
Expand Down

0 comments on commit 0af7d4e

Please sign in to comment.