{"action":"opened","number":3564,"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/3564","id":54606577,"html_url":"https://github.com/libgit2/libgit2/pull/3564","diff_url":"https://github.com/libgit2/libgit2/pull/3564.diff","patch_url":"https://github.com/libgit2/libgit2/pull/3564.patch","issue_url":"https://api.github.com/repos/libgit2/libgit2/issues/3564","number":3564,"state":"open","locked":false,"title":"Custom merge drivers and proper gitattributes `merge` handling","user":{"login":"ethomson","id":1130014,"avatar_url":"https://avatars.githubusercontent.com/u/1130014?v=3","gravatar_id":"","url":"https://api.github.com/users/ethomson","html_url":"https://github.com/ethomson","followers_url":"https://api.github.com/users/ethomson/followers","following_url":"https://api.github.com/users/ethomson/following{/other_user}","gists_url":"https://api.github.com/users/ethomson/gists{/gist_id}","starred_url":"https://api.github.com/users/ethomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethomson/subscriptions","organizations_url":"https://api.github.com/users/ethomson/orgs","repos_url":"https://api.github.com/users/ethomson/repos","events_url":"https://api.github.com/users/ethomson/events{/privacy}","received_events_url":"https://api.github.com/users/ethomson/received_events","type":"User","site_admin":false},"body":"While #3497 added support for `merge=union` in `.gitattributes`, I felt that we should have a more complete story for handling the `merge` attribute.  This PR:\r\n\r\n1. Adds a framework for adding custom merge drivers.  This is heavily inspired by the custom filter framework, and a consumer can add one or more custom merge drivers by name (for example, you may add a new `custom` driver) or - probably more useful - can add a wildcard merge driver.  This allows a consumer to be given the option to handle all configured merge drivers that are not built-in.\r\n\r\n    For example, a consumer could register a custom merge driver for the wildcard (`*`).  If there were a `merge=custom` line in a `.gitattributes` for a file, the configured merge driver would be given the information about the file changes and the `.gitattributes` configuration.  The driver could (for example) look for the corresponding `custom` merge driver and - if found - elect to accept responsibility for this change.  It would then invoke the `custom` merge driver and provide the results back.\r\n\r\n    The merge driver may also defer the check, at which point libgit2 will invoke the default built-in merge driver.  This is equivalent to when a user has configured `merge=foobar` in their `.gitattributes` but has not configured the `foobar` merge driver.  The merge driver configuration is ignored, and git will simply behave as if it was not configured at all.\r\n\r\n2. Additional handling for the [`merge` attribute](http://git-scm.com/docs/gitattributes).  When set (eg, `merge`) this will indicate that the file is mergeable and the default built-in `text` driver should be used.  When unset (eg, `-merge`) this will indicate that the file is binary and should not be merged (ie, is simply a conflict).  When unspecified (eg, no merge line) this indicates that the file is text but if a `merge.default` configuration setting exists, that will specify the driver to be used (otherwise the built-in `text` driver will be used).  Finally, if it is set to a string (eg, `merge=foobar`) then that indicates the driver to be used.\r\n\r\nAny of the built-in drivers (`text`, `binary` or `union`) may be specified.\r\n\r\n3. Proper handling of the `merge.default` configuration setting.  Query the `merge.default` to get the default merge driver name and use it when the `merge` attribute is not specified for a file.\r\n\r\nFixes #3497 \r\nFixes #2180 ","created_at":"2015-12-26T19:48:32Z","updated_at":"2015-12-26T19:48:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3564/commits","review_comments_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3564/comments","review_comment_url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/libgit2/issues/3564/comments","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/b45224a51406c02ac0079236397494c375d06e24","head":{"label":"ethomson:merge_drivers","ref":"merge_drivers","sha":"b45224a51406c02ac0079236397494c375d06e24","user":{"login":"ethomson","id":1130014,"avatar_url":"https://avatars.githubusercontent.com/u/1130014?v=3","gravatar_id":"","url":"https://api.github.com/users/ethomson","html_url":"https://github.com/ethomson","followers_url":"https://api.github.com/users/ethomson/followers","following_url":"https://api.github.com/users/ethomson/following{/other_user}","gists_url":"https://api.github.com/users/ethomson/gists{/gist_id}","starred_url":"https://api.github.com/users/ethomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethomson/subscriptions","organizations_url":"https://api.github.com/users/ethomson/orgs","repos_url":"https://api.github.com/users/ethomson/repos","events_url":"https://api.github.com/users/ethomson/events{/privacy}","received_events_url":"https://api.github.com/users/ethomson/received_events","type":"User","site_admin":false},"repo":{"id":6315414,"name":"libgit2","full_name":"ethomson/libgit2","owner":{"login":"ethomson","id":1130014,"avatar_url":"https://avatars.githubusercontent.com/u/1130014?v=3","gravatar_id":"","url":"https://api.github.com/users/ethomson","html_url":"https://github.com/ethomson","followers_url":"https://api.github.com/users/ethomson/followers","following_url":"https://api.github.com/users/ethomson/following{/other_user}","gists_url":"https://api.github.com/users/ethomson/gists{/gist_id}","starred_url":"https://api.github.com/users/ethomson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethomson/subscriptions","organizations_url":"https://api.github.com/users/ethomson/orgs","repos_url":"https://api.github.com/users/ethomson/repos","events_url":"https://api.github.com/users/ethomson/events{/privacy}","received_events_url":"https://api.github.com/users/ethomson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ethomson/libgit2","description":"The Library","fork":true,"url":"https://api.github.com/repos/ethomson/libgit2","forks_url":"https://api.github.com/repos/ethomson/libgit2/forks","keys_url":"https://api.github.com/repos/ethomson/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethomson/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethomson/libgit2/teams","hooks_url":"https://api.github.com/repos/ethomson/libgit2/hooks","issue_events_url":"https://api.github.com/repos/ethomson/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/ethomson/libgit2/events","assignees_url":"https://api.github.com/repos/ethomson/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/ethomson/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/ethomson/libgit2/tags","blobs_url":"https://api.github.com/repos/ethomson/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethomson/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethomson/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethomson/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethomson/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/ethomson/libgit2/languages","stargazers_url":"https://api.github.com/repos/ethomson/libgit2/stargazers","contributors_url":"https://api.github.com/repos/ethomson/libgit2/contributors","subscribers_url":"https://api.github.com/repos/ethomson/libgit2/subscribers","subscription_url":"https://api.github.com/repos/ethomson/libgit2/subscription","commits_url":"https://api.github.com/repos/ethomson/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethomson/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethomson/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethomson/libgit2/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethomson/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/ethomson/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethomson/libgit2/merges","archive_url":"https://api.github.com/repos/ethomson/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethomson/libgit2/downloads","issues_url":"https://api.github.com/repos/ethomson/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/ethomson/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/ethomson/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/ethomson/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethomson/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/ethomson/libgit2/releases{/id}","created_at":"2012-10-21T00:45:28Z","updated_at":"2015-03-30T13:32:43Z","pushed_at":"2015-12-26T19:48:06Z","git_url":"git://github.com/ethomson/libgit2.git","ssh_url":"git@github.com:ethomson/libgit2.git","clone_url":"https://github.com/ethomson/libgit2.git","svn_url":"https://github.com/ethomson/libgit2","homepage":"http://libgit2.github.com","size":22522,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"libgit2:master","ref":"master","sha":"3d29b12c9c8ba3272bbc5523fccde96c06ee6b83","user":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"repo":{"id":901662,"name":"libgit2","full_name":"libgit2/libgit2","owner":{"login":"libgit2","id":394745,"avatar_url":"https://avatars.githubusercontent.com/u/394745?v=3","gravatar_id":"","url":"https://api.github.com/users/libgit2","html_url":"https://github.com/libgit2","followers_url":"https://api.github.com/users/libgit2/followers","following_url":"https://api.github.com/users/libgit2/following{/other_user}","gists_url":"https://api.github.com/users/libgit2/gists{/gist_id}","starred_url":"https://api.github.com/users/libgit2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/libgit2/subscriptions","organizations_url":"https://api.github.com/users/libgit2/orgs","repos_url":"https://api.github.com/users/libgit2/repos","events_url":"https://api.github.com/users/libgit2/events{/privacy}","received_events_url":"https://api.github.com/users/libgit2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/libgit2/libgit2","description":"The Library","fork":false,"url":"https://api.github.com/repos/libgit2/libgit2","forks_url":"https://api.github.com/repos/libgit2/libgit2/forks","keys_url":"https://api.github.com/repos/libgit2/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/libgit2/teams","hooks_url":"https://api.github.com/repos/libgit2/libgit2/hooks","issue_events_url":"https://api.github.com/repos/libgit2/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/libgit2/events","assignees_url":"https://api.github.com/repos/libgit2/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/libgit2/tags","blobs_url":"https://api.github.com/repos/libgit2/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/libgit2/languages","stargazers_url":"https://api.github.com/repos/libgit2/libgit2/stargazers","contributors_url":"https://api.github.com/repos/libgit2/libgit2/contributors","subscribers_url":"https://api.github.com/repos/libgit2/libgit2/subscribers","subscription_url":"https://api.github.com/repos/libgit2/libgit2/subscription","commits_url":"https://api.github.com/repos/libgit2/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/libgit2/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/libgit2/merges","archive_url":"https://api.github.com/repos/libgit2/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/libgit2/downloads","issues_url":"https://api.github.com/repos/libgit2/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/libgit2/releases{/id}","created_at":"2010-09-10T16:17:48Z","updated_at":"2015-12-26T15:38:16Z","pushed_at":"2015-12-26T19:48:32Z","git_url":"git://github.com/libgit2/libgit2.git","ssh_url":"git@github.com:libgit2/libgit2.git","clone_url":"https://github.com/libgit2/libgit2.git","svn_url":"https://github.com/libgit2/libgit2","homepage":"http://libgit2.github.com","size":33092,"stargazers_count":5381,"watchers_count":5381,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1281,"mirror_url":null,"open_issues_count":136,"forks":1281,"open_issues":136,"watchers":5381,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3564"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3564"},"issue":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3564"},"comments":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3564/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3564/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3564/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/libgit2/statuses/b45224a51406c02ac0079236397494c375d06e24"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":8,"additions":1425,"deletions":113,"changed_files":9}}