{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/73481086","id":73481086,"diff_hunk":"@@ -85,8 +85,12 @@ static int git_sysdir_guess_template_dirs(git_buf *out)\n \n typedef int (*git_sysdir_guess_cb)(git_buf *out);\n \n-static git_buf git_sysdir__dirs[GIT_SYSDIR__MAX] =\n-\t{ GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT };\n+struct git_sysdir__dir {\n+\tint initialized;\n+\tgit_buf buf;\n+};\n+\n+static struct git_sysdir__dir git_sysdir__dirs[GIT_SYSDIR__MAX];","path":"src/sysdir.c","position":11,"original_position":11,"commit_id":"ef0239676c9f0c248c49277979f139fcc2e0220b","original_commit_id":"ef0239676c9f0c248c49277979f139fcc2e0220b","user":{"login":"pks-t","id":4056630,"avatar_url":"https://avatars.githubusercontent.com/u/4056630?v=3","gravatar_id":"","url":"https://api.github.com/users/pks-t","html_url":"https://github.com/pks-t","followers_url":"https://api.github.com/users/pks-t/followers","following_url":"https://api.github.com/users/pks-t/following{/other_user}","gists_url":"https://api.github.com/users/pks-t/gists{/gist_id}","starred_url":"https://api.github.com/users/pks-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pks-t/subscriptions","organizations_url":"https://api.github.com/users/pks-t/orgs","repos_url":"https://api.github.com/users/pks-t/repos","events_url":"https://api.github.com/users/pks-t/events{/privacy}","received_events_url":"https://api.github.com/users/pks-t/received_events","type":"User","site_admin":false},"body":"Hum. If you're already creating a new sysdir struct, what do you think about including the guess callbacks into the struct and then drop the `git_sysdir__dir_guess` array? So basically\r\n\r\n```\r\nstatic struct git_sysdir__dir dirs[] = {\r\n    { git_sysdir_guess_system_dirs, GIT_BUF_INIT },\r\n    { git_sysdir_guess_global_dirs, GIT_BUF_INIT },\r\n    ...\r\n};\r\n```\r\n\r\nThis would make the correlation of these two structures clearer and reduce a bit of its magic.","created_at":"2016-08-04T08:24:26Z","updated_at":"2016-08-04T08:24:26Z","html_url":"https://github.com/libgit2/libgit2/pull/3877#discussion_r73481086","pull_request_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3877","_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/73481086"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3877#discussion_r73481086"},"pull_request":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3877"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/3877","id":79391514,"html_url":"https://github.com/libgit2/libgit2/pull/3877","diff_url":"https://github.com/libgit2/libgit2/pull/3877.diff","patch_url":"https://github.com/libgit2/libgit2/pull/3877.patch","issue_url":"https://api.github.com/repos/libgit2/libgit2/issues/3877","number":3877,"state":"open","locked":false,"title":"sysdir: don't assume an empty dir is uninitialized","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":true},"body":"Don't assume that an empty system directory buffer is uninitialized.\r\nIn fact, there simply may be no appropriate path for that value.\r\n(For example, the Windows-specific programdata directory has no value\r\non non-Windows machines.)\r\n\r\nThis prevents us from continually trying to re-lookup these values,\r\nwhich could get racy if two different threads are each calling\r\n`git_sysdir_get` and trying to lookup / clear the value simultaneously.\r\n\r\nFixes #3871 ","created_at":"2016-07-29T17:03:52Z","updated_at":"2016-08-04T08:24:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5931fb3cf7f0996561ed60fe0fcb8412ac77b80b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3877/commits","review_comments_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3877/comments","review_comment_url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/libgit2/issues/3877/comments","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/ef0239676c9f0c248c49277979f139fcc2e0220b","head":{"label":"libgit2:ethomson/paths_init","ref":"ethomson/paths_init","sha":"ef0239676c9f0c248c49277979f139fcc2e0220b","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}","deployments_url":"https://api.github.com/repos/libgit2/libgit2/deployments","created_at":"2010-09-10T16:17:48Z","updated_at":"2016-08-04T02:30:51Z","pushed_at":"2016-08-04T02:00:22Z","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":65923,"stargazers_count":5721,"watchers_count":5721,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1392,"mirror_url":null,"open_issues_count":170,"forks":1392,"open_issues":170,"watchers":5721,"default_branch":"master"}},"base":{"label":"libgit2:master","ref":"master","sha":"152efee20b74ea261cf8e05410a110687e17376e","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}","deployments_url":"https://api.github.com/repos/libgit2/libgit2/deployments","created_at":"2010-09-10T16:17:48Z","updated_at":"2016-08-04T02:30:51Z","pushed_at":"2016-08-04T02:00:22Z","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":65923,"stargazers_count":5721,"watchers_count":5721,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1392,"mirror_url":null,"open_issues_count":170,"forks":1392,"open_issues":170,"watchers":5721,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3877"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3877"},"issue":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3877"},"comments":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3877/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3877/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3877/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/libgit2/statuses/ef0239676c9f0c248c49277979f139fcc2e0220b"}}}}
{"actor":{"display_login":"pks-t"}}