{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/rugged/pulls/comments/37806412","id":37806412,"diff_hunk":"@@ -111,6 +111,28 @@ static VALUE rb_git_features(VALUE self)\n \n /*\n  *  call-seq:\n+ *    Rugged.valid_full_oid?(oid) -> true or false\n+ *\n+ *  Checks to see if a string contains a full 40-character sha1.\n+ *\n+ *    Rugged.valid_full_oid?('d8786bfc97485e8d7b19b21fb88c8ef1f199fc3f')\n+ *    #=> true\n+ */\n+static VALUE rb_git_valid_full_oid(VALUE self, VALUE hex)\n+{\n+\tgit_oid oid;\n+\n+\tCheck_Type(hex, T_STRING);\n+\tint errorcode = git_oid_fromstr(&oid, StringValueCStr(hex));","path":"ext/rugged/rugged.c","position":null,"original_position":16,"commit_id":"e849be62c70a550173b35cfc1b5673aa98910772","original_commit_id":"a3ba51f19d1f574eed8b2cc203a6d3b7425ed583","user":{"login":"carlosmn","id":335443,"avatar_url":"https://avatars.githubusercontent.com/u/335443?v=3","gravatar_id":"","url":"https://api.github.com/users/carlosmn","html_url":"https://github.com/carlosmn","followers_url":"https://api.github.com/users/carlosmn/followers","following_url":"https://api.github.com/users/carlosmn/following{/other_user}","gists_url":"https://api.github.com/users/carlosmn/gists{/gist_id}","starred_url":"https://api.github.com/users/carlosmn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlosmn/subscriptions","organizations_url":"https://api.github.com/users/carlosmn/orgs","repos_url":"https://api.github.com/users/carlosmn/repos","events_url":"https://api.github.com/users/carlosmn/events{/privacy}","received_events_url":"https://api.github.com/users/carlosmn/received_events","type":"User","site_admin":false},"body":"C89 fo' lyfe, yo","created_at":"2015-08-24T21:21:41Z","updated_at":"2015-08-24T21:21:41Z","html_url":"https://github.com/libgit2/rugged/pull/514#discussion_r37806412","pull_request_url":"https://api.github.com/repos/libgit2/rugged/pulls/514","_links":{"self":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/comments/37806412"},"html":{"href":"https://github.com/libgit2/rugged/pull/514#discussion_r37806412"},"pull_request":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/514"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/rugged/pulls/514","id":43221171,"html_url":"https://github.com/libgit2/rugged/pull/514","diff_url":"https://github.com/libgit2/rugged/pull/514.diff","patch_url":"https://github.com/libgit2/rugged/pull/514.patch","issue_url":"https://api.github.com/repos/libgit2/rugged/issues/514","number":514,"state":"closed","locked":false,"title":"Add Rugged.valid_full_oid? helper method","user":{"login":"brianmario","id":11571,"avatar_url":"https://avatars.githubusercontent.com/u/11571?v=3","gravatar_id":"","url":"https://api.github.com/users/brianmario","html_url":"https://github.com/brianmario","followers_url":"https://api.github.com/users/brianmario/followers","following_url":"https://api.github.com/users/brianmario/following{/other_user}","gists_url":"https://api.github.com/users/brianmario/gists{/gist_id}","starred_url":"https://api.github.com/users/brianmario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianmario/subscriptions","organizations_url":"https://api.github.com/users/brianmario/orgs","repos_url":"https://api.github.com/users/brianmario/repos","events_url":"https://api.github.com/users/brianmario/events{/privacy}","received_events_url":"https://api.github.com/users/brianmario/received_events","type":"User","site_admin":true},"body":"Previously I've been using regex to check the validity of a string as a full 40-character sha1, but decided to benchmark that against the `Rugged.hex_to_raw` method and found it to be ~6x faster. Only bummer was that `hex_to_raw` will raise if the input string was invalid, and in that case ended up only being about 1.5x faster.\r\n\r\nSo this extracts just the validity check and returns a boolean value. Meaning we can skip the raise/rescue slowdown as well as creating the output string that `hex_to_raw` would have made.","created_at":"2015-08-24T21:00:07Z","updated_at":"2015-08-24T21:21:41Z","closed_at":"2015-08-24T21:14:03Z","merged_at":"2015-08-24T21:14:03Z","merge_commit_sha":"d38181d7a6b9760fe19b36a0b2821ae85d9ad5f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/rugged/pulls/514/commits","review_comments_url":"https://api.github.com/repos/libgit2/rugged/pulls/514/comments","review_comment_url":"https://api.github.com/repos/libgit2/rugged/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/rugged/issues/514/comments","statuses_url":"https://api.github.com/repos/libgit2/rugged/statuses/e849be62c70a550173b35cfc1b5673aa98910772","head":{"label":"libgit2:brianmario/add-valid-full-oid-helper","ref":"brianmario/add-valid-full-oid-helper","sha":"e849be62c70a550173b35cfc1b5673aa98910772","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":901663,"name":"rugged","full_name":"libgit2/rugged","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/rugged","description":"ruby bindings to libgit2","fork":false,"url":"https://api.github.com/repos/libgit2/rugged","forks_url":"https://api.github.com/repos/libgit2/rugged/forks","keys_url":"https://api.github.com/repos/libgit2/rugged/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/rugged/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/rugged/teams","hooks_url":"https://api.github.com/repos/libgit2/rugged/hooks","issue_events_url":"https://api.github.com/repos/libgit2/rugged/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/rugged/events","assignees_url":"https://api.github.com/repos/libgit2/rugged/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/rugged/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/rugged/tags","blobs_url":"https://api.github.com/repos/libgit2/rugged/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/rugged/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/rugged/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/rugged/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/rugged/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/rugged/languages","stargazers_url":"https://api.github.com/repos/libgit2/rugged/stargazers","contributors_url":"https://api.github.com/repos/libgit2/rugged/contributors","subscribers_url":"https://api.github.com/repos/libgit2/rugged/subscribers","subscription_url":"https://api.github.com/repos/libgit2/rugged/subscription","commits_url":"https://api.github.com/repos/libgit2/rugged/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/rugged/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/rugged/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/rugged/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/rugged/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/rugged/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/rugged/merges","archive_url":"https://api.github.com/repos/libgit2/rugged/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/rugged/downloads","issues_url":"https://api.github.com/repos/libgit2/rugged/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/rugged/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/rugged/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/rugged/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/rugged/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/rugged/releases{/id}","created_at":"2010-09-10T16:18:17Z","updated_at":"2015-08-24T20:24:30Z","pushed_at":"2015-08-24T21:18:54Z","git_url":"git://github.com/libgit2/rugged.git","ssh_url":"git@github.com:libgit2/rugged.git","clone_url":"https://github.com/libgit2/rugged.git","svn_url":"https://github.com/libgit2/rugged","homepage":"","size":22882,"stargazers_count":1482,"watchers_count":1482,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":193,"mirror_url":null,"open_issues_count":25,"forks":193,"open_issues":25,"watchers":1482,"default_branch":"master"}},"base":{"label":"libgit2:master","ref":"master","sha":"51eb13f1fb9ba17969fb62380c67741d3d8841ea","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":901663,"name":"rugged","full_name":"libgit2/rugged","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/rugged","description":"ruby bindings to libgit2","fork":false,"url":"https://api.github.com/repos/libgit2/rugged","forks_url":"https://api.github.com/repos/libgit2/rugged/forks","keys_url":"https://api.github.com/repos/libgit2/rugged/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/rugged/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/rugged/teams","hooks_url":"https://api.github.com/repos/libgit2/rugged/hooks","issue_events_url":"https://api.github.com/repos/libgit2/rugged/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/rugged/events","assignees_url":"https://api.github.com/repos/libgit2/rugged/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/rugged/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/rugged/tags","blobs_url":"https://api.github.com/repos/libgit2/rugged/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/rugged/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/rugged/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/rugged/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/rugged/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/rugged/languages","stargazers_url":"https://api.github.com/repos/libgit2/rugged/stargazers","contributors_url":"https://api.github.com/repos/libgit2/rugged/contributors","subscribers_url":"https://api.github.com/repos/libgit2/rugged/subscribers","subscription_url":"https://api.github.com/repos/libgit2/rugged/subscription","commits_url":"https://api.github.com/repos/libgit2/rugged/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/rugged/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/rugged/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/rugged/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/rugged/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/rugged/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/rugged/merges","archive_url":"https://api.github.com/repos/libgit2/rugged/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/rugged/downloads","issues_url":"https://api.github.com/repos/libgit2/rugged/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/rugged/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/rugged/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/rugged/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/rugged/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/rugged/releases{/id}","created_at":"2010-09-10T16:18:17Z","updated_at":"2015-08-24T20:24:30Z","pushed_at":"2015-08-24T21:18:54Z","git_url":"git://github.com/libgit2/rugged.git","ssh_url":"git@github.com:libgit2/rugged.git","clone_url":"https://github.com/libgit2/rugged.git","svn_url":"https://github.com/libgit2/rugged","homepage":"","size":22882,"stargazers_count":1482,"watchers_count":1482,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":193,"mirror_url":null,"open_issues_count":25,"forks":193,"open_issues":25,"watchers":1482,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/514"},"html":{"href":"https://github.com/libgit2/rugged/pull/514"},"issue":{"href":"https://api.github.com/repos/libgit2/rugged/issues/514"},"comments":{"href":"https://api.github.com/repos/libgit2/rugged/issues/514/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/514/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/rugged/pulls/514/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/rugged/statuses/e849be62c70a550173b35cfc1b5673aa98910772"}}}}