chrisky
chrisky

Reputation: 63

Git merge conflicts cannot detect logical merge conflicts/errors, right?

I see that conflict happens when two branch changed same "line" of code. So i guess it's possible that two people edited same file without knowing each others changes, and because the changes were not in same lines therefore git gives it a pass during merge, but may have introduced logical errors?

Upvotes: 0

Views: 892

Answers (3)

Kache
Kache

Reputation: 16687

That's correct.

Git merge conflicts are text editing conflicts where it can't be certain which of two changes to adopt into the merged version.

It's still possible to have a logical "conflict" of code meaning/intent. Git is unable to understand the edits.

A simple example of two developers working independently:

  • Dev A deletes an unused method.
  • Dev B adds a new usage of that same method somewhere else.

Git does not compile/execute the code and cannot know that there is a logical conflict just by doing a textual code merge.

Upvotes: 2

Kaz
Kaz

Reputation: 58598

Automatic merging is not reliable; the results have to be subject to review and testing.

In many cases it is "obvious" by inspection that two changes are completely unrelated.

For instance, an of-by-one fix in some loop in a serial UART driver is almost certainly unrelated to the fix for a race condition in the USB stack, so you don't bother considering these for some sort of semantic conflict.

Automatic merging, in general, is one of those tools about which we could write an "unreasonable effectiveness of" article.

Upvotes: 0

Yes. Git just organize versions and help async development. It does not compile or test your code. Instead you could create some tests that run before commits.

Upvotes: 1

Related Questions