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 docs for isbare/isattached #22557

Merged
merged 2 commits into from
Jun 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions base/libgit2/repository.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
LibGit2.GitRepo(path::AbstractString)

Opens a git repository at `path`.
Open a git repository at `path`.
"""
function GitRepo(path::AbstractString)
repo_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
Expand All @@ -15,7 +15,7 @@ end
"""
LibGit2.GitRepoExt(path::AbstractString, flags::Cuint = Cuint(Consts.REPOSITORY_OPEN_DEFAULT))

Opens a git repository at `path` with extended controls (for instance, if the current
Open a git repository at `path` with extended controls (for instance, if the current
user must be a member of a special access group to read `path`).
"""
function GitRepoExt(path::AbstractString, flags::Cuint = Cuint(Consts.REPOSITORY_OPEN_DEFAULT))
Expand All @@ -36,7 +36,7 @@ end
"""
LibGit2.init(path::AbstractString, bare::Bool=false) -> GitRepo

Opens a new git repository at `path`. If `bare` is `false`,
Open a new git repository at `path`. If `bare` is `false`,
the working tree will be created in `path/.git`. If `bare`
is `true`, no working directory will be created.
"""
Expand Down Expand Up @@ -80,10 +80,26 @@ function headname(repo::GitRepo)
end
end

"""
isbare(repo::GitRepo) -> Bool

Determine if `repo` is bare. Suppose the top level directory of `repo` is `DIR`.
A non-bare repository is one in which the git directory (see [`gitdir`](@ref)) is
`DIR/.git`, and the working tree can be checked out. A bare repository is one in
which all of git's administrative files are simply in `DIR`, rather than "hidden"
in the `.git` subdirectory. This means that there is nowhere to check out the working
tree, and no tracking information for remote branches or configurations is present.
"""
function isbare(repo::GitRepo)
return ccall((:git_repository_is_bare, :libgit2), Cint, (Ptr{Void},), repo.ptr) == 1
end

"""
isattached(repo::GitRepo) -> Bool

Determine if `repo` is detached - that is, whether its HEAD points to a commit
(detached) or whether HEAD points to a branch tip (attached).
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, perhaps "whether its HEAD points to ... or whether its HEAD points to ..." or simplify to "whether its HEAD points to ... or to ..."?

Copy link
Contributor

Choose a reason for hiding this comment

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

this would be better, yes - was not addressed

"""
function isattached(repo::GitRepo)
ccall((:git_repository_head_detached, :libgit2), Cint, (Ptr{Void},), repo.ptr) != 1
end
Expand Down Expand Up @@ -150,7 +166,7 @@ revparseid(repo::GitRepo, spec) = GitHash(GitUnknownObject(repo, spec))
"""
LibGit2.gitdir(repo::GitRepo)

Returns the location of the "git" files of `repo`:
Return the location of the "git" files of `repo`:

- for normal repositories, this is the location of the `.git` folder.
- for bare repositories, this is the location of the repository itself.
Expand All @@ -165,8 +181,8 @@ end
"""
LibGit2.workdir(repo::GitRepo)

The location of the working directory of `repo`. This will throw an error for bare
repositories.
Return the location of the working directory of `repo`.
This will throw an error for bare repositories.

!!! note

Expand All @@ -186,7 +202,7 @@ end
"""
LibGit2.path(repo::GitRepo)

The base file path of the repository `repo`.
Return the base file path of the repository `repo`.

- for normal repositories, this will typically be the parent directory of the ".git"
directory (note: this may be different than the working directory, see `workdir` for
Expand Down Expand Up @@ -371,7 +387,7 @@ end
"""
LibGit2.remotes(repo::GitRepo)

Returns a vector of the names of the remotes of `repo`.
Return a vector of the names of the remotes of `repo`.
"""
function remotes(repo::GitRepo)
sa_ref = Ref(StrArrayStruct())
Expand Down