-
|
In a repository like this jj git init /tmp/what
cd /tmp/what
echo won > the-file ; jj commit -m "Add line 1"
echo too >> the-file ; jj commit -m "Add line 2"
echo tri >> the-file ; jj desc -m "Add line 3"
jj edit @-a conflict is created by sed -i '2s/.*/two/' the-filebut not by sed -i '1s/.*/one/' the-fileThe conflict looks like this: Similarly, editing the only (and therefore also last) line in the previous change, gives a similar conflict. I've tried many experiments which are all consistent with what I observe here. It appears that editing the last line leads to conflicts. If there were an inconsistency in the presence/absence of a newilne at the end of the last line, this would make sense, but AFAICT the newline at the end is there throughout. The line is fully replaced in the edited change, it is not modified by the following change but the conflict marker suggests the contrary, so what is the source of the conflict? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
After you change the second commit from "won too" (pretend that spaces are newlines) to "won two", we rebase the third commit on top. That means rebasing the "won too" -> "won too tri" change on top of "won two", which means we have a 3-way merge with "won too" as base and "won two" and "won too tri" as sides. We then line inputs up and see that they all start with "won " but have a conflict right after that because the base is "too" and the sides are "two" and "too tri".
The leading space in the " too" line in the conflict marker indicates that it's unchanged compared to the base. |
Beta Was this translation helpful? Give feedback.
-
|
Very briefly, summarizing your linked '3-way merge algorithm', there should only be a conflict if all three versions disagree:
Here is the summary of the two situations, for easy reference: (Have I made a mistake in construting this this?)
Looking at the left (
Looking at the right (
I agree. How does this differ from the conflicting case? (This is the whole point of my original question!) Is it because the content of the second line is taken as context? In that case we get in which case I do see three different versions in 'context conflict' and only two different versions in 'context no-conflict'. |
Beta Was this translation helpful? Give feedback.
I think I get it: in the conflict case, it's not that line 2 and (the originally non-existent) line 3 are being modified independently, rather the modification is a single hunk/unit.
In the non-conflict case, the presence of an unmodified line 2 between them, prevents the modification of line 1 and the (originally non-existent) line 3 from being considered a single unit.
When treated independently, there is no conflict; when treated as a single unit, there is a conflict.
Is that it?