Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add GitShortHash type, remove some get methods #20104

Merged
merged 11 commits into from
Jan 31, 2017
22 changes: 18 additions & 4 deletions base/libgit2/repository.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,29 @@ function isattached(repo::GitRepo)
ccall((:git_repository_head_detached, :libgit2), Cint, (Ptr{Void},), repo.ptr) != 1
end

"""
@doc """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the @doc necessary here?

GitObject(repo::GitRepo, hash::AbstractGitHash)
GitObject(repo::GitRepo, spec::AbstractString)

Return the specified git object from `repo` specified by `hash`/`spec`.
Return the specified object (`GitCommit`, `GitBlob`, `GitTree` or `GitTag`) from `repo`
specified by `hash`/`spec`.

- `hash` is a full (`GitHash`) or partial (`GitShortHash`) hash.
- `spec` is a textual specification: see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for a full list.
"""
""" GitObject

for T in (:GitCommit, :GitBlob, :GitTree, :GitTag)
@eval @doc $"""
$T(repo::GitRepo, hash::AbstractGitHash)
$T(repo::GitRepo, spec::AbstractString)

Return a `$T` object from `repo` specified by `hash`/`spec`.

- `hash` is a full (`GitHash`) or partial (`GitShortHash`) hash.
- `spec` is a textual specification: see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for a full list.
""" $T
end

function (::Type{T}){T<:GitObject}(repo::GitRepo, spec::AbstractString)
obj_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
@check ccall((:git_revparse_single, :libgit2), Cint,
Expand Down Expand Up @@ -178,7 +192,7 @@ end
peel([T,] obj::GitObject)

Recursively peel `obj` until an object of type `T` is obtained. If no `T` is provided,
then it will be peeled until the type changes.
then `obj` will be peeled until the type changes.

- A `GitTag` will be peeled to the object it references.
- A `GitCommit` will be peeled to a `GitTree`.
Expand Down