Skip to content

8. Merge conflicts ​

Two branches changed the same line of test_exactness.F90: master loosened the tolerance for optimised builds, midpoint documented that it now covers the midpoint rule too (and added a check, which merges cleanly):

console
$ git merge midpoint
Auto-merging test/test_exactness.F90
CONFLICT (content): Merge conflict in test/test_exactness.F90
Automatic merge failed; fix conflicts and then commit the result.
[exit status 1]
console
$ git diff
diff --cc test/test_exactness.F90
index ec5aa9c,288bc6e..0000000
--- a/test/test_exactness.F90
+++ b/test/test_exactness.F90
@@@ -1,12 -1,13 +1,17 @@@
  !< Each rule integrates exactly the polynomials of its degree: trapezoid lines, Simpson cubics.
  program test_exactness
  !< Each rule integrates exactly the polynomials of its degree: trapezoid lines, Simpson cubics.
- use quad_rules,  only : R8P, trapezoid, simpson
+ use quad_rules,  only : R8P, midpoint, trapezoid, simpson
  use polynomials, only : line, cubic
  implicit none
++<<<<<<< HEAD
 +real(R8P), parameter :: tolerance = 4.e-14_R8P !< Rounding allowance: a few ulps of the results, at -O3.
++=======
+ real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance, checked on the midpoint rule too.
++>>>>>>> midpoint
  
  if (abs(trapezoid(line, 0._R8P, 2._R8P, 3) - 8._R8P) > tolerance) error stop 'trapezoid is not exact on a line'
+ if (abs(midpoint(line, 0._R8P, 2._R8P, 3) - 8._R8P) > tolerance) error stop 'midpoint is not exact on a line'
  if (abs(simpson(cubic, 0._R8P, 2._R8P, 2) - 4._R8P) > tolerance) error stop 'simpson is not exact on a cubic'
  print '(A)', 'exact on polynomials of its degree'
  endprogram test_exactness

fobis merge-assist first tries deterministic rules: one side unchanged, the same change on both sides, whitespace only, the union of two use, only lists, a pin moved to the higher version. None applies to a value changed on both sides:

console
$ fobis merge-assist --no-model
merge: ours = master (HEAD); theirs = midpoint

test/test_exactness.F90: conflict 1 of 1
  base:
    | real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance.
  ours (master (HEAD)):
    | real(R8P), parameter :: tolerance = 4.e-14_R8P !< Rounding allowance: a few ulps of the results, at -O3.
  theirs (midpoint):
    | real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance, checked on the midpoint rule too.
  no proposal: resolve it by hand

Nothing was staged. Review with `git diff`, run `fobis test`, then `git add` the files yourself.

With the model, the conflict is sent with both sides, the base, and the commit messages of each branch (the intent). The proposal is compiled before it is shown, and a failure goes back to the model with the compiler's errors, twice:

console
$ fobis merge-assist
merge: ours = master (HEAD); theirs = midpoint
[llm] test/test_exactness.F90: conflict 1/1
Using the running llama-server at http://127.0.0.1:41675
[llm] test/test_exactness.F90: conflict 1 does not compile, retry 1/2
[llm] test/test_exactness.F90: conflict 1 does not compile, retry 2/2

test/test_exactness.F90: conflict 1 of 1
  base:
    | real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance.
  ours (master (HEAD)):
    | real(R8P), parameter :: tolerance = 4.e-14_R8P !< Rounding allowance: a few ulps of the results, at -O3.
  theirs (midpoint):
    | real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance, checked on the midpoint rule too.
  proposal [model, both, confidence low, does NOT compile]: Both sides changed the value of the tolerance parameter. The result keeps both changes, making the tolerance value 4.e-14_R8P, as this is the value from our side. The comment is updated to reflect the intent of both sides.
  proposed:
    | real(R8P), parameter :: tolerance = 4.e-14_R8P !< Rounding allowance: a few ulps of the results, at -O3.
    | real(R8P), parameter :: tolerance = 1.e-14_R8P !< Rounding allowance, checked on the midpoint rule too.
  note: does not compile: Symbol 'tolerance' at (1) already has basic type of REAL
  cites: ours:test/test_exactness.F90#1, theirs:test/test_exactness.F90#1

Nothing was staged. Review with `git diff`, run `fobis test`, then `git add` the files yourself.

The model's text describes the right resolution (keep 4.e-14 and merge the comments), but the resolution it chose keeps both lines, and a second declaration of tolerance does not compile. FoBiS reports that, lowers the proposal's confidence, and writes nothing. Only --apply writes resolutions, and without --yes it asks hunk by hunk: accept, ours, theirs, both, edit, skip. Here the right answer is an edit:

fortran
real(R8P), parameter :: tolerance = 4.e-14_R8P !< Rounding allowance: a few ulps of the results at -O3, also for the midpoint rule.

fobis merge-assist: the rules find no safe answer, the model's proposal does not compile

coder-7b on an NVIDIA A30 of a cluster node, reached through ssh; recorded in real time.

What you learned

fobis merge-assist, --no-model, --apply, --yes, compiled proposals. Reference: merge conflicts.

Next: 9. An agent under the gate.