-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Throw error on aborted rebase #19651
Changes from 3 commits
acb37e4
0e4d654
e402b11
2afcccb
f67e31a
022655c
fc84275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,46 +386,68 @@ function merge!(repo::GitRepo; | |
merge_opts::MergeOptions = MergeOptions(), | ||
checkout_opts::CheckoutOptions = CheckoutOptions()) | ||
# merge into head branch | ||
with(head(repo)) do head_ref | ||
upst_anns = if !isempty(committish) # merge committish into HEAD | ||
if committish == Consts.FETCH_HEAD # merge FETCH_HEAD | ||
fheads = fetchheads(repo) | ||
filter!(fh->fh.ismerge, fheads) | ||
if isempty(fheads) | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"There is no fetch reference for this branch.")) | ||
end | ||
map(fh->GitAnnotated(repo,fh), fheads) | ||
else # merge commitish | ||
[GitAnnotated(repo, committish)] | ||
upst_anns = if !isempty(committish) # merge committish into HEAD | ||
if committish == Consts.FETCH_HEAD # merge FETCH_HEAD | ||
fheads = fetchheads(repo) | ||
filter!(fh->fh.ismerge, fheads) | ||
if isempty(fheads) | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"There is no fetch reference for this branch.")) | ||
end | ||
else | ||
if !isempty(branch) # merge provided branch into HEAD | ||
with(GitReference(repo, branch)) do brn_ref | ||
[GitAnnotated(repo, brn_ref)] | ||
map(fh->GitAnnotated(repo,fh), fheads) | ||
else # merge commitish | ||
[GitAnnotated(repo, committish)] | ||
end | ||
else | ||
if !isempty(branch) # merge provided branch into HEAD | ||
with(GitReference(repo, branch)) do brn_ref | ||
[GitAnnotated(repo, brn_ref)] | ||
end | ||
else # try to get tracking remote branch for the head | ||
if !isattached(repo) | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"Repository HEAD is detached. Remote tracking branch cannot be used.")) | ||
end | ||
if isunborn(repo) | ||
# this isn't really a merge, but really moving HEAD | ||
# https://github.com/libgit2/libgit2/issues/2135#issuecomment-35997764 | ||
# try to figure out remote tracking of unborn head | ||
|
||
m = with(GitReference(repo, Consts.HEAD_FILE)) do head_sym_ref | ||
match(r"refs/heads/(.*)", fullname(head_sym_ref)) | ||
end | ||
else # try to get tracking remote branch for the head | ||
if !isattached(repo) | ||
if m == nothing | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"Repository HEAD is detached. Remote tracking branch cannot be used.")) | ||
"Unable to determine name of unborn branch.")) | ||
end | ||
with(upstream(head_ref)) do tr_brn_ref | ||
if tr_brn_ref === nothing | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"There is no tracking information for the current branch.")) | ||
branchname = m.captures[1] | ||
remotename = with(GitConfig, repo) do cfg | ||
LibGit2.get(String, cfg, "branch.$branchname.remote") | ||
end | ||
ref = GitReference(repo, "refs/remotes/$remotename/$branchname") | ||
obj = LibGit2.Oid(ref) | ||
LibGit2.create_branch(repo, "master", get(GitCommit, repo, obj)) | ||
return true | ||
else | ||
with(head(repo)) do head_ref | ||
with(upstream(head_ref)) do tr_brn_ref | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was newbase not hooked up at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. guess we should add that to the list in #19839 since it would be a useful feature to have at some point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point. |
||
if tr_brn_ref === nothing | ||
throw(GitError(Error.Merge, Error.ERROR, | ||
"There is no tracking information for the current branch.")) | ||
end | ||
[GitAnnotated(repo, tr_brn_ref)] | ||
end | ||
[GitAnnotated(repo, tr_brn_ref)] | ||
end | ||
end | ||
end | ||
end | ||
|
||
try | ||
merge!(repo, upst_anns, fastforward, | ||
merge_opts=merge_opts, | ||
checkout_opts=checkout_opts) | ||
finally | ||
map(finalize, upst_anns) | ||
end | ||
try | ||
merge!(repo, upst_anns, fastforward, | ||
merge_opts=merge_opts, | ||
checkout_opts=checkout_opts) | ||
finally | ||
map(finalize, upst_anns) | ||
end | ||
end | ||
|
||
|
@@ -455,6 +477,7 @@ function rebase!(repo::GitRepo, upstream::AbstractString="", newbase::AbstractSt | |
finish(rbs, sig) | ||
catch err | ||
abort(rbs) | ||
rethrow(err) | ||
finally | ||
finalize(rbs) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
===
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing is a singleton, so it just cuts out one level of inlining