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

Package system on libgit2 #11196

Merged
merged 90 commits into from
Sep 29, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
865c87c
changing `installed` based to support `libgit2`
wildart May 5, 2015
851c053
merged installed & dependents into `Read`, moved `libgit2` calls into…
wildart May 5, 2015
12a525c
removed `Git` module calls from `Read`
wildart May 5, 2015
b2be2d7
changed string type
wildart May 5, 2015
9c88dbc
renamed to 'libgit2'
wildart May 6, 2015
cdf28d4
fixed to AbstractString
wildart May 7, 2015
c57ec72
added libgit2 error handling
wildart May 8, 2015
7140141
write to repo configuration value with any accepted type
wildart May 8, 2015
f836a71
added `clone` & `fetch`, updated 'Dir' and `Cache`
wildart May 8, 2015
61ba8f0
switching to `Ref` type
wildart May 8, 2015
ba591fe
changed incorrect types & syntax
wildart May 8, 2015
efb5bba
working on `Generate`
wildart May 9, 2015
bb40811
fixed changed api
wildart May 9, 2015
4ca8175
construct type pragmatically
wildart May 9, 2015
25a7d0a
added `with_libgit2` helper function
wildart May 9, 2015
3516046
package generator works!!!
wildart May 10, 2015
3198519
added default value to GitConfig 'get' to prevent exceptions
wildart May 10, 2015
3305ed6
added anyobject type and `checkout` functions
wildart May 10, 2015
071a872
no more `git` in Write
wildart May 10, 2015
87e7fbf
fixed `revparse`, `isdirty` & errors in `Write`
wildart May 10, 2015
409bb27
improved git types description
wildart May 10, 2015
9802b85
transitioned Entry.add
wildart May 11, 2015
e2c1a38
transitioned Entry.clone
wildart May 11, 2015
ff9b5d6
GitError is Exception subclass
wildart May 11, 2015
f55de93
fixed `need_update`, `head_oid`, `revparse`, `CHECKOUT_NONE`, `Checko…
wildart May 11, 2015
6dedbb2
transitioned Entry: `free` & `pin`
wildart May 11, 2015
8fbf905
refactored error handling
wildart May 13, 2015
e4ac8bd
error fix: nonexistent directory case, cannot create empty wrapper
wildart May 13, 2015
8ff8a25
made options structures immutable with convinient constructors
wildart May 13, 2015
273ecfa
rewrote Write module: changed resource management and commit checkout.
wildart May 13, 2015
c1179e7
added proper `checkout` & `branch` functions
wildart May 13, 2015
67435f6
added tests for `libgit2`
wildart May 16, 2015
740194a
removed unnecessary `rethrow` calls
wildart May 16, 2015
30688dc
transitioned `checkout`, `free`, `update`, `register`
wildart May 17, 2015
331f8c2
switched to https
wildart May 17, 2015
dcac546
added `gitdir` (location of repo '.git') and `path` (repo location)
wildart May 17, 2015
52d72cb
import Base for `finalize`s
wildart May 17, 2015
3e957e8
transitioned `tag` & `register`
wildart May 17, 2015
3ff4628
fixed `get` with default for GitConfig
wildart May 18, 2015
c9d04e2
fixed errors, set to run only pkg & libgit2 tests
wildart May 18, 2015
d409e13
added PkgError exception
wildart May 19, 2015
3335bf7
added licence line
wildart May 19, 2015
b5efeef
fixed GitHub saved token retrieval & PkgError visibility
wildart May 19, 2015
efde7ed
added `push`, transitioned `pull_request`
wildart May 19, 2015
f1b5694
fixed import error
wildart May 20, 2015
c1298e8
added `revcount` for counting differences
wildart May 20, 2015
6943209
fixed exceptions in tests
wildart May 20, 2015
8612798
speedup `prefetch` call
wildart May 21, 2015
9016b11
refactored GitConfig methods
wildart May 21, 2015
21fcc2c
removed prefix from `finalize` calls
wildart May 21, 2015
2d456ab
newline at end of file
wildart May 21, 2015
327e989
No more `Git`!
wildart May 23, 2015
307aa8b
partial fix for #11580
wildart Jun 6, 2015
70963a9
adopting CString & refactoring
wildart Jun 27, 2015
f8b0dec
added prototype of git repl
wildart Jun 28, 2015
c0d59a0
added `clone` & `init` command
wildart Jul 2, 2015
09406ad
refactoring commit message call
wildart Jul 8, 2015
50b81f6
rebased, moved `libgit2` to `base`, updated to 0.23 & tests
testurser Jul 9, 2015
c9fcd0b
fixed repl tests
wildart Jul 9, 2015
39aa02b
tuple-based Oid
testurser Jul 9, 2015
8b5dd78
added `Oid` tests, modified `free` with tuple parameters,
testurser Jul 10, 2015
5a4aad0
fixed: string value retrieval from config, resource management in tests
wildart Jul 10, 2015
c254abb
fixed 0.23 compatibility errors, added more commands to git-repl
wildart Jul 13, 2015
f58f762
used new enums, changed location of GITHUB_REGEX, exported PkgError
wildart Jul 13, 2015
fad9263
switch to release build for windows
wildart Jul 14, 2015
93af677
diff & rebase update to v0.23, error fixes
wildart Jul 27, 2015
1347d68
added callbacks, updated push & publish
wildart Jul 28, 2015
25778f7
merge overhaul, added credential & fetchhead callbacks, small fixes &…
wildart Aug 2, 2015
9f3bad9
added extended repo open, ported Base.url
wildart Aug 2, 2015
5fa68d5
fixed Pkg.pull_request, suppress backtrace PkgError & code cleanup
wildart Aug 2, 2015
f3301fb
switch GitRepo to GitRevWalker
wildart Aug 2, 2015
9690fa6
added to GitREPL: branch & tag
wildart Aug 2, 2015
c5350e5
added `commit` to Git REPL & fixed commands help info
wildart Aug 2, 2015
243e1a8
fix Git REPL `commit` output
wildart Aug 2, 2015
7aa333b
added `checkout` to Git REPL
wildart Aug 2, 2015
2f8c7b7
fixed remote branch name
wildart Aug 2, 2015
2853db0
reomoved Git module and its tests
wildart Aug 2, 2015
0ccfdfe
fix error message & add all tests
wildart Aug 3, 2015
4beb9af
fixed cache update, remove redundant `chomp` call from Git REPL `comm…
wildart Aug 3, 2015
7e9caae
fixed: `tag` requirements creation, empty callbacks
wildart Aug 8, 2015
78929ad
fixed tests
wildart Sep 14, 2015
29004a4
removed Git REPL
wildart Sep 14, 2015
116bb4c
fixed bad rebase commit of `inbase`
wildart Sep 14, 2015
b0f07a8
added: tree entry type, tree walker, blob lookup, some refinements
wildart Sep 23, 2015
80f0db7
Union() => Union{}
wildart Sep 23, 2015
0663672
fixed comparisons to `nothing`
wildart Sep 25, 2015
509e4b2
renamed module `GitConst` to `Consts`, added support of ssh-agent
wildart Sep 29, 2015
11f08b5
returned `Pkg.Git` module
wildart Sep 29, 2015
d18efae
fix deprecation warning
jakebolewski Sep 29, 2015
35cd85f
add error branch test for package availablity
jakebolewski Sep 29, 2015
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
Prev Previous commit
Next Next commit
transitioned checkout, free, update, register
added merge functionality
  • Loading branch information
wildart authored and jakebolewski committed Sep 29, 2015
commit 30688dc82adc2c9810bcfbb9ed2712f0edea09ec
4 changes: 2 additions & 2 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Dir

import ..Pkg: DEFAULT_META, META_BRANCH
import ..LibGit2, ..LibGit2.with_libgit2
import ..LibGit2, ..LibGit2.with

const DIR_NAME = ".julia"

Expand Down Expand Up @@ -46,7 +46,7 @@ function init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRA
temp_dir = mktempdir(dir)
Base.cd(temp_dir) do
info("Cloning METADATA from $meta")
with_libgit2(LibGit2.clone(meta, "METADATA", branch = branch)) do metadata_repo
with(LibGit2.clone(meta, "METADATA", branch = branch)) do metadata_repo
LibGit2.set_remote_url(metadata_repo, meta)
end
touch("REQUIRE")
Expand Down
82 changes: 46 additions & 36 deletions base/pkg/entry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,22 @@ function clone(url_or_pkg::AbstractString)
clone(url,pkg)
end

function _checkout(pkg::AbstractString, what::AbstractString, merge::Bool=false, pull::Bool=false, branch::Bool=false)
Git.transact(dir=pkg) do #TODO: finish restore()
Git.dirty(dir=pkg) && error("$pkg is dirty, bailing")
branch ? Git.run(`checkout -q -B $what -t origin/$what`, dir=pkg) : Git.run(`checkout -q $what`, dir=pkg)
merge && Git.run(`merge -q --ff-only $what`, dir=pkg)
if pull
info("Pulling $pkg latest $what...")
Git.run(`pull -q --ff-only`, dir=pkg)
end
resolve()
end
end

function checkout(pkg::AbstractString, branch::AbstractString, merge::Bool, pull::Bool)
ispath(pkg,".git") || error("$pkg is not a git repo")
info("Checking out $pkg $branch...")
_checkout(pkg,branch,merge,pull,true)
LibGit2.with(LibGit2.GitRepo, pkg) do r
LibGit2.transact(r) do repo
LibGit2.isdirty(repo) && error("$pkg is dirty, bailing")
LibGit2.branch!(repo, branch, track=LibGit2.GitConst.REMOTE_ORIGIN)
merge && LibGit2.merge!(repo) # merge changes
if pull
info("Pulling $pkg latest $branch...")
LibGit2.fetch(repo)
LibGit2.merge!(repo)
end
resolve()
end
end
end

function free(pkg::AbstractString)
Expand All @@ -245,7 +244,11 @@ function free(pkg::AbstractString)
for ver in vers
sha1 = avail[ver].sha1
LibGit2.iscommit(sha1, repo) || continue
return _checkout(pkg, sha1)
return LibGit2.transact(repo) do r
LibGit2.isdirty(repo) && error("$pkg is dirty, bailing")
LibGit2.checkout!(repo, sha1)
resolve()
end
end
isempty(Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a)=avail])) && continue
error("can't find any registered versions of $pkg to checkout")
Expand Down Expand Up @@ -306,18 +309,22 @@ end
function update(branch::AbstractString)
info("Updating METADATA...")
cd("METADATA") do
if Git.branch() != branch
Git.dirty() && error("METADATA is dirty and not on $branch, bailing")
Git.attached() || error("METADATA is detached not on $branch, bailing")
Git.run(`fetch -q --all`)
Git.run(`checkout -q HEAD^0`)
Git.run(`branch -f $branch refs/remotes/origin/$branch`)
Git.run(`checkout -q $branch`)
with(GitRepo, ".") do repo
with(LibGit2.head(repo)) do h
if LibGit2.branch(h) != branch
LibGit2.isdirty(repo) && error("METADATA is dirty and not on $branch, bailing")
LibGit2.isattached(repo) || error("METADATA is detached not on $branch, bailing")
LibGit2.fetch(repo)
LibGit2.checkout_head(repo)
LibGit2.branch!(repo, branch, track="refs/remotes/origin/$branch")
LibGit2.merge!(repo)
end
end
end
# TODO: handle merge conflicts
Base.withenv("GIT_MERGE_AUTOEDIT"=>"no") do
Git.run(`pull --rebase -q`, out=DevNull)
end
# Base.withenv("GIT_MERGE_AUTOEDIT"=>"no") do
# Git.run(`pull --rebase -q`, out=DevNull)
# end
end
avail = Read.available()
# this has to happen before computing free/fixed
Expand All @@ -332,17 +339,17 @@ function update(branch::AbstractString)
fixed = Read.fixed(avail,instd)
for (pkg,ver) in fixed
ispath(pkg,".git") || continue
begin
if Git.attached(dir=pkg) && !Git.dirty(dir=pkg)
with(GitRepo, pkg) do repo
if LibGit2.isattached(repo) && !LibGit2.isdirty(repo)
info("Updating $pkg...")
@recover begin
Git.run(`fetch -q --all`, dir=pkg)
Git.success(`pull -q --ff-only`, dir=pkg) # suppress output
LibGit2.fetch(repo)
LibGit2.merge!(repo)
end
end
if haskey(avail,pkg)
Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a)=avail[pkg]])
end
end
if haskey(avail,pkg)
Cache.prefetch(pkg, Read.url(pkg), [a.sha1 for (v,a)=avail[pkg]])
end
end
info("Computing changes...")
Expand Down Expand Up @@ -577,10 +584,13 @@ function register(pkg::AbstractString, url::AbstractString)
end

function register(pkg::AbstractString)
Git.success(`config remote.origin.url`, dir=pkg) ||
error("$pkg: no URL configured")
url = Git.readchomp(`config remote.origin.url`, dir=pkg)
register(pkg,Git.normalize_url(url))
url = LibGit2.with(LibGit2.GitRepo, pkg) do repo
LibGit2.with(LibGit2.GitConfig, repo) do cfg
LibGit2.get(cfg, "remote.origin.url", "")
end
end
isempty(url) || error("$pkg: no URL configured")
register(pkg, LibGit2.normalize_url(url))
end

function isrewritable(v::VersionNumber)
Expand Down
34 changes: 13 additions & 21 deletions base/pkg/libgit2.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module LibGit2

export with_libgit2, with, with_warn
export with, with_warn
export GitRepo, GitConfig, GitIndex

const GITHUB_REGEX =
Expand All @@ -19,6 +19,7 @@ include("libgit2/walker.jl")
include("libgit2/remote.jl")
include("libgit2/strarray.jl")
include("libgit2/index.jl")
include("libgit2/merge.jl")

immutable State
head::Oid
Expand All @@ -39,14 +40,8 @@ end

"""Return HEAD Oid as string"""
function head(pkg::AbstractString)
head_id =""
repo = GitRepo(pkg)
try
head_id = string(head_oid(repo))
catch err
warn(err)
finally
finalize(repo)
with(GitRepo, pkg) do repo
string(head_oid(repo))
end
end

Expand Down Expand Up @@ -96,7 +91,6 @@ function isdiff(repo::GitRepo, treeish::AbstractString, paths::AbstractString=""
result = c > 0
finalize(diff)
catch err
warn(err)
result = true
finally
!emptypathspec && finalize(sa)
Expand Down Expand Up @@ -228,7 +222,7 @@ function branch!(repo::GitRepo, branch_name::AbstractString,
end
end
try
if !isempty(track) # setup tracking
if !isempty(track) # setup tracking #TODO: what is branch tracks other then "origin" remote
with(GitConfig, repo) do cfg
set!(cfg, "branch.$branch_name.remote", GitConst.REMOTE_ORIGIN)
set!(cfg, "branch.$branch_name.merge", name(branch_ref))
Expand All @@ -252,15 +246,13 @@ function checkout!(repo::GitRepo, commit::AbstractString = "";
# grab head name
head_name = GitConst.HEAD_FILE
try
head_ref = head(repo)
head_name = shortname(head_ref)
# if it is HEAD use short OID instead
if head_name == GitConst.HEAD_FILE
head_name = string(Oid(head_ref))
with(head(repo)) do head_ref
head_name = shortname(head_ref)
# if it is HEAD use short OID instead
if head_name == GitConst.HEAD_FILE
head_name = string(Oid(head_ref))
end
end
finalize(head_ref)
catch err
warn(err)
end

# search for commit to get a commit object
Expand Down Expand Up @@ -322,7 +314,7 @@ function reset!(repo::GitRepo, committish::AbstractString, pathspecs::AbstractSt
end

""" git reset [--soft | --mixed | --hard] <commit> """
function reset!(repo::GitRepo, commit::Oid, mode::Cint = GitConst.GIT_RESET_MIXED)
function reset!(repo::GitRepo, commit::Oid, mode::Cint = GitConst.RESET_MIXED)

obj = get(GitAnyObject, repo, commit)
obj == nothing && return
Expand Down Expand Up @@ -378,7 +370,7 @@ function restore(s::State, repo::GitRepo)

read_tree!(idx, s.index) # restore index
end
reset!(repo, s.head, GitConst.GIT_RESET_SOFT) # restore head
reset!(repo, s.head, GitConst.RESET_SOFT) # restore head
end

function transact(f::Function, repo::GitRepo)
Expand Down
27 changes: 16 additions & 11 deletions base/pkg/libgit2/const.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ module GitConst

const MERGE_TREE_FIND_RENAMES = Cint(1) << Cint(0)

const MERGE_FILE_FAVOR_NORMAL = Cint(0)
const MERGE_FILE_FAVOR_OURS = Cint(1)
const MERGE_FILE_FAVOR_THEIRS = Cint(2)
const MERGE_FILE_FAVOR_UNION = Cint(3)

const MERGE_AUTOMERGE_NORMAL = Cint(0)
const MERGE_AUTOMERGE_FAVOR_OURS = Cint(1)
const MERGE_AUTOMERGE_FAVOR_THEIRS = Cint(2)
Expand All @@ -180,15 +185,15 @@ module GitConst
const MERGE_NO_FASTFORWARD = Cint(1)
const MERGE_FASTFORWARD_ONLY = Cint(2)

const GIT_MERGE_ANALYSIS_NONE = 0,
const GIT_MERGE_ANALYSIS_NORMAL = (1 << 0)
const GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1)
const GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2)
const GIT_MERGE_ANALYSIS_UNBORN = (1 << 3)
const MERGE_ANALYSIS_NONE = 0,
const MERGE_ANALYSIS_NORMAL = (1 << 0)
Copy link
Member

Choose a reason for hiding this comment

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

extra parens ... why are these constants Int, unlike all the others?

const MERGE_ANALYSIS_UP_TO_DATE = (1 << 1)
const MERGE_ANALYSIS_FASTFORWARD = (1 << 2)
const MERGE_ANALYSIS_UNBORN = (1 << 3)

const GIT_MERGE_PREFERENCE_NONE = 0
const GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0)
const GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1)
const MERGE_PREFERENCE_NONE = 0
const MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0)
const MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1)

const DIRECTION_FETCH = Cint(0)
const DIRECTION_PUSH = Cint(1)
Expand All @@ -211,7 +216,7 @@ module GitConst
const GIT_REPOSITORY_STATE_APPLY_MAILBOX = Cint(8)
const GIT_REPOSITORY_STATE_APPLY_MAILBOX_OR_REBASE = Cint(9)

const GIT_RESET_SOFT = Cint(1) # Move the head to the given commit
const GIT_RESET_MIXED = Cint(2) # SOFT plus reset index to the commit
const GIT_RESET_HARD = Cint(3) # MIXED plus changes in working tree discarded
const RESET_SOFT = Cint(1) # Move the head to the given commit
const RESET_MIXED = Cint(2) # SOFT plus reset index to the commit
const RESET_HARD = Cint(3) # MIXED plus changes in working tree discarded
end
Copy link
Member

Choose a reason for hiding this comment

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

newline

69 changes: 69 additions & 0 deletions base/pkg/libgit2/merge.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function GitAnnotated(repo::GitRepo, commit_id::Oid)
ann_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
@check ccall((:git_annotated_commit_lookup, :libgit2), Cint,
(Ptr{Ptr{Void}}, Ptr{Void}, Ptr{Oid}),
ann_ptr_ptr, repo.ptr, commit_id)
return GitAnnotated(ann_ptr_ptr[])
end

function GitAnnotated(repo::GitRepo, ref::GitReference)
ann_ref_ref = Ref{Ptr{Void}}(C_NULL)
@check ccall((:git_annotated_commit_from_ref, :libgit2), Cint,
(Ptr{Ptr{Void}}, Ptr{Void}, Ptr{Void}),
ann_ref_ref, repo.ptr, ref.ptr)
return GitAnnotated(ann_ref_ref[])
end

function merge_analysis(repo::GitRepo, ann::GitAnnotated)
analysis = Ref{Cint}(0)
preference = Ref{Cint}(0)
@check ccall((:git_merge_analysis, :libgit2), Cint,
(Ptr{Cint}, Ptr{Cint}, Ptr{Void}, Ptr{Ptr{Void}}, Csize_t),
analysis, preference, repo.ptr, Ref{Ptr{Void}}(ann.ptr), 1)
return analysis[], preference[]
end

function commit(ann::GitAnnotated)
return Oid(ccall((:git_annotated_commit_id, :libgit2), Ptr{Oid}, (Ptr{Void},), ann.ptr))
end

""" Merge changes into current head """
function merge!(repo::GitRepo; fast_forward::Bool=false)
# get head annotated upstream reference
with(head(repo)) do hr
with(upstream(hr)) do hur
with(GitAnnotated(repo, hur)) do hua
ma, mp = merge_analysis(repo, hua)
(ma & GitConst.MERGE_ANALYSIS_UP_TO_DATE == GitConst.MERGE_ANALYSIS_UP_TO_DATE) && return
if (ma & GitConst.MERGE_ANALYSIS_FASTFORWARD == GitConst.MERGE_ANALYSIS_FASTFORWARD)
# do fastforward: checkout tree and update branch references
# hur_oid = Oid(hur)
# with(get(GitCommit, repo, hur_oid)) do cmt
# checkout_tree(repo, cmt)
# end
# target!(hr, hur_oid, msg="pkg.libgit2.megre!: fastforward $(name(hur)) into $(name(hr))")
# head!(repo, hur, msg="--fastforward")

hur_oid = Oid(hur)
target!(hr, hur_oid, msg="pkg.libgit2.megre!: fastforward $(name(hur)) into $(name(hr))")
reset!(repo, hur_oid, GitConst.RESET_HARD)
elseif (ma & GitConst.MERGE_ANALYSIS_NORMAL == GitConst.MERGE_ANALYSIS_NORMAL)
if fast_forward
warn("Fastforward merge is not possible. Abort merging.")
return
end
merge_opts = MergeOptionsStruct()
checkout_opts = CheckoutOptionsStruct(checkout_strategy = GitConst.CHECKOUT_SAFE)
@check ccall((:git_merge, :libgit2), Cint,
(Ptr{Void}, Ptr{Ptr{Void}}, Csize_t, Ptr{MergeOptionsStruct}, Ptr{CheckoutOptionsStruct}),
repo.ptr, Ref{Ptr{Void}}(hua.ptr), 1, Ref(merge_opts), Ref(checkout_opts))
cleanup(repo)
info("Review and commit merged changes.")
else
warn("Unknown merge analysis result. Merging is not possible.")
end
end
end
end
end

5 changes: 2 additions & 3 deletions base/pkg/libgit2/oid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const OID_RAWSZ = 20
const OID_HEXSZ = OID_RAWSZ * 2
const OID_MINPREFIXLEN = 4

#TODO: The Oid generated code should now use an immutable type that wraps an ntuple of length 20
# immutable Oid
# id1::UInt8
# id2::UInt8
Expand Down Expand Up @@ -54,9 +55,7 @@ end

function Oid(ref::GitReference)
isempty(ref) && return Oid()

typ = ccall((:git_reference_type, :libgit2), Cint, (Ptr{Void},), ref.ptr)
typ != 1 && return Oid()
reftype(ref) != GitConst.REF_OID && return Oid()
oid_ptr = ccall((:git_reference_target, :libgit2), Ptr{UInt8}, (Ptr{Void},), ref.ptr)
oid_ptr == C_NULL && return Oid()
return Oid(oid_ptr)
Expand Down
Loading