Skip to content

Commit

Permalink
Deprecate GitAnyObject -> GitUnknownObject
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Jan 8, 2017
1 parent 23c5450 commit 79ae816
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 35 deletions.
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1512,4 +1512,7 @@ unsafe_wrap(::Type{String}, p::Cstring, own::Bool=false) = unsafe_wrap(String, c
unsafe_wrap(::Type{String}, p::Cstring, len::Integer, own::Bool=false) =
unsafe_wrap(String, convert(Ptr{UInt8}, p), len, own)

# Rename LibGit2.GitAnyObject to LibGit2.GitUnknownObject (part of #19839)
eval(LibGit2, :(Base.@deprecate_binding GitAnyObject GitUnknownObject))

# End deprecations scheduled for 0.6
12 changes: 6 additions & 6 deletions base/libgit2/consts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module Consts
const REMOTE_ORIGIN = "origin"

# objs
const OBJ_ANY = Cint(-2)
const OBJ_BAD = Cint(-1)
const OBJ_COMMIT = Cint(1)
const OBJ_TREE = Cint(2)
const OBJ_BLOB = Cint(3)
const OBJ_TAG = Cint(4)
const OBJ_UNKNOWN = Cint(-2)
const OBJ_BAD = Cint(-1)
const OBJ_COMMIT = Cint(1)
const OBJ_TREE = Cint(2)
const OBJ_BLOB = Cint(3)
const OBJ_TAG = Cint(4)

#revwalk
const SORT_NONE = Cint(0)
Expand Down
4 changes: 2 additions & 2 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function checkout!(repo::GitRepo, commit::AbstractString = "";
end

# search for commit to get a commit object
obj = get(GitAnyObject, repo, Oid(commit))
obj = get(GitUnknownObject, repo, Oid(commit))
obj === nothing && return
try
peeled = peel(obj, Consts.OBJ_COMMIT)
Expand Down Expand Up @@ -341,7 +341,7 @@ end

""" git reset [--soft | --mixed | --hard] <commit> """
function reset!(repo::GitRepo, commit::Oid, mode::Cint = Consts.RESET_MIXED)
obj = get(GitAnyObject, repo, commit)
obj = get(GitUnknownObject, repo, commit)
# object must exist for reset
obj === nothing && throw(GitError(Error.Object, Error.ERROR, "Commit `$(string(commit))` object not found"))
try
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/reference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function peel{T <: GitObject}(::Type{T}, ref::GitReference)
return Oid()
elseif err != Int(Error.GIT_OK)
if obj_ptr_ptr[] != C_NULL
finalize(GitAnyObject(obj_ptr_ptr[]))
finalize(GitUnknownObject(obj_ptr_ptr[]))
end
throw(Error.GitError(err))
end
Expand Down
6 changes: 3 additions & 3 deletions base/libgit2/repository.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function revparse(repo::GitRepo, objname::AbstractString)
err = ccall((:git_revparse_single, :libgit2), Cint,
(Ptr{Ptr{Void}}, Ptr{Void}, Cstring), obj_ptr_ptr, repo.ptr, objname)
err != 0 && return nothing
return GitAnyObject(obj_ptr_ptr[])
return GitUnknownObject(obj_ptr_ptr[])
end

""" Returns id of a found object """
Expand Down Expand Up @@ -104,7 +104,7 @@ function get{T <: GitObject}(::Type{T}, r::GitRepo, oid::Oid, oid_size::Int=OID_
return nothing
elseif err != Int(Error.GIT_OK)
if obj_ptr_ptr[] != C_NULL
finalize(GitAnyObject(obj_ptr_ptr[]))
finalize(GitUnknownObject(obj_ptr_ptr[]))
end
throw(Error.GitError(err))
end
Expand Down Expand Up @@ -134,7 +134,7 @@ function peel(obj::GitObject, obj_type::Cint)
return Oid()
elseif err != Int(Error.GIT_OK)
if peeled_ptr_ptr[] != C_NULL
finalize(GitAnyObject(peeled_ptr_ptr[]))
finalize(GitUnknownObject(peeled_ptr_ptr[]))
end
throw(Error.GitError(err))
end
Expand Down
2 changes: 1 addition & 1 deletion base/libgit2/tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ function object(repo::GitRepo, te::GitTreeEntry)
@check ccall((:git_tree_entry_to_object, :libgit2), Cint,
(Ptr{Ptr{Void}}, Ptr{Void}, Ref{Void}),
obj_ptr_ptr, repo.ptr, te.ptr)
return GitAnyObject(obj_ptr_ptr[])
return GitUnknownObject(obj_ptr_ptr[])
end
44 changes: 22 additions & 22 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,24 +407,24 @@ end

# Common types
for (typ, ref, sup, fnc) in (
(:GitRemote, :Void, :AbstractGitObject, :(:git_remote_free)),
(:GitRevWalker, :Void, :AbstractGitObject, :(:git_revwalk_free)),
(:GitConfig, :Void, :AbstractGitObject, :(:git_config_free)),
(:GitReference, :Void, :AbstractGitObject, :(:git_reference_free)),
(:GitDiff, :Void, :AbstractGitObject, :(:git_diff_free)),
(:GitIndex, :Void, :AbstractGitObject, :(:git_index_free)),
(:GitRepo, :Void, :AbstractGitObject, :(:git_repository_free)),
(:GitAnnotated, :Void, :AbstractGitObject, :(:git_annotated_commit_free)),
(:GitRebase, :Void, :AbstractGitObject, :(:git_rebase_free)),
(:GitStatus, :Void, :AbstractGitObject, :(:git_status_list_free)),
(:GitBranchIter, :Void, :AbstractGitObject, :(:git_branch_iterator_free)),
(:GitTreeEntry, :Void, :AbstractGitObject, :(:git_tree_entry_free)),
(:GitSignature, :SignatureStruct, :AbstractGitObject, :(:git_signature_free)),
(:GitAnyObject, :Void, :GitObject, nothing),
(:GitCommit, :Void, :GitObject, nothing),
(:GitBlob, :Void, :GitObject, nothing),
(:GitTree, :Void, :GitObject, nothing),
(:GitTag, :Void, :GitObject, nothing)
(:GitRemote, :Void, :AbstractGitObject, :(:git_remote_free)),
(:GitRevWalker, :Void, :AbstractGitObject, :(:git_revwalk_free)),
(:GitConfig, :Void, :AbstractGitObject, :(:git_config_free)),
(:GitReference, :Void, :AbstractGitObject, :(:git_reference_free)),
(:GitDiff, :Void, :AbstractGitObject, :(:git_diff_free)),
(:GitIndex, :Void, :AbstractGitObject, :(:git_index_free)),
(:GitRepo, :Void, :AbstractGitObject, :(:git_repository_free)),
(:GitAnnotated, :Void, :AbstractGitObject, :(:git_annotated_commit_free)),
(:GitRebase, :Void, :AbstractGitObject, :(:git_rebase_free)),
(:GitStatus, :Void, :AbstractGitObject, :(:git_status_list_free)),
(:GitBranchIter, :Void, :AbstractGitObject, :(:git_branch_iterator_free)),
(:GitTreeEntry, :Void, :AbstractGitObject, :(:git_tree_entry_free)),
(:GitSignature, :SignatureStruct, :AbstractGitObject, :(:git_signature_free)),
(:GitUnknownObject, :Void, :GitObject, nothing),
(:GitCommit, :Void, :GitObject, nothing),
(:GitBlob, :Void, :GitObject, nothing),
(:GitTree, :Void, :GitObject, nothing),
(:GitTag, :Void, :GitObject, nothing)
)

@eval type $typ <: $sup
Expand Down Expand Up @@ -486,8 +486,8 @@ function getobjecttype{T<:GitObject}(::Type{T})
Consts.OBJ_BLOB
elseif T == GitTag
Consts.OBJ_TAG
elseif T == GitAnyObject
Consts.OBJ_ANY
elseif T == GitUnknownObject
Consts.OBJ_UNKNOWN
else
throw(GitError(Error.Object, Error.ENOTFOUND, "Type $T is not supported"))
end
Expand All @@ -502,8 +502,8 @@ function getobjecttype(obj_type::Cint)
GitBlob
elseif obj_type == Consts.OBJ_TAG
GitTag
elseif obj_type == Consts.OBJ_ANY
GitAnyObject
elseif obj_type == Consts.OBJ_UNKNOWN
GitUnknownObject
else
throw(GitError(Error.Object, Error.ENOTFOUND, "Object type $obj_type is not supported"))
end
Expand Down

0 comments on commit 79ae816

Please sign in to comment.