-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unresolvable conflict when merging with empty file #3223
Comments
Interesting. It should be possible to work around the bug by doing |
Yeah, I worked around by renaming the file, running jj status, then renaming it back |
Following git's behavior, there is no conflict. So it seems |
Should this be handled as a conflict or just merge the files as git does? |
Still new to the code base, but I think the issue stems from somewhere in (edit: scratch that, a trivial resolution is attempted in |
Copying my answer from Discord to here: I think it ideally should be considered a conflict. The problem is that we use the empty string as a placeholder for a missing file when materializing/rendering the conflict markers. So the conflict becomes this:
I.e. a conflict adding "abc\n" on one side, "" on the other side, and "" in the base. That gets automatically resolved to just "abc\n". (It doesn't actually work exactly this way.) I wonder how well it would work to replace the missing-file placeholder by e.g. "". I'm not sure that's a good idea, and i don't want to use english-specific user-visible strings in the library code anyway |
This is a little confusing to me: it seems like we shouldn't need to change the conflict markers. As you said,
should already be auto-resolving to
Oh, I was just planning to add some with #1176 (comment). The plan is to eventually make the strings configurable, though, and they could be provided with the CLI. |
I'm guessing that the problem is that the conflict is generated like that after auto-resolution of conflicts happens. We could still introduce different conflict markers for empty files, but in terms of user-visible effects with this bug, things would be the same or worse. Creating an empty file on both sides is an example of what we've been calling "A + A - B" conflicts, which are auto-resolved to "A" at some cost to consistency in our conflict theory. It would behoove |
If it's considered a conflict or not, the situation should be handled in some way. Marking it as a conflict but not providing a conflict marker might be confusing for users. |
I actually think "empty file" and "missing file" are not the same state, which is why I feel like this case should be considered a conflict. But it's a rare case in practice so we might want to just mark it resolved anyway. |
+1
I agree. In our theory, creating an empty file on both sides is a conflict where the base is the "missing file" state and both sides are the "empty file" state. So, the situation of this bug (one side being an "empty file" and the other being a "nonempty file") would be a conflict. In practice, however, I don't think jj's behavior would change if we treated it that way. As long as we follow "A + A - B = A", it does not matter whether "B" is "missing" or "empty" (in the latter case, we'd have B=A). |
Putting things another way, perhaps What I said before is true if the answer to this question is "yes". If it's "no", we'd have to simplify the |
I agree, but I thought we already do. I suspect we're hitting this check: Lines 370 to 380 in 2dc95bb
|
Good find! I think that's likely it. |
Just tested. In the scenario of this issue, |
Weird. I just checked as well and it is called for me, and it returns early because of that check I mentioned above. |
Really weird on my end. It sometimes triggers, sometimes doesn't. Sometimes only when I run |
I'm currently thinking of resolving this by keeping this conflicted and materializing the file as a conflict. However, it turns out we currently wouldn't materialize a conflict involving an empty file, or any file not ending in a newline, correctly: #3968. If acceptable, I'd materialize it as though the empty file was a file with just a newline (see that bug). Another option would be to not consider this a conflict. I'm going back and forth on whether this would be "more correct" in theory (considered as a composition of a conflict |
Description
When one commit creates an empty file, and another commit creates a file of the same name, you get a conflict that can never be resolved.
I believe the core issue is that there are no conflict markers in such a file, and so jj says "file was unmodified" and hence thinks the resolution failed.
Steps to Reproduce the Problem
jj git init
touch foo
jj new @-
echo "abc" > foo
jj rebase -s @ <other commit>
Expected Behavior
Either there is no conflict, or the conflict resolution works
Actual Behavior
Conflict can never be resolved
Specifications
The text was updated successfully, but these errors were encountered: