Skip to content

Commit

Permalink
fix for API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Jun 5, 2018
1 parent 37bb61b commit 8e3cfe7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
40 changes: 27 additions & 13 deletions stdlib/LibGit2/src/config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"""
GitConfig(path::AbstractString, level::Consts.GIT_CONFIG=Consts.CONFIG_LEVEL_APP, force::Bool=false)
Create a new `GitConfig` by loading configuration information from the file at
`path`. See [`addfile`](@ref) for more information about the `level` and `force`
options.
Create a new `GitConfig` by loading configuration information from the file at `path`. See
[`addfile`](@ref) for more information about the `level`, `repo` and `force` options.
"""
function GitConfig(path::AbstractString,
level::Consts.GIT_CONFIG = Consts.CONFIG_LEVEL_APP,
repo::Union{GitRepo, Nothing}=nothing,
force::Bool=false)
# create new config object
cfg_ptr_ptr = Ref{Ptr{Cvoid}}(C_NULL)
@check ccall((:git_config_new, :libgit2), Cint, (Ptr{Ptr{Cvoid}},), cfg_ptr_ptr)
cfg = GitConfig(cfg_ptr_ptr[])
try
addfile(cfg, path, level, force)
addfile(cfg, path, level, repo, force)
catch ex
close(cfg)
rethrow(ex)
Expand Down Expand Up @@ -65,22 +65,36 @@ function GitConfig(level::Consts.GIT_CONFIG = Consts.CONFIG_LEVEL_DEFAULT)
end

"""
addfile(cfg::GitConfig, path::AbstractString, level::Consts.GIT_CONFIG=Consts.CONFIG_LEVEL_APP, force::Bool=false)
addfile(cfg::GitConfig, path::AbstractString,
level::Consts.GIT_CONFIG=Consts.CONFIG_LEVEL_APP,
repo::Union{GitRepo, Nothing} = nothing,
force::Bool=false)
Add an existing git configuration file located at `path` to the current
`GitConfig` `cfg`. If the file does not exist, it will be created.
`level` sets the git configuration priority level and is determined by
[`Consts.GIT_CONFIG`](@ref). If `force` is `false` and a configuration for
the given priority level already exists, `addfile` will error. If `force` is
`true`, the existing configuration will be replaced by the one in the file at
`path`.
- `level` sets the git configuration priority level and is determined by
[`Consts.GIT_CONFIG`](@ref).
- `repo` is an optional repository to allow parsing of conditional includes.
- If `force` is `false` and a configuration for the given priority level already exists,
`addfile` will error. If `force` is `true`, the existing configuration will be replaced by
the one in the file at `path`.
"""
function addfile(cfg::GitConfig, path::AbstractString,
level::Consts.GIT_CONFIG = Consts.CONFIG_LEVEL_APP,
repo::Union{GitRepo, Nothing} = nothing,
force::Bool=false)
@check ccall((:git_config_add_file_ondisk, :libgit2), Cint,
(Ptr{Ptr{Cvoid}}, Cstring, Cint, Cint),
cfg.ptr, path, Cint(level), Cint(force))
@static if LibGit2.VERSION >= v"0.27.0"
@check ccall((:git_config_add_file_ondisk, :libgit2), Cint,
(Ptr{Ptr{Cvoid}}, Cstring, Cint, Ptr{Cvoid}, Cint),
cfg.ptr, path, Cint(level), isa(repo, GitRepo) ? repo.ptr : C_NULL, Cint(force))
else
repo === nothing || error("repo argument is not supported in this version of LibGit2")
@check ccall((:git_config_add_file_ondisk, :libgit2), Cint,
(Ptr{Ptr{Cvoid}}, Cstring, Cint, Cint),
cfg.ptr, path, Cint(level), Cint(force))
end
end

function get(::Type{<:AbstractString}, c::GitConfig, name::AbstractString)
Expand Down
8 changes: 8 additions & 0 deletions stdlib/LibGit2/src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Matches the [`git_time`](https://libgit2.github.com/libgit2/#HEAD/type/git_time)
struct TimeStruct
time::Int64 # time in seconds from epoch
offset::Cint # timezone offset in minutes
@static if LibGit2.VERSION >= v"0.27.0"
sign::Cchar
end
end

"""
Expand Down Expand Up @@ -830,6 +833,8 @@ The fields represent:
* `flags`: flags for controlling any callbacks used in a status call.
* `pathspec`: an array of paths to use for path-matching. The behavior of the path-matching
will vary depending on the values of `show` and `flags`.
* The `baseline` is the tree to be used for comparison to the working directory and
index; defaults to HEAD.
"""
@kwdef struct StatusOptions
version::Cuint = 1
Expand All @@ -839,6 +844,9 @@ The fields represent:
Consts.STATUS_OPT_RENAMES_HEAD_TO_INDEX |
Consts.STATUS_OPT_SORT_CASE_SENSITIVELY
pathspec::StrArrayStruct
@static if LibGit2.VERSION >= v"0.27.0"
baseline::Ptr{Cvoid}
end
end

"""
Expand Down

0 comments on commit 8e3cfe7

Please sign in to comment.