{"action":"created","issue":{"url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1123","labels_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1123/labels{/name}","comments_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1123/comments","events_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1123/events","html_url":"https://github.com/libgit2/libgit2sharp/pull/1123","id":91318077,"number":1123,"title":"Allow libgit2# to redirect the global/system/xdg config search path","user":{"login":"rcorre","id":2496231,"avatar_url":"https://avatars.githubusercontent.com/u/2496231?v=3","gravatar_id":"","url":"https://api.github.com/users/rcorre","html_url":"https://github.com/rcorre","followers_url":"https://api.github.com/users/rcorre/followers","following_url":"https://api.github.com/users/rcorre/following{/other_user}","gists_url":"https://api.github.com/users/rcorre/gists{/gist_id}","starred_url":"https://api.github.com/users/rcorre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rcorre/subscriptions","organizations_url":"https://api.github.com/users/rcorre/orgs","repos_url":"https://api.github.com/users/rcorre/repos","events_url":"https://api.github.com/users/rcorre/events{/privacy}","received_events_url":"https://api.github.com/users/rcorre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":42,"created_at":"2015-06-26T17:44:09Z","updated_at":"2015-09-09T21:35:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1123","html_url":"https://github.com/libgit2/libgit2sharp/pull/1123","diff_url":"https://github.com/libgit2/libgit2sharp/pull/1123.diff","patch_url":"https://github.com/libgit2/libgit2sharp/pull/1123.patch"},"body":"This provides an interface for libgit2# to redirect config file lookups via libgit2's `git_libgit2_opt`.\r\n\r\nThis is useful for unit-testing methods that hit the global, system, or xdg config files.\r\n\r\nIt is currently possible to redirect config access using `RepositoryOptions`, but this only works if the functions you are testing take a `Repository` as an argument. This isn't much of a problem for libgit2#, but other frameworks may not want to pass a `Repository` all the way through their call stack to support testing with a faked config. This provides a more foolproof way to sandbox your tests as it guarantees that all config access is redirected (libgit2 [uses this for testing](https://github.com/libgit2/libgit2/blob/c7f94123569e8fe00ffb3a35e6a12b6ebe9320ec/tests/config/global.c#L5)).\r\n\r\nThe first commit adds the actual functionality. `git_libgit2_opts` has a number of other options -- I only added bindings for search path redirection, but this sets the stage for binding other libgit2 settings if they are needed.\r\n\r\nThe second commit shows how this could be used within libgit2# tests. The current redirection scheme can be flaky -- I noticed some tests failing because they [only redirected system config access](https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs#L1049), and my personal global config was interfering.\r\nThe test could be fixed without this, of course, but I think this will help prevent mistakes in the long run.\r\n\r\n[EDIT]\r\nI've removed the second commit for now -- my partial fixup of the test fixtures was causing problems in as many tests as it fixed.\r\n\r\nThis PR just allows libgit2# consumers to redirect config access, I can work on a second PR to use this in the lg2# test fixtures if it seems like a good idea (started [here](https://github.com/rcorre/libgit2sharp/commit/f5002458f9e8a8867a86c89e5c297678c084d650))."},"comment":{"url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/comments/139052487","html_url":"https://github.com/libgit2/libgit2sharp/pull/1123#issuecomment-139052487","issue_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1123","id":139052487,"user":{"login":"nulltoken","id":92363,"avatar_url":"https://avatars.githubusercontent.com/u/92363?v=3","gravatar_id":"","url":"https://api.github.com/users/nulltoken","html_url":"https://github.com/nulltoken","followers_url":"https://api.github.com/users/nulltoken/followers","following_url":"https://api.github.com/users/nulltoken/following{/other_user}","gists_url":"https://api.github.com/users/nulltoken/gists{/gist_id}","starred_url":"https://api.github.com/users/nulltoken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nulltoken/subscriptions","organizations_url":"https://api.github.com/users/nulltoken/orgs","repos_url":"https://api.github.com/users/nulltoken/repos","events_url":"https://api.github.com/users/nulltoken/events{/privacy}","received_events_url":"https://api.github.com/users/nulltoken/received_events","type":"User","site_admin":false},"created_at":"2015-09-09T21:35:16Z","updated_at":"2015-09-09T21:35:16Z","body":"> @nulltoken: squashed and ready to go\r\n\r\n@rcorre :heart: Let's merge it. Awesome job!\r\n\r\n> I am sad Configs are no longer an option. :(\r\n\r\n@Therzok I'm going to open an issue discussing the potential deprecation of those"}}