Skip to content

Absence of conflict in delete/modify case #529

@wetneb

Description

@wetneb

I found a case where spork doesn't produce any conflict while I intuitively think it should. Informally:

  • On the left side, you replace (or delete) a node n
  • On the right side, you make a change to some descendant of n

In this scenario, as a user I would intuitively expect to be presented with a conflict, because automatically choosing the version of the left side silently discards changes from the right side.

The example below is quite minimalistic, but I think it's a real problem in real usage scenarios. For instance, say the left side inlines a method and the right side makes changes to the method's body. In such a case I don't want the merge driver to silently discard the changes of the right side, especially if the inlining is happening across multiple files, in which case there is no chance spork is able to replicate the changes to the method body in places where the method was used.

This seems to be a rather fundamental problem of the algorithm as it stands: I don't see how to tweak the procedure to reconstruct a tree from a change set to fix this issue. What do you think @slarse?

Base.java

class MyCls {
     public void foo(int t) {
          int a = (t + 8) * 5 - 3;
     }
}

Left.java

class MyCls {
     public void foo(int t) {
          int a = 23 - 3;
     }
}

Right.java

class MyCls {
     public void foo(int t) {
          int a = t * 5 - 3;
     }
}

Current output

class MyCls {
    public void foo(int t) {
        int a = 23 - 3;
    }
}

Expected output

Something along the lines of what git merge-file produces (or with a narrower conflict):

class MyCls {
     public void foo(int t) {
<<<<<<< Left.java
          int a = 23 - 3;
||||||| Base.java
          int a = (t + 8) * 5 - 3;
=======
          int a = t * 5 - 3;
>>>>>>> Right.java
     }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions