Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Wrong values returned in MergeResult#getConflicts()

Hi,

I wrote some parts of the code and I have to admit: I also don't fully understand org.eclipse.jgit.api.MergeResult anymore. There is the low-level org.eclipse.jgit.merge.MergeResult and this seems to have the right content. But the api level class contains some bugs (and is far to complicated if it takes so long to analyse this problem). What I did up to know: I temporarily took your unit test and brought it to JGit test classes (https://git.eclipse.org/r/#/c/71232/). I added more toString() methods to MergeResult/MergeChunk (https://git.eclipse.org/r/#/c/71231/). Additionally I added some System.out.println to the test and when I execute the test I get what I pasted below. The low-level MergeResults which are added to the api level MergeResult show correctly how the conflicts are detected. But the API level MergeResult seem to miss some information. Will continue to investigate:

Here is what I get when I do the merge with native git and inspect the workingtreefiles afterwards (btw: I have configured "git config merge.conflictstyle=diff3"):

chris@vblub14:/tmp/jgit_test_8097925874040451262_tmp/tmp_4912665237122255536$ cat Bar.java 
1
2
<<<<<<< HEAD
3
4-master
||||||| merged common ancestors
3
4
=======
3-side
4-side
5
>>>>>>> f5c2c18e746e847de0b7a45329d08c291538b094
chris@vblub14:/tmp/jgit_test_8097925874040451262_tmp/tmp_4912665237122255536$ cat Foo.java 
1
2
3
<<<<<<< HEAD
4-master
||||||| merged common ancestors
4
=======
4-side
>>>>>>> f5c2c18e746e847de0b7a45329d08c291538b094
5
6
7
8

Here is the output of your test which I incorporated into jgit in https://git.eclipse.org/r/#/c/71232:

Adding org.eclipse.jgit.merge.MergeResult: {#sequences:3, chunks:[{state:NO_CONFLICT, sequenceIndex:0, begin:0, end:3}, {state:FIRST_CONFLICTING_RANGE, sequenceIndex:1, begin:3, end:4}, {state:NEXT_CONFLICTING_RANGE, sequenceIndex:2, begin:3, end:4}, {state:NO_CONFLICT, sequenceIndex:0, begin:4, end:8}]}
Adding org.eclipse.jgit.merge.MergeResult: {#sequences:3, chunks:[{state:NO_CONFLICT, sequenceIndex:0, begin:0, end:2}, {state:FIRST_CONFLICTING_RANGE, sequenceIndex:1, begin:2, end:4}, {state:NEXT_CONFLICTING_RANGE, sequenceIndex:2, begin:2, end:5}]}
Conflicts in file Foo.java
  Conflict #0
    Chunk for commit d0b09434547df8d59783f44c11f24b5b8e11c61a 1250379778 -t--sp starts on line #0
    Chunk for commit 9b1b18f5525cfec97e326f9bbf2385ef7a30b2ab 1250379778 -t--sp starts on line #3
Conflicts in file Bar.java
  Conflict #0
    Chunk for commit d0b09434547df8d59783f44c11f24b5b8e11c61a 1250379778 -t--sp starts on line #0
    Chunk for commit 9b1b18f5525cfec97e326f9bbf2385ef7a30b2ab 1250379778 -t--sp starts on line #2
mResult.toStringExt(): {mergedCommits:[d0b09434547df8d59783f44c11f24b5b8e11c61a, 9b1b18f5525cfec97e326f9bbf2385ef7a30b2ab], base:f84a5343f91466a0f0cf50c90d766090970a7c7c, newHead:null, mergeStatus:Conflicting, description:null, mergeStrategy:recursive, failingPaths:[], checkoutConflicts:[], conflicts:[Foo.java->[[0][0]:0, [0][1]:3, [0][2]:3], Bar.java->[[0][0]:0, [0][1]:2, [0][2]:2]]}

Ciao
  Chris

Back to the top