Skip to content
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

How should a deletion versus modification conflict be handled? #33

Closed
sageserpent-open opened this issue Apr 5, 2024 · 1 comment
Closed
Labels
question Further information is requested

Comments

@sageserpent-open
Copy link
Owner

As of Git commit SHA: 7873fcf, coverage testing shows that the logic here and here is not covered.

These deal with the situation where the merge has not tweaked the modification, so either the modification should be left in the working directory if it was done in our branch, or restored from the blob id if done on their branch.

The reason this never happens is that the merge is presented with a synthetic empty input representing the side with the deletion; it then does a three-way merge between outright deletion of content versus the modification, picking up changes to be propagated from the modified side if sections have moved out of the deleted file into another file.

That's fine in itself, but it means that Kinetic Merge will produce a merged result that is just the modifications without the original content of the file prior to deletion. If that results in an empty merge result, then the conflict is trivially resolved as a straight deletion (this supports code motion in the presence of edits from one file to another), and if the merge result is non empty, it is presented as a tweaked conflict between the deletion and the merge result, not the modified file content.

Git on the other hand just shows a conflict between a deletion and the modified file content - it doesn't think of the deletion is implying a merge of loss of content at all.

Should Kinetic Merge try to emulate Git, or is it better that it tries to merge to some extent? If it did emulate Git, how would this work with code motion across files? What if two files swap their content on one branch, but are edited in place on the other?

@sageserpent-open
Copy link
Owner Author

sageserpent-open commented May 30, 2024

Those code paths are now covered due to: 7ceed11, df31b31 and 3172523.

There are also tests for swapping of two files on one branch with editing of one or both of the original files on another branch: fc78628, 2dab8f2, d458fde and 90cad46 - subsequent work has got them to pass.

Kinetic Merge will result in a Git status of UD or DU for the merged file, depending on whether the modification was performed on our or their branch, respectively. This is in line with what Git does.

It will however merge the content deletion into the version of the file left in the working tree (as well as the staged entry for the side that performed the modification). This is in contrast to Git, which thinks that the deletion doesn't imply loss of content that should be merged - it simply leaves the other side as it is and asks the user to decide what to do.

As mentioned above, this fits in with the code motion cases where the 'deleted' file has simply moved elsewhere; I'm happy to leave it as it stands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant