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 18, 2017
1 parent 48e923f commit e99061e
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 @@ -457,7 +457,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 @@ -472,7 +472,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 @@ -489,10 +489,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 @@ -509,6 +510,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 @@ -650,6 +650,19 @@ mktempdir() do dir

# issue #19624
@test LibGit2.head_oid(repo) == 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
LibGit2.rebase!(repo, "branch/a", "master")

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

0 comments on commit e99061e

Please sign in to comment.