{"action":"created","comment":{"url":"https://api.github.com/repos/relaxedws/merge/pulls/comments/67378202","id":67378202,"diff_hunk":"@@ -0,0 +1,206 @@\n+<?php\n+\n+namespace Relaxed\\Merge\\ThreeWayMerge;\n+\n+use Exception;\n+\n+class ThreeWayMerge\n+{\n+    public function performMerge(array $ancestor, array $local, array $remote)\n+    {\n+        // Returning a new Array for now. Can return the modified ancestor as well.\n+        $merged = [];\n+        foreach ($ancestor as $key => $value) {\n+            if (is_array($value)) {\n+                $merged[$key] = $this->performMerge(\n+                    $value,\n+                    $local[$key],\n+                    $remote[$key]\n+                );\n+            } else {\n+                $merged[$key] = $this->merge(\n+                    $ancestor[$key],\n+                    $local[$key],\n+                    $remote[$key],\n+                    $key\n+                );\n+                if ($merged[$key] == null) {\n+                    unset($merged[$key]);\n+                }\n+            }\n+        }\n+        return $merged;\n+    }\n+\n+    protected function merge($x, $y, $z, $key)\n+    {\n+        $ancestor = (strpos($x, \"\\n\") !== false ? explode(\"\\n\", $x) : array($x));\n+        $local = (strpos($y, \"\\n\") !== false ? explode(\"\\n\", $y) : array($y));\n+        $remote = (strpos($z, \"\\n\") !== false ? explode(\"\\n\", $z) : array($z));\n+        $count_ancestor = count($ancestor);\n+        $count_remote = count($remote);\n+        $count_local = count($local);\n+        if ($count_ancestor != $count_local\n+            && $count_local!= $count_remote\n+            && $count_ancestor != $count_remote\n+        ) {\n+            $merged = $this->linesModified(\n+                $ancestor,\n+                $local,\n+                $remote,\n+                $count_ancestor,\n+                $count_local,\n+                $count_remote\n+            );\n+        } else {\n+            $count = $count_ancestor == $count_local ? $count_remote : $count_local;\n+            $merged = $count > $count_ancestor ?\n+                $this->linesAdded(\n+                    $ancestor,\n+                    $local,\n+                    $remote,\n+                    $count,\n+                    $count_remote,\n+                    $count_ancestor,\n+                    $count_local\n+                ) :\n+                $this->linesRemovedOrModified($ancestor, $local, $remote, $count);","path":"src/ThreeWayMerge.php","position":67,"original_position":67,"commit_id":"9c20f2ebc73aef8cf13818879ad5f15799c19506","original_commit_id":"9c20f2ebc73aef8cf13818879ad5f15799c19506","user":{"login":"dickolsson","id":112085,"avatar_url":"https://avatars.githubusercontent.com/u/112085?v=3","gravatar_id":"","url":"https://api.github.com/users/dickolsson","html_url":"https://github.com/dickolsson","followers_url":"https://api.github.com/users/dickolsson/followers","following_url":"https://api.github.com/users/dickolsson/following{/other_user}","gists_url":"https://api.github.com/users/dickolsson/gists{/gist_id}","starred_url":"https://api.github.com/users/dickolsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dickolsson/subscriptions","organizations_url":"https://api.github.com/users/dickolsson/orgs","repos_url":"https://api.github.com/users/dickolsson/repos","events_url":"https://api.github.com/users/dickolsson/events{/privacy}","received_events_url":"https://api.github.com/users/dickolsson/received_events","type":"User","site_admin":false},"body":"To improve readability I think sections like this one should be broken out into full `if` `else` statements, instead of the shorthand versions of it.","created_at":"2016-06-16T16:28:11Z","updated_at":"2016-06-16T16:28:11Z","html_url":"https://github.com/relaxedws/merge/pull/2#discussion_r67378202","pull_request_url":"https://api.github.com/repos/relaxedws/merge/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/comments/67378202"},"html":{"href":"https://github.com/relaxedws/merge/pull/2#discussion_r67378202"},"pull_request":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/relaxedws/merge/pulls/2","id":73861687,"html_url":"https://github.com/relaxedws/merge/pull/2","diff_url":"https://github.com/relaxedws/merge/pull/2.diff","patch_url":"https://github.com/relaxedws/merge/pull/2.patch","issue_url":"https://api.github.com/repos/relaxedws/merge/issues/2","number":2,"state":"open","locked":false,"title":"Multi line merge functionality for merge library.","user":{"login":"sharprakeshverma","id":10394619,"avatar_url":"https://avatars.githubusercontent.com/u/10394619?v=3","gravatar_id":"","url":"https://api.github.com/users/sharprakeshverma","html_url":"https://github.com/sharprakeshverma","followers_url":"https://api.github.com/users/sharprakeshverma/followers","following_url":"https://api.github.com/users/sharprakeshverma/following{/other_user}","gists_url":"https://api.github.com/users/sharprakeshverma/gists{/gist_id}","starred_url":"https://api.github.com/users/sharprakeshverma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharprakeshverma/subscriptions","organizations_url":"https://api.github.com/users/sharprakeshverma/orgs","repos_url":"https://api.github.com/users/sharprakeshverma/repos","events_url":"https://api.github.com/users/sharprakeshverma/events{/privacy}","received_events_url":"https://api.github.com/users/sharprakeshverma/received_events","type":"User","site_admin":false},"body":"No Ready completely. Works fine for changes in same number of lines. \r\nAdding functionality for Addition and removal of lines as well.\r\nWill take care of keys addition and removal after that.\r\nTested at my end only. No tests have been added in the test file.","created_at":"2016-06-15T07:08:01Z","updated_at":"2016-06-16T16:28:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"231de270b6f062679c74cb05528f3100794e1616","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/relaxedws/merge/pulls/2/commits","review_comments_url":"https://api.github.com/repos/relaxedws/merge/pulls/2/comments","review_comment_url":"https://api.github.com/repos/relaxedws/merge/pulls/comments{/number}","comments_url":"https://api.github.com/repos/relaxedws/merge/issues/2/comments","statuses_url":"https://api.github.com/repos/relaxedws/merge/statuses/9c20f2ebc73aef8cf13818879ad5f15799c19506","head":{"label":"sharprakeshverma:multiline","ref":"multiline","sha":"9c20f2ebc73aef8cf13818879ad5f15799c19506","user":{"login":"sharprakeshverma","id":10394619,"avatar_url":"https://avatars.githubusercontent.com/u/10394619?v=3","gravatar_id":"","url":"https://api.github.com/users/sharprakeshverma","html_url":"https://github.com/sharprakeshverma","followers_url":"https://api.github.com/users/sharprakeshverma/followers","following_url":"https://api.github.com/users/sharprakeshverma/following{/other_user}","gists_url":"https://api.github.com/users/sharprakeshverma/gists{/gist_id}","starred_url":"https://api.github.com/users/sharprakeshverma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharprakeshverma/subscriptions","organizations_url":"https://api.github.com/users/sharprakeshverma/orgs","repos_url":"https://api.github.com/users/sharprakeshverma/repos","events_url":"https://api.github.com/users/sharprakeshverma/events{/privacy}","received_events_url":"https://api.github.com/users/sharprakeshverma/received_events","type":"User","site_admin":false},"repo":{"id":59297006,"name":"merge","full_name":"sharprakeshverma/merge","owner":{"login":"sharprakeshverma","id":10394619,"avatar_url":"https://avatars.githubusercontent.com/u/10394619?v=3","gravatar_id":"","url":"https://api.github.com/users/sharprakeshverma","html_url":"https://github.com/sharprakeshverma","followers_url":"https://api.github.com/users/sharprakeshverma/followers","following_url":"https://api.github.com/users/sharprakeshverma/following{/other_user}","gists_url":"https://api.github.com/users/sharprakeshverma/gists{/gist_id}","starred_url":"https://api.github.com/users/sharprakeshverma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharprakeshverma/subscriptions","organizations_url":"https://api.github.com/users/sharprakeshverma/orgs","repos_url":"https://api.github.com/users/sharprakeshverma/repos","events_url":"https://api.github.com/users/sharprakeshverma/events{/privacy}","received_events_url":"https://api.github.com/users/sharprakeshverma/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sharprakeshverma/merge","description":"","fork":true,"url":"https://api.github.com/repos/sharprakeshverma/merge","forks_url":"https://api.github.com/repos/sharprakeshverma/merge/forks","keys_url":"https://api.github.com/repos/sharprakeshverma/merge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sharprakeshverma/merge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sharprakeshverma/merge/teams","hooks_url":"https://api.github.com/repos/sharprakeshverma/merge/hooks","issue_events_url":"https://api.github.com/repos/sharprakeshverma/merge/issues/events{/number}","events_url":"https://api.github.com/repos/sharprakeshverma/merge/events","assignees_url":"https://api.github.com/repos/sharprakeshverma/merge/assignees{/user}","branches_url":"https://api.github.com/repos/sharprakeshverma/merge/branches{/branch}","tags_url":"https://api.github.com/repos/sharprakeshverma/merge/tags","blobs_url":"https://api.github.com/repos/sharprakeshverma/merge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sharprakeshverma/merge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sharprakeshverma/merge/git/refs{/sha}","trees_url":"https://api.github.com/repos/sharprakeshverma/merge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sharprakeshverma/merge/statuses/{sha}","languages_url":"https://api.github.com/repos/sharprakeshverma/merge/languages","stargazers_url":"https://api.github.com/repos/sharprakeshverma/merge/stargazers","contributors_url":"https://api.github.com/repos/sharprakeshverma/merge/contributors","subscribers_url":"https://api.github.com/repos/sharprakeshverma/merge/subscribers","subscription_url":"https://api.github.com/repos/sharprakeshverma/merge/subscription","commits_url":"https://api.github.com/repos/sharprakeshverma/merge/commits{/sha}","git_commits_url":"https://api.github.com/repos/sharprakeshverma/merge/git/commits{/sha}","comments_url":"https://api.github.com/repos/sharprakeshverma/merge/comments{/number}","issue_comment_url":"https://api.github.com/repos/sharprakeshverma/merge/issues/comments{/number}","contents_url":"https://api.github.com/repos/sharprakeshverma/merge/contents/{+path}","compare_url":"https://api.github.com/repos/sharprakeshverma/merge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sharprakeshverma/merge/merges","archive_url":"https://api.github.com/repos/sharprakeshverma/merge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sharprakeshverma/merge/downloads","issues_url":"https://api.github.com/repos/sharprakeshverma/merge/issues{/number}","pulls_url":"https://api.github.com/repos/sharprakeshverma/merge/pulls{/number}","milestones_url":"https://api.github.com/repos/sharprakeshverma/merge/milestones{/number}","notifications_url":"https://api.github.com/repos/sharprakeshverma/merge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sharprakeshverma/merge/labels{/name}","releases_url":"https://api.github.com/repos/sharprakeshverma/merge/releases{/id}","deployments_url":"https://api.github.com/repos/sharprakeshverma/merge/deployments","created_at":"2016-05-20T13:35:08Z","updated_at":"2016-06-10T23:38:55Z","pushed_at":"2016-06-16T11:19:27Z","git_url":"git://github.com/sharprakeshverma/merge.git","ssh_url":"git@github.com:sharprakeshverma/merge.git","clone_url":"https://github.com/sharprakeshverma/merge.git","svn_url":"https://github.com/sharprakeshverma/merge","homepage":null,"size":38,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"relaxedws:master","ref":"master","sha":"8d884c15e1a052459d1b16bdc4ee06024df11b03","user":{"login":"relaxedws","id":10012156,"avatar_url":"https://avatars.githubusercontent.com/u/10012156?v=3","gravatar_id":"","url":"https://api.github.com/users/relaxedws","html_url":"https://github.com/relaxedws","followers_url":"https://api.github.com/users/relaxedws/followers","following_url":"https://api.github.com/users/relaxedws/following{/other_user}","gists_url":"https://api.github.com/users/relaxedws/gists{/gist_id}","starred_url":"https://api.github.com/users/relaxedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/relaxedws/subscriptions","organizations_url":"https://api.github.com/users/relaxedws/orgs","repos_url":"https://api.github.com/users/relaxedws/repos","events_url":"https://api.github.com/users/relaxedws/events{/privacy}","received_events_url":"https://api.github.com/users/relaxedws/received_events","type":"Organization","site_admin":false},"repo":{"id":59295163,"name":"merge","full_name":"relaxedws/merge","owner":{"login":"relaxedws","id":10012156,"avatar_url":"https://avatars.githubusercontent.com/u/10012156?v=3","gravatar_id":"","url":"https://api.github.com/users/relaxedws","html_url":"https://github.com/relaxedws","followers_url":"https://api.github.com/users/relaxedws/followers","following_url":"https://api.github.com/users/relaxedws/following{/other_user}","gists_url":"https://api.github.com/users/relaxedws/gists{/gist_id}","starred_url":"https://api.github.com/users/relaxedws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/relaxedws/subscriptions","organizations_url":"https://api.github.com/users/relaxedws/orgs","repos_url":"https://api.github.com/users/relaxedws/repos","events_url":"https://api.github.com/users/relaxedws/events{/privacy}","received_events_url":"https://api.github.com/users/relaxedws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/relaxedws/merge","description":"","fork":false,"url":"https://api.github.com/repos/relaxedws/merge","forks_url":"https://api.github.com/repos/relaxedws/merge/forks","keys_url":"https://api.github.com/repos/relaxedws/merge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/relaxedws/merge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/relaxedws/merge/teams","hooks_url":"https://api.github.com/repos/relaxedws/merge/hooks","issue_events_url":"https://api.github.com/repos/relaxedws/merge/issues/events{/number}","events_url":"https://api.github.com/repos/relaxedws/merge/events","assignees_url":"https://api.github.com/repos/relaxedws/merge/assignees{/user}","branches_url":"https://api.github.com/repos/relaxedws/merge/branches{/branch}","tags_url":"https://api.github.com/repos/relaxedws/merge/tags","blobs_url":"https://api.github.com/repos/relaxedws/merge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/relaxedws/merge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/relaxedws/merge/git/refs{/sha}","trees_url":"https://api.github.com/repos/relaxedws/merge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/relaxedws/merge/statuses/{sha}","languages_url":"https://api.github.com/repos/relaxedws/merge/languages","stargazers_url":"https://api.github.com/repos/relaxedws/merge/stargazers","contributors_url":"https://api.github.com/repos/relaxedws/merge/contributors","subscribers_url":"https://api.github.com/repos/relaxedws/merge/subscribers","subscription_url":"https://api.github.com/repos/relaxedws/merge/subscription","commits_url":"https://api.github.com/repos/relaxedws/merge/commits{/sha}","git_commits_url":"https://api.github.com/repos/relaxedws/merge/git/commits{/sha}","comments_url":"https://api.github.com/repos/relaxedws/merge/comments{/number}","issue_comment_url":"https://api.github.com/repos/relaxedws/merge/issues/comments{/number}","contents_url":"https://api.github.com/repos/relaxedws/merge/contents/{+path}","compare_url":"https://api.github.com/repos/relaxedws/merge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/relaxedws/merge/merges","archive_url":"https://api.github.com/repos/relaxedws/merge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/relaxedws/merge/downloads","issues_url":"https://api.github.com/repos/relaxedws/merge/issues{/number}","pulls_url":"https://api.github.com/repos/relaxedws/merge/pulls{/number}","milestones_url":"https://api.github.com/repos/relaxedws/merge/milestones{/number}","notifications_url":"https://api.github.com/repos/relaxedws/merge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/relaxedws/merge/labels{/name}","releases_url":"https://api.github.com/repos/relaxedws/merge/releases{/id}","deployments_url":"https://api.github.com/repos/relaxedws/merge/deployments","created_at":"2016-05-20T13:09:19Z","updated_at":"2016-06-15T11:45:50Z","pushed_at":"2016-06-16T11:19:28Z","git_url":"git://github.com/relaxedws/merge.git","ssh_url":"git@github.com:relaxedws/merge.git","clone_url":"https://github.com/relaxedws/merge.git","svn_url":"https://github.com/relaxedws/merge","homepage":null,"size":31,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/2"},"html":{"href":"https://github.com/relaxedws/merge/pull/2"},"issue":{"href":"https://api.github.com/repos/relaxedws/merge/issues/2"},"comments":{"href":"https://api.github.com/repos/relaxedws/merge/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/relaxedws/merge/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/relaxedws/merge/statuses/9c20f2ebc73aef8cf13818879ad5f15799c19506"}}}}
{"actor":{"display_login":"dickolsson"}}