{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/68894472","id":68894472,"diff_hunk":"@@ -0,0 +1,152 @@\n+/*\n+ * Copyright (C) the libgit2 contributors. All rights reserved.\n+ *\n+ * This file is part of libgit2, distributed under the GNU GPL v2 with\n+ * a Linking Exception. For full terms see the included COPYING file.\n+ */\n+\n+#include \"common.h\"\n+#include \"posix.h\"\n+#include \"repository.h\"\n+\n+#include \"git2/hook.h\"\n+\n+#define GIT_HOOKS_DIR \"hooks/\"\n+\n+const char * const githooks[] = {\n+\t\"applypatch-msg\",\n+\t\"pre-applypatch\",\n+\t\"post-applypatch\",\n+\t\"pre-commit\",\n+\t\"prepare-commit-msg\",\n+\t\"commit-msg\",\n+\t\"post-commit\",\n+\t\"pre-rebase\",\n+\t\"post-checkout\",\n+\t\"post-merge\",\n+\t\"pre-push\",\n+\t\"pre-receive\",\n+\t\"update\",\n+\t\"post-receive\",\n+\t\"post-update\",\n+\t\"push-to-checkout\",\n+\t\"pre-auto-gc\",\n+\t\"post-rewrite\",\n+};\n+\n+#define MAX_HOOK_LEN 18+1\n+#define HOOK_FILE_MODE 0776\n+\n+static int build_hook_path(char **hook_path, git_repository *repo, const char *hook_name)\n+{\n+\tint hook_dir_len;\n+\n+\tassert(hook_path);\n+\n+\thook_dir_len = strlen(repo->path_repository) + strlen(GIT_HOOKS_DIR);\n+\t*hook_path = git__malloc(hook_dir_len + MAX_HOOK_LEN);\n+\tGITERR_CHECK_ALLOC(*hook_path);\n+\n+\tstrcpy(*hook_path, repo->path_repository);\n+\tstrcat(*hook_path, GIT_HOOKS_DIR);\n+\tstrcat(*hook_path, hook_name);\n+\n+\treturn 0;\n+}\n+\n+static int check_hook_path(const char *hook_path)\n+{\n+\tint err;\n+\tstruct stat hook_stat;\n+\n+\tassert(hook_path);\n+\n+\t/* Skip missing hooks */\n+\terr = p_stat(hook_path, &hook_stat);\n+\tif (err) return -1;\n+\n+\t/* Check exec bits */\n+\tif ((hook_stat.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0) return -1;","path":"src/hook.c","position":69,"original_position":69,"commit_id":"79a0548ba3c934726b5e462e8926aa454febe55d","original_commit_id":"79a0548ba3c934726b5e462e8926aa454febe55d","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":"Just wondering, do we really care for `S_IXOTH`? Above you've defined `HOOK_FILE_MODE` as being `0776`, that is the file is not executable for others.","created_at":"2016-06-29T06:59:14Z","updated_at":"2016-06-29T06:59:14Z","html_url":"https://github.com/libgit2/libgit2/pull/3824#discussion_r68894472","pull_request_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3824","_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments/68894472"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3824#discussion_r68894472"},"pull_request":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3824"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2/pulls/3824","id":74005169,"html_url":"https://github.com/libgit2/libgit2/pull/3824","diff_url":"https://github.com/libgit2/libgit2/pull/3824.diff","patch_url":"https://github.com/libgit2/libgit2/pull/3824.patch","issue_url":"https://api.github.com/repos/libgit2/libgit2/issues/3824","number":3824,"state":"open","locked":false,"title":"Hook support","user":{"login":"tiennou","id":81099,"avatar_url":"https://avatars.githubusercontent.com/u/81099?v=3","gravatar_id":"","url":"https://api.github.com/users/tiennou","html_url":"https://github.com/tiennou","followers_url":"https://api.github.com/users/tiennou/followers","following_url":"https://api.github.com/users/tiennou/following{/other_user}","gists_url":"https://api.github.com/users/tiennou/gists{/gist_id}","starred_url":"https://api.github.com/users/tiennou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiennou/subscriptions","organizations_url":"https://api.github.com/users/tiennou/orgs","repos_url":"https://api.github.com/users/tiennou/repos","events_url":"https://api.github.com/users/tiennou/events{/privacy}","received_events_url":"https://api.github.com/users/tiennou/received_events","type":"User","site_admin":false},"body":"This is a first pass at supporting hooks. It aims to provide the basic blocks (as per PROJECTS.md), so enumeration, loading and saving is supported, and there's a quick skeleton of how I'm planning to handle hook execution.\r\n\r\nA few points/questions :\r\n- I was under the impression there had already been some discussion around the design, but I haven't been able to find them.\r\n- The list of hooks is hardcoded. This is completely debatable, but given variable argument count, I thought something that acts as a \"we support these hooks\" was preferable to YMMV.\r\n- I seem to remember bindings don't like callbacks (and me too, given my current enumeration test is human-based :wink:). Should I provide an alternate way (e.g. `git_hook_iterator_new()`) ?\r\n- The plan for actually executing the hooks is to have something like `git_hook__execute(hook_name, ...)` and sprinkle those everywhere, but it might or might not be doable — I haven't been that far yet.","created_at":"2016-06-16T00:18:27Z","updated_at":"2016-06-29T06:59:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2ba6faca92b7b37669b3add6bdaebb5d6bf3d98b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3824/commits","review_comments_url":"https://api.github.com/repos/libgit2/libgit2/pulls/3824/comments","review_comment_url":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/libgit2/issues/3824/comments","statuses_url":"https://api.github.com/repos/libgit2/libgit2/statuses/79a0548ba3c934726b5e462e8926aa454febe55d","head":{"label":"tiennou:hooks","ref":"hooks","sha":"79a0548ba3c934726b5e462e8926aa454febe55d","user":{"login":"tiennou","id":81099,"avatar_url":"https://avatars.githubusercontent.com/u/81099?v=3","gravatar_id":"","url":"https://api.github.com/users/tiennou","html_url":"https://github.com/tiennou","followers_url":"https://api.github.com/users/tiennou/followers","following_url":"https://api.github.com/users/tiennou/following{/other_user}","gists_url":"https://api.github.com/users/tiennou/gists{/gist_id}","starred_url":"https://api.github.com/users/tiennou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiennou/subscriptions","organizations_url":"https://api.github.com/users/tiennou/orgs","repos_url":"https://api.github.com/users/tiennou/repos","events_url":"https://api.github.com/users/tiennou/events{/privacy}","received_events_url":"https://api.github.com/users/tiennou/received_events","type":"User","site_admin":false},"repo":{"id":11159911,"name":"libgit2","full_name":"tiennou/libgit2","owner":{"login":"tiennou","id":81099,"avatar_url":"https://avatars.githubusercontent.com/u/81099?v=3","gravatar_id":"","url":"https://api.github.com/users/tiennou","html_url":"https://github.com/tiennou","followers_url":"https://api.github.com/users/tiennou/followers","following_url":"https://api.github.com/users/tiennou/following{/other_user}","gists_url":"https://api.github.com/users/tiennou/gists{/gist_id}","starred_url":"https://api.github.com/users/tiennou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiennou/subscriptions","organizations_url":"https://api.github.com/users/tiennou/orgs","repos_url":"https://api.github.com/users/tiennou/repos","events_url":"https://api.github.com/users/tiennou/events{/privacy}","received_events_url":"https://api.github.com/users/tiennou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tiennou/libgit2","description":"The Library","fork":true,"url":"https://api.github.com/repos/tiennou/libgit2","forks_url":"https://api.github.com/repos/tiennou/libgit2/forks","keys_url":"https://api.github.com/repos/tiennou/libgit2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tiennou/libgit2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tiennou/libgit2/teams","hooks_url":"https://api.github.com/repos/tiennou/libgit2/hooks","issue_events_url":"https://api.github.com/repos/tiennou/libgit2/issues/events{/number}","events_url":"https://api.github.com/repos/tiennou/libgit2/events","assignees_url":"https://api.github.com/repos/tiennou/libgit2/assignees{/user}","branches_url":"https://api.github.com/repos/tiennou/libgit2/branches{/branch}","tags_url":"https://api.github.com/repos/tiennou/libgit2/tags","blobs_url":"https://api.github.com/repos/tiennou/libgit2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tiennou/libgit2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tiennou/libgit2/git/refs{/sha}","trees_url":"https://api.github.com/repos/tiennou/libgit2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tiennou/libgit2/statuses/{sha}","languages_url":"https://api.github.com/repos/tiennou/libgit2/languages","stargazers_url":"https://api.github.com/repos/tiennou/libgit2/stargazers","contributors_url":"https://api.github.com/repos/tiennou/libgit2/contributors","subscribers_url":"https://api.github.com/repos/tiennou/libgit2/subscribers","subscription_url":"https://api.github.com/repos/tiennou/libgit2/subscription","commits_url":"https://api.github.com/repos/tiennou/libgit2/commits{/sha}","git_commits_url":"https://api.github.com/repos/tiennou/libgit2/git/commits{/sha}","comments_url":"https://api.github.com/repos/tiennou/libgit2/comments{/number}","issue_comment_url":"https://api.github.com/repos/tiennou/libgit2/issues/comments{/number}","contents_url":"https://api.github.com/repos/tiennou/libgit2/contents/{+path}","compare_url":"https://api.github.com/repos/tiennou/libgit2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tiennou/libgit2/merges","archive_url":"https://api.github.com/repos/tiennou/libgit2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tiennou/libgit2/downloads","issues_url":"https://api.github.com/repos/tiennou/libgit2/issues{/number}","pulls_url":"https://api.github.com/repos/tiennou/libgit2/pulls{/number}","milestones_url":"https://api.github.com/repos/tiennou/libgit2/milestones{/number}","notifications_url":"https://api.github.com/repos/tiennou/libgit2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tiennou/libgit2/labels{/name}","releases_url":"https://api.github.com/repos/tiennou/libgit2/releases{/id}","deployments_url":"https://api.github.com/repos/tiennou/libgit2/deployments","created_at":"2013-07-03T19:51:56Z","updated_at":"2014-03-31T22:21:50Z","pushed_at":"2016-06-28T19:18:56Z","git_url":"git://github.com/tiennou/libgit2.git","ssh_url":"git@github.com:tiennou/libgit2.git","clone_url":"https://github.com/tiennou/libgit2.git","svn_url":"https://github.com/tiennou/libgit2","homepage":"http://libgit2.github.com","size":21086,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"development"}},"base":{"label":"libgit2:master","ref":"master","sha":"abb6f72aaacd4edb4131d1bdb8d0965bd189ee82","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-06-29T01:18:27Z","pushed_at":"2016-06-29T04:30:47Z","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":67936,"stargazers_count":5677,"watchers_count":5677,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1380,"mirror_url":null,"open_issues_count":161,"forks":1380,"open_issues":161,"watchers":5677,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3824"},"html":{"href":"https://github.com/libgit2/libgit2/pull/3824"},"issue":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3824"},"comments":{"href":"https://api.github.com/repos/libgit2/libgit2/issues/3824/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3824/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/libgit2/pulls/3824/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/libgit2/statuses/79a0548ba3c934726b5e462e8926aa454febe55d"}}}}
{"actor":{"display_login":"pks-t"}}