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

Document merge base and GitAnnotated #23437

Merged
merged 1 commit into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions base/libgit2/merge.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

"""
GitAnnotated(repo::GitRepo, commit_id::GitHash)
GitAnnotated(repo::GitRepo, ref::GitReference)
GitAnnotated(repo::GitRepo, fh::FetchHead)
GitAnnotated(repo::GitRepo, comittish::AbstractString)

An annotated git commit carries with it information about how it was looked up and
why, so that rebase or merge operations have more information about the context of
the commit. Conflict files contain information about the source/target branches in
the merge which are conflicting, for instance. An annotated commit can refer to the
tip of a remote branch, for instance when a [`FetchHead`](@ref) is passed, or to a
branch head described using `GitReference`.
Copy link
Member

Choose a reason for hiding this comment

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

I really like this description! It would be good to mention what the GitAnnotated constructor does or returns though. It gives you a GitAnnotated, which is an annotated commit object, 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.

Yes. I'm glad the description is useful. It seemed clear to me that these are c-tors but maybe not...

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I guess it's fine as-is.

"""
function GitAnnotated(repo::GitRepo, commit_id::GitHash)
ann_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
@check ccall((:git_annotated_commit_lookup, :libgit2), Cint,
Expand Down Expand Up @@ -140,6 +153,12 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated}, fastforward::Bool;
return merge_result
end

"""
merge_base(repo::GitRepo, one::AbstractString, two::AbstractString) -> GitHash

Find a merge base (a common ancestor) between the commits `one` and `two`.
`one` and `two` may both be in string form. Return the `GitHash` of the merge base.
"""
function merge_base(repo::GitRepo, one::AbstractString, two::AbstractString)
oid1_ptr = Ref(GitHash(one))
oid2_ptr = Ref(GitHash(two))
Expand Down
1 change: 1 addition & 0 deletions doc/src/devdocs/libgit2.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Base.LibGit2.fetch
Base.LibGit2.fetchheads
Base.LibGit2.fetch_refspecs
Base.LibGit2.fetchhead_foreach_cb
Base.LibGit2.merge_base
Base.LibGit2.merge!(::Base.LibGit2.GitRepo; ::Any...)
Base.LibGit2.ffmerge!
Base.LibGit2.fullname
Expand Down