4 ms·
You know, I suspect that in many production cases, neither merge is "correct". The example involves a lot code duplication, and a change to the block of code w
by saalweachter 16y ago
You know, I suspect that in many production cases, neither merge is "correct". The example involves a lot code duplication, and a change to the block of code which was duplicated.
The probable case is something like:
function foo(){
do_something_complex_but_not_correct();
}
with one person making the change to:
function foo(){
something_else();
do_something_complex_but_not_correct();
}
and then:
function foo(){
do_something_complex_but_not_correct();
something_else();
do_something_complex_but_not_correct();
}
in the stated two-step change, while another author makes the change to:
function foo(){
do_something_complex_and_also_correct();
}
The correct "merge" is going to be to apply the second change to both blocks of code, not just the first or the second:
function foo(){
do_something_complex_and_also_correct();
something_else();
do_something_complex_and_also_correct();
}
- Groxx 16y agoWhich is why I side with explicit, patch-like behavior. Interpreting a `move-and-copy` as a `move` when there's a chunk of duplicate data that could mess things up means it's essentially doing a primitive semantic analysis of what you meant to do. It may be correct more of the time, but it can't be correct all of the time. What I "meant to do" could have been as you stated, where both should have changed. Or I could have copied the internals of a function to a new one, and made minor changes around it, and actually do wish to use that new copy as the official version. There is no way to 100% accurately detect such intent without being explicit about it, so I'd prefer something dumb and therefore extremely predictable.