Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Revert of a merge commit
Revert of a merge commit [message #1715237] Fri, 20 November 2015 13:14 Go to next message
Carlos Garcia is currently offline Carlos GarciaFriend
Messages: 5
Registered: November 2015
Junior Member
Hi,

When a try to execute a revert of a merge commit i get the following error:

Cannot revert commit '3f752b07d8c02800fea3a9a512a55837e591c2a0' because it has 2 parents, only commits with exactly one parent are supported.

So, Is not possible to revert merge commits with JGIT?

Greetings Smile
Re: Revert of a merge commit [message #1715244 is a reply to message #1715237] Fri, 20 November 2015 13:56 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
Right. Reverting a merge is not supported currently by JGit. Also native git fails if you just say "git revert <mergeCommitId>". See [1] where it is said "Usually you cannot revert a merge ...". You have to tell native git explicitly which of the merged branches should be the "mainline". And yes, that option is not supported by JGit.

[1] https://git-scm.com/docs/git-revert#_options


Ciao
Chris
Re: Revert of a merge commit [message #1715412 is a reply to message #1715244] Mon, 23 November 2015 12:24 Go to previous messageGo to next message
Carlos Garcia is currently offline Carlos GarciaFriend
Messages: 5
Registered: November 2015
Junior Member
Thanks for the reply!!

Will be that option supported by Jgit in the near future? In other words, is it in the roadmap? Smile

Greetings!
Re: Revert of a merge commit [message #1715439 is a reply to message #1715412] Mon, 23 November 2015 15:10 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
I don't know of anybody else who requested that feature up to know. So I guess it's not on any comitters roadmap. Imagine you once merged without conflicts the commits c-master and c-side inside the merge commit m. Now you want to revert merge commit m and your mainline should be c-master. Then you could achieve what you want by reverting every commit reachable from c-side but not from c-master: "git log <c-master>..<c-side>". You'll end up with individual revert commits which you can then squash into one big revert commit. This is of course only doable if the number of commits from the side branch is small.




Ciao
Chris
Re: Revert of a merge commit [message #1715588 is a reply to message #1715439] Tue, 24 November 2015 13:53 Go to previous messageGo to next message
Carlos Garcia is currently offline Carlos GarciaFriend
Messages: 5
Registered: November 2015
Junior Member
Hi,

Well, I thing that option only works if the merge commit does not resolve conflicts on any files. Am i wrong?

Thanks for the comments!
Re: Revert of a merge commit [message #1715592 is a reply to message #1715588] Tue, 24 November 2015 14:37 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
Yes. That's what I meant with "... once merged without conflicts ..." . If you need to revert a merge commit which included conflict resolutions you are out of luck. You either use commandline git (with --mainline option) for that revert or contribute that functionality to E/JGit Smile . I could help teaching JGit to revert merge commits. But I am not sure how to present that selection of the mainline in the EGIt UI.


Ciao
Chris
Re: Revert of a merge commit [message #1715621 is a reply to message #1715592] Tue, 24 November 2015 17:33 Go to previous messageGo to next message
Carlos Garcia is currently offline Carlos GarciaFriend
Messages: 5
Registered: November 2015
Junior Member
It would be nice if you could provide me some information to try to develop this feature.

I assume that there is some documentation somewhere for newbies that want to add add new features to the library (just like me) Smile

Greetings
Re: Revert of a merge commit [message #1715668 is a reply to message #1715621] Wed, 25 November 2015 07:50 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
You need to follow our contributor guide https://wiki.eclipse.org/EGit/Contributor_Guide. When you have EGit and JGit sources in your eclipse compiling without errors (with API-baseline tooling turned on as described in the guide) you are ready to go. I don't know much about the Eclipse UI programming but I can help with the semantics you need to implement in JGit. A revert of a merge commit m which has as mainline parent commit p1 is nothing else as a merge of commits (HEAD, p1) with common predecessor m. When you are ready with preparations I can help with that.
-


Ciao
Chris
Previous Topic:Getting multiple NCDFE: org/eclipse/team/core/RepositoryProvider errors
Next Topic:JGIT/EGIT@Windows/NTFS; duplicate tags / case insensitive
Goto Forum:
  


Current Time: Fri Apr 26 08:26:26 GMT 2024

Powered by FUDForum. Page generated in 0.02884 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top