Skip to content

Commit

Permalink
Trial run of adding newbase back
Browse files Browse the repository at this point in the history
Addresses part of #19839
  • Loading branch information
kshyatt committed Jan 19, 2017
1 parent 271b318 commit 9f71dec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 7 additions & 3 deletions base/libgit2/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ function merge!(repo::GitRepo;
end

"""
LibGit2.rebase!(repo::GitRepo[, upstream::AbstractString])
LibGit2.rebase!(repo::GitRepo, upstream::AbstractString="", newbase::AbstractString="")
Attempt an automatic merge rebase of the current branch, from `upstream` if provided, or
otherwise from the upstream tracking branch.
Expand All @@ -476,7 +476,7 @@ a `GitError`. This is roughly equivalent to the following command line statement
fi
"""
function rebase!(repo::GitRepo, upstream::AbstractString="")
function rebase!(repo::GitRepo, upstream::AbstractString="", newbase::AbstractString="")
with(head(repo)) do head_ref
head_ann = GitAnnotated(repo, head_ref)
upst_ann = if isempty(upstream)
Expand All @@ -493,10 +493,11 @@ function rebase!(repo::GitRepo, upstream::AbstractString="")
else
GitAnnotated(repo, upstream)
end
onto_ann = Nullable{GitAnnotated}(isempty(newbase) ? nothing : GitAnnotated(repo, newbase))
try
sig = default_signature(repo)
try
rbs = GitRebase(repo, head_ann, upst_ann)
rbs = GitRebase(repo, head_ann, upst_ann, onto=onto_ann)
try
while (rbs_op = next(rbs)) !== nothing
commit(rbs, sig)
Expand All @@ -513,6 +514,9 @@ function rebase!(repo::GitRepo, upstream::AbstractString="")
close(sig)
end
finally
if !isempty(newbase)
close(Base.get(onto_ann))
end
close(upst_ann)
close(head_ann)
end
Expand Down
13 changes: 13 additions & 0 deletions test/libgit2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,19 @@ mktempdir() do dir

# issue #19624
@test newnewhead == newhead

# add yet another file
open(joinpath(LibGit2.path(repo),"file4"),"w") do f
write(f, "444\n")
end
LibGit2.add!(repo, "file4")
LibGit2.commit(repo, "add file4")

# rebase with onto
newhead = LibGit2.rebase!(repo, "branch/a", "master")

newerhead = LibGit2.head_oid(repo)
@test newerhead == newhead
finally
close(repo)
end
Expand Down

0 comments on commit 9f71dec

Please sign in to comment.