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

Doc the fields of some libgit2 types #22543

Merged
merged 8 commits into from
Jul 8, 2017
Merged
Changes from 6 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
45 changes: 45 additions & 0 deletions base/libgit2/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,33 @@ end
Options for connecting through a proxy.

Matches the [`git_proxy_options`](https://libgit2.github.com/libgit2/#HEAD/type/git_proxy_options) struct.

The fields represent:
* `version`: version of the struct in use, in case this changes later. For now, always `1`.
* `proxytype`: an `enum` for the type of proxy to use.
Defined in [`git_proxy_t`](https://libgit2.github.com/libgit2/#HEAD/type/git_proxy_t).
Copy link
Contributor

Choose a reason for hiding this comment

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

does the Julia enum use the same spellings? worth spelling out the qualified Julia-side enum name those would be specified as

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - look ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make check-whitespace passed again locally

Copy link
Contributor

Choose a reason for hiding this comment

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

looks great, though if it's not exported, maybe qualify it with the module name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you're willing to wait, I hope to do another PR later tonight with examples that would show that it's not exported?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example added!

The corresponding Julia enum is [`GIT_PROXY`](@ref) and has values:
- `PROXY_NONE`: do not attempt the connection through a proxy.
- `PROXY_AUTO`: attempt to figure out the proxy configuration from the git configuration.
- `PROXY_SPECIFIED`: connect using the URL given in the `url` field of this struct.
Default is to auto-detect the proxy type.
* `url`: the URL of the proxy.
* `credential_cb`: a pointer to a callback function which will be called if the remote
Copy link
Contributor

Choose a reason for hiding this comment

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

on the julia side this is just a function input, not a pointer right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, credential_cb::Ptr{Void}

Copy link
Contributor

Choose a reason for hiding this comment

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

do you need to do something with cfunction then to pass a julia function to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think you have to do something much like the stuff in base/libgit2/callbacks.jl

requires authentication to connect.
* `certificate_cb`: a pointer to a callback function which will be called if certificate
verification fails. This lets the user decide whether or not to keep connecting. If
the function returns `1`, connecting will be allowed. If it returns `0`, the connection
will not be allowed. A negative value can be used to return errors.
* `payload`: the payload to be provided to the two callback functions.

# Examples
```julia-repl
julia> fo = LibGit2.FetchOptions();

julia> fo.proxy_opts = LibGit2.ProxyOptions(url=Cstring("https://my_proxy_url.com"))

julia> fetch(remote, "master", options=fo)
```
"""
@kwdef struct ProxyOptions
version::Cuint = 1
Expand Down Expand Up @@ -287,6 +314,12 @@ end
LibGit2.DescribeFormatOptions

Matches the [`git_describe_format_options`](https://libgit2.github.com/libgit2/#HEAD/type/git_describe_format_options) struct.

The fields represent:
* `version`: version of the struct in use, in case this changes later. For now, always `1`.
* `abbreviated_size`: lower bound on the size of the abbreviated `GitHash` to use, defaulting to `7`.
* `always_use_long_format`: set to `1` to use the long format for strings even if a short format can be used.
* `dirty_suffix`: if set, this will be appended to the end of the description string if the [`workdir`](@ref) is dirty.
"""
@kwdef struct DescribeFormatOptions
version::Cuint = 1
Expand All @@ -300,6 +333,18 @@ end

Description of one side of a delta.
Matches the [`git_diff_file`](https://libgit2.github.com/libgit2/#HEAD/type/git_diff_file) struct.

The fields represent:
* `id`: the [`GitHash`](@ref) of the item in the diff. If the item is empty on this
side of the diff (for instance, if the diff is of the removal of a file), this will
be `GitHash(0)`.
* `path`: a `NULL` terminated path to the item relative to the working directory of the repository.
* `size`: the size of the item in bytes.
* `flags`: a combination of the [`git_diff_flag_t`](https://libgit2.github.com/libgit2/#HEAD/type/git_diff_flag_t)
flags. The `i`th bit of this integer sets the `i`th flag.
* `mode`: the [`stat`](@ref) mode for the item.
* `id_abbrev`: only present in LibGit2 versions newer than or equal to `0.25.0`.
The length of the `id` field when converted using [`hex`](@ref). Usually equal to `GIT_OID_HEXSZ`.
Copy link
Contributor

Choose a reason for hiding this comment

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

is GIT_OID_HEXSZ a C name or the Julia enum name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For us it's OID_HEXSZ. I'll update.

"""
struct DiffFile
id::GitHash
Expand Down