Skip to content

Commit

Permalink
docs for GitHash, remove unnecessary error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Jan 21, 2017
1 parent 0515e73 commit ed65d4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ See `git diff-index <treeish> [-- <path>]`
"""
function isdiff(repo::GitRepo, treeish::AbstractString, paths::AbstractString=""; cached::Bool=false)
tree_oid = revparseid(repo, "$treeish^{tree}")
iszero(tree_oid) && error("invalid treeish $treeish") # this can be removed by #20104
result = false
tree = GitTree(repo, tree_oid)
try
Expand Down
18 changes: 16 additions & 2 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@ const OID_MINPREFIXLEN = 4

abstract AbstractGitHash

"""
GitHash
A git object identifier, based on the sha-1 hash. It is a $OID_RAWSZ byte string
($OID_HEXSZ hex digits) used to identify a `GitObject` in a repository.
"""
immutable GitHash <: AbstractGitHash
val::NTuple{OID_RAWSZ, UInt8}
GitHash(val::NTuple{OID_RAWSZ, UInt8}) = new(val)
end
GitHash() = GitHash(ntuple(i->zero(UInt8), OID_RAWSZ))

"""
GitShortHash
This is a shortened form of `GitHash`, which can be used to identify a git object when it
is unique.
Internally it is stored as two fields: a full-size `GitHash` (`hash`) and a length (`len`). Only the initial `len` hex digits of `hash` are used.
"""
immutable GitShortHash <: AbstractGitHash
hash::GitHash
len::Csize_t
hash::GitHash # underlying hash: unused digits are ignored
len::Csize_t # length in hex digits
end


Expand Down

0 comments on commit ed65d4d

Please sign in to comment.