Repository state Merging in JGit -


i trying resolve merge conflicts programmatically, i.e force merge. after resolving merge conflicts, if try commit below exception:

org.eclipse.jgit.api.errors.wrongrepositorystateexception: cannot commit repository state: merging.

how change repository status or missing something. code snippet:

if((repositorystate.safe == pullcommand.getrepository().getrepositorystate())) {   pullresult result = pullcommand.call();   if(mergestatus.conflicting == result.getmergeresult().getmergestatus()){       mgcmd = git.merge();      mgcmd.include(repo.getref("refs/remotes/origin/development"));      mgcmd.setstrategy(mergestrategy.ours);      mgcmd.setcommit(true);      res = mgcmd.call();       system.out.println("failing path ==="+res.getfailingpaths());      pullcommand.getrepository().resolve("c:\\code\\thin\\thinclient\\.git");      if(res.getmergestatus().equals(mergeresult.mergestatus.conflicting)){        system.out.println("merge status=========+++"+res.getmergestatus());      } 

the mergecommand not meant resolve merge conflicts. contrary true, cause merge conflicts if included ref(s) cannot merged without conflicts.

the pullcommand composite command first fetches commits upstream , tries merge them using mergecommand.

in order programmatically resolve merge conflicts, need change files in local work directory accordingly, add them index, , issue merge commit.

information conflicting files can found in pullresult.getmergeresult(). merge commit can created regular commitcommand.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -