{"thread":{"id":"51415","subject":"[QUESTION] Git fails to detect merge conflict?","startedAt":"2019-07-01T23:28:32Z","lastAt":"2019-07-05T00:45:13Z","messageCount":3,"participants":["Anton Ermolenko","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"378467","messageId":"E42B8D46-0CA0-44E0-946F-8ADA96993629@atlassian.com","threadId":"51415","inReplyTo":null,"subject":"[QUESTION] Git fails to detect merge conflict?","fromName":"Anton Ermolenko","fromEmail":"aermolenko@atlassian.com","sentAt":"2019-07-01T23:28:26Z","receivedAt":"2019-07-01T23:28:32Z","isPatch":false,"sender":{"key":"aermolenko@atlassian.com","avatar":null},"body":"Hello folks,\n\nI'm writing on behalf of a customer and I wonder if you could help me to clarify\nif the following test case should be considered a bug or if it is expected\nbehavior.\n\n  # create repository\n  git init\n  # add initial content\n  cat << EOF > example.txt\n\n--- START ---\n  LINE 1\n  LINE 2\n  LINE 3\n---  END  ---\n\nEOF\n  # commit the changes\n  git add example.txt && git commit -m \"Initial Commit\"\n\n  # create a branch\n  git checkout -b change-a\n  # introduce a change\n  cat << EOF > example.txt\n\n--- START ---\n  LINE 1\n  LINE 2\n  LINE 3\n  LINE 4\n  LINE 5\n  LINE 6\n  LINE 7\n  LINE 8\n  LINE 9\n---  END  ---\n\nEOF\n  # commit the change\n  git commit -am \"change a\"\n\n  # return to master and create another branch\n  git checkout master && git checkout -b change-b\n  # introduce another change\n  cat << EOF > example.txt\n\n--- START ---\n  LINE 1\n  LINE B\n  LINE 3\n  LINE D\n  LINE E\n  LINE 3\n---  END  ---\n\nEOF\n  git commit -am \"change b\"\n\nAt this point the \"change-a\" diff with master is:\n\ndiff --git a/example.txt b/example.txt\nindex 1cebaff..605f2b0 100644\n--- a/example.txt\n+++ b/example.txt\n@@ -3,5 +3,11 @@\n   LINE 1\n   LINE 2\n   LINE 3\n+  LINE 4\n+  LINE 5\n+  LINE 6\n+  LINE 7\n+  LINE 8\n+  LINE 9\n ---  END  ---\n\nand \"change-b\" diff with master is:\n\ndiff --git a/example.txt b/example.txt\nindex 1cebaff..cf5c0b2 100644\n--- a/example.txt\n+++ b/example.txt\n@@ -1,7 +1,10 @@\n\n --- START ---\n   LINE 1\n-  LINE 2\n+  LINE B\n+  LINE 3\n+  LINE D\n+  LINE E\n   LINE 3\n ---  END  ---\n\nIf a user to merge branches with \"no-fast-forward\" strategy, git does not detect\na conflict:\n\n  # merge change-a first\n  git merge --no-ff -m \"merge change-a\" change-a\n  # merge change-b now\n  git merge --no-ff -m \"merge change-b\" change-b\n\nAnd the resulting content of \"example.txt\" is:\n\n--- START ---\n  LINE 1\n  LINE B\n  LINE 3\n  LINE D\n  LINE E\n  LINE 3\n  LINE 4\n  LINE 5\n  LINE 6\n  LINE 7\n  LINE 8\n  LINE 9\n---  END  ---\n\nMy understanding is that recursive merge here won't consider that situation to\nbe a merge conflict as the changes have been introduced in different spots in\nthe file.\n\nAm I correct or is this a bug?\n\nThank you,\nAnton.\n\n"},{"id":"378468","messageId":"20190702001528.GA94153@google.com","threadId":"51415","inReplyTo":"E42B8D46-0CA0-44E0-946F-8ADA96993629@atlassian.com","subject":"Re: [QUESTION] Git fails to detect merge conflict?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-07-02T00:15:28Z","receivedAt":"2019-07-02T00:15:33Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Anton Ermolenko wrote:\n\n> My understanding is that recursive merge here won't consider that situation to\n> be a merge conflict as the changes have been introduced in different spots in\n> the file.\n\nYes, that seems right to me.\n\nDo you have more details about the context?  What do these files look\nlike?  Are there other cues that we could use to discover that the\ncustomer intended the changes to conflict?\n\nThanks,\nJonathan\n"},{"id":"378616","messageId":"70A38295-66D4-43B0-87EF-EA3EB5C0CEAE@atlassian.com","threadId":"51415","inReplyTo":"20190702001528.GA94153@google.com","subject":"Re: [QUESTION] Git fails to detect merge conflict?","fromName":"Anton Ermolenko","fromEmail":"aermolenko@atlassian.com","sentAt":"2019-07-05T00:45:07Z","receivedAt":"2019-07-05T00:45:13Z","isPatch":false,"sender":{"key":"aermolenko@atlassian.com","avatar":null},"body":"Hello!\n\nThanks for you answer.\n\n\nThe original content of the file:\n\n\n--- START ---\n  LINE 1\n  LINE 2\n  LINE 3\n---  END  —\n\n\n\nBranch “change-a” modifies it to become:\n\n\n--- START ---\n  LINE 1\n  LINE 2\n  LINE 3\n  LINE 4\n  LINE 5\n  LINE 6\n  LINE 7\n  LINE 8\n  LINE 9\n---  END  —\n\nWhile branch “change-b” modifies it to become:\n\n\n--- START ---\n  LINE 1\n  LINE B\n  LINE 3\n  LINE D\n  LINE E\n  LINE 3\n---  END  —\n\nNow, on master I’m able to perform “—no-ff” merge with and git does not detect any conflict.\nThe result is this:\n\n\n--- START ---\n  LINE 1\n  LINE B\n  LINE 3\n  LINE D\n  LINE E\n  LINE 3\n  LINE 4\n  LINE 5\n  LINE 6\n  LINE 7\n  LINE 8\n  LINE 9\n---  END  —\n\nWhich is both changes applied sequentially - first, the change from “change-b” as it happens to be earlier in the file, then change from “change-a”.\n\n\nThank you,\nAnton.\n\n\n\n\n\n> On 2 Jul 2019, at 10:15 am, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> \n> Anton Ermolenko wrote:\n> \n>> My understanding is that recursive merge here won't consider that situation to\n>> be a merge conflict as the changes have been introduced in different spots in\n>> the file.\n> \n> Yes, that seems right to me.\n> \n> Do you have more details about the context?  What do these files look\n> like?  Are there other cues that we could use to discover that the\n> customer intended the changes to conflict?\n> \n> Thanks,\n> Jonathan\n\n"}]}