Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » aborting a conflicted merge
aborting a conflicted merge [message #753852] Sat, 29 October 2011 14:06 Go to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
From what I can see egit doesn't have a direct equivalent of 'git merge --abort'. I see an abort option for egit rebase but not egit merge. Am I not looking in the right place or does it not exist?

I can use egit reset to abort a conflicted merge but the result is not always identical to what 'git merge --abort' would do.
Re: aborting a conflicted merge [message #753909 is a reply to message #753852] Sun, 30 October 2011 14:44 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
R Shapiro skrev 2011-10-29 16.0616:
> From what I can see egit doesn't have a direct equivalent of 'git merge --abort'. I see an abort option for egit rebase but not egit merge. Am I not looking in the right
> place or does it not exist?
>
> I can use egit reset to abort a conflicted merge but the result is not always identical to what 'git merge --abort' would do.
>

It does not exist (yet).

-- robin
Re: aborting a conflicted merge [message #1728583 is a reply to message #753909] Tue, 05 April 2016 15:07 Go to previous messageGo to next message
Alcemir Santos is currently offline Alcemir SantosFriend
Messages: 23
Registered: July 2012
Junior Member

More than 4 year have gone now, have this already been implemented?
Re: aborting a conflicted merge [message #1729410 is a reply to message #1728583] Wed, 13 April 2016 22:11 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 841
Registered: July 2009
Senior Member
no, maybe you want to contribute this ?
Re: aborting a conflicted merge [message #1732046 is a reply to message #1729410] Thu, 12 May 2016 08:34 Go to previous messageGo to next message
Alcemir Santos is currently offline Alcemir SantosFriend
Messages: 23
Registered: July 2012
Junior Member

Matthias Sohn wrote on Wed, 13 April 2016 18:11

no, maybe you want to contribute this ?


I can try, I will start to study the code to learn how to do that.

In the mean time, how can I work around this? I mean, since I tried to execute a merge and it ran into conflicts, how to undo the merge attempt in order to be able to proceed with other operations with the repository?
Re: aborting a conflicted merge [message #1732093 is a reply to message #1732046] Thu, 12 May 2016 13:55 Go to previous messageGo to next message
Alcemir Santos is currently offline Alcemir SantosFriend
Messages: 23
Registered: July 2012
Junior Member

I tried to run git merge --abort with Runtime.exec() but it ends with the following message:
Quote:
error: Entry '<filename>' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'HEAD'.


This is what I have tried:

// Option 1
static final String ABORT_CMD = "git merge --abort";
static final String[] ABORT_ENV = { "GIT_PAGER=cat" };
Runtime run = Runtime.getRuntime();
Process pr = run.exec(ABORT_CMD, ABORT_ENV, repositoryPath);
pr.waitFor();


// Option 2
ProcessBuilder pb =  new ProcessBuilder("git", "merge", "--abort");
pb.directory(repositoryPath);
Process pr = pb.start();
pr.waitFor();


In both ways, I have got the same message.
Re: aborting a conflicted merge [message #1732149 is a reply to message #1732093] Thu, 12 May 2016 22:01 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 841
Registered: July 2009
Senior Member
you can workaround by resetting hard to the commit you started the merge from
Re: aborting a conflicted merge [message #1732194 is a reply to message #1732149] Fri, 13 May 2016 11:38 Go to previous message
Alcemir Santos is currently offline Alcemir SantosFriend
Messages: 23
Registered: July 2012
Junior Member

It seems to have worked for my purpose.
I had already tried this but without setref() to such commit.

by the way, would u mind to explain the difference between both approaches ("git reset <sha1>" and "git merge --abort")? I have found this, which left me wondering whether the latter is an alias for the first one or not.
Previous Topic:Can't Merge into master
Next Topic:Accessing the conflicting lines
Goto Forum:
  


Current Time: Sat Jul 30 03:34:57 GMT 2016

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

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