Skip to content

Commit 149d108

Browse files
authored
Merge pull request #23437 from JuliaLang/ksh/docmerge2
Document merge base and GitAnnotated
2 parents f82fc0f + 50e7208 commit 149d108

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

base/libgit2/merge.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
"""
4+
GitAnnotated(repo::GitRepo, commit_id::GitHash)
5+
GitAnnotated(repo::GitRepo, ref::GitReference)
6+
GitAnnotated(repo::GitRepo, fh::FetchHead)
7+
GitAnnotated(repo::GitRepo, comittish::AbstractString)
8+
9+
An annotated git commit carries with it information about how it was looked up and
10+
why, so that rebase or merge operations have more information about the context of
11+
the commit. Conflict files contain information about the source/target branches in
12+
the merge which are conflicting, for instance. An annotated commit can refer to the
13+
tip of a remote branch, for instance when a [`FetchHead`](@ref) is passed, or to a
14+
branch head described using `GitReference`.
15+
"""
316
function GitAnnotated(repo::GitRepo, commit_id::GitHash)
417
ann_ptr_ptr = Ref{Ptr{Void}}(C_NULL)
518
@check ccall((:git_annotated_commit_lookup, :libgit2), Cint,
@@ -140,6 +153,12 @@ function merge!(repo::GitRepo, anns::Vector{GitAnnotated}, fastforward::Bool;
140153
return merge_result
141154
end
142155

156+
"""
157+
merge_base(repo::GitRepo, one::AbstractString, two::AbstractString) -> GitHash
158+
159+
Find a merge base (a common ancestor) between the commits `one` and `two`.
160+
`one` and `two` may both be in string form. Return the `GitHash` of the merge base.
161+
"""
143162
function merge_base(repo::GitRepo, one::AbstractString, two::AbstractString)
144163
oid1_ptr = Ref(GitHash(one))
145164
oid2_ptr = Ref(GitHash(two))

doc/src/devdocs/libgit2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Base.LibGit2.fetch
7575
Base.LibGit2.fetchheads
7676
Base.LibGit2.fetch_refspecs
7777
Base.LibGit2.fetchhead_foreach_cb
78+
Base.LibGit2.merge_base
7879
Base.LibGit2.merge!(::Base.LibGit2.GitRepo; ::Any...)
7980
Base.LibGit2.ffmerge!
8081
Base.LibGit2.fullname

0 commit comments

Comments
 (0)