From 9f71dec74c4ccb70cb6b3d4fdb502353f11b588a Mon Sep 17 00:00:00 2001 From: kshyatt Date: Tue, 10 Jan 2017 11:36:41 -0800 Subject: [PATCH] Trial run of adding newbase back Addresses part of #19839 --- base/libgit2/libgit2.jl | 10 +++++++--- test/libgit2.jl | 13 +++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/base/libgit2/libgit2.jl b/base/libgit2/libgit2.jl index a91fe0eb7bed0..9433e9fb8dac0 100644 --- a/base/libgit2/libgit2.jl +++ b/base/libgit2/libgit2.jl @@ -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. @@ -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) @@ -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) @@ -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 diff --git a/test/libgit2.jl b/test/libgit2.jl index 6d3a2f6728d53..c86994547b602 100644 --- a/test/libgit2.jl +++ b/test/libgit2.jl @@ -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