Skip to content

Commit

Permalink
Merge pull request #21171 from JuliaLang/sb/libgit2/cat
Browse files Browse the repository at this point in the history
deprecate use of cat with LibGit2 objects
  • Loading branch information
kshyatt authored Mar 28, 2017
2 parents 85f37bc + e8a022a commit 55e1333
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
11 changes: 10 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1138,8 +1138,17 @@ end
@deprecate revparse(repo::GitRepo, objname::AbstractString) GitObject(repo, objname) false
@deprecate object(repo::GitRepo, te::GitTreeEntry) GitObject(repo, te) false
@deprecate commit(ann::GitAnnotated) GitHash(ann) false
@deprecate cat{T<:GitObject}(repo::GitRepo, ::Type{T}, object::AbstractString) cat(repo, object)
@deprecate lookup(repo::GitRepo, oid::GitHash) GitBlob(repo, oid) false
function Base.cat{T<:GitObject}(repo::GitRepo, ::Type{T}, object::Union{AbstractString,AbstractGitHash})
Base.depwarn("cat(repo::GitRepo, T, spec) is deprecated, use content(T(repo, spec))", :cat)
try
return content(GitBlob(repo, spec))
catch e
isa(e, LibGit2.GitError) && return nothing
rethrow(e)
end
end
Base.cat(repo::GitRepo, object::Union{AbstractString,AbstractGitHash}) = cat(repo, GitBlob, object)
end

# when this deprecation is deleted, remove all calls to it, and all
Expand Down
12 changes: 1 addition & 11 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module LibGit2

import Base: merge!, cat, ==
import Base: merge!, ==

export with, GitRepo, GitConfig

Expand Down Expand Up @@ -495,16 +495,6 @@ Equivalent to `git reset [--soft | --mixed | --hard] <id>`.
reset!(repo::GitRepo, id::GitHash, mode::Cint = Consts.RESET_MIXED) =
reset!(repo, GitObject(repo, id), mode)

""" git cat-file <commit> """
function cat(repo::GitRepo, spec::Union{AbstractString,AbstractGitHash})
obj = GitObject(repo, spec)
if isa(obj, GitBlob)
content(obj)
else
nothing
end
end

""" git rev-list --count <commit1> <commit2> """
function revcount(repo::GitRepo, fst::AbstractString, snd::AbstractString)
fst_id = revparseid(repo, fst)
Expand Down

0 comments on commit 55e1333

Please sign in to comment.