2

I am currently using JGit to merge remote branches, so after fetching from remote I would like to verify conflicts before I attempt to merge, so that I can decide what kind of merge strategy to use, for eg:

Myrepo/filesmodifiedbyme/file1.txt
Myrepo/filesmodifiedbysomeone/file2.txt

After fetch:

  • if there are conflicts in file1.txt, I would like to use MergeStrategy.OURS,
  • if file2.txt has conflicts, I would like to apply MergeStrategy.THEIRS.

So following are my questions:

  1. how to get conflicts ahead before merging two branches?
  2. how to apply multiple merge strategy on different files at same time?
sanat
  • 91
  • 7
  • This is not an answer to your question as asked, but [this looks like a job for "custom merge drivers"](http://stackoverflow.com/a/930495/1256452) – torek Sep 10 '13 at 01:40
  • hi @sanat, were you able to find the solution for this problem, since i'm also facing same type of problem. It will be great if you can help me, please. – Abhishek-M Aug 01 '17 at 10:28

1 Answers1

1

If you're using the JGit MergeCommand to run this, the most likely way is to run the merge with a mergeCommand.setCommit(false) (so that you do the dry-run), and then based on your decisions, clean the working directory and re-run the merge command with the appropriate merge strategy.

AlBlue
  • 23,254
  • 14
  • 71
  • 91