{"action":"created","comment":{"url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/comments/42058532","id":42058532,"diff_hunk":"@@ -0,0 +1,185 @@\n+using System;\n+using System.IO;\n+using LibGit2Sharp.Core;\n+using LibGit2Sharp.Core.Handles;\n+\n+namespace LibGit2Sharp\n+{\n+    /// <summary>\n+    /// Representation of a git packbuilder.\n+    /// </summary>\n+    public sealed class PackBuilder : IDisposable\n+    {\n+        private readonly PackBuilderSafeHandle packBuilderHandle;\n+        private readonly Repository repo;\n+\n+        /// <summary>\n+        /// Constructs a packbuilder from a repository.\n+        /// </summary>\n+        internal PackBuilder(Repository repository)\n+        {\n+            Ensure.ArgumentNotNull(repository, \"repository\");\n+\n+            repo = repository;\n+            packBuilderHandle = Proxy.git_packbuilder_new(repo.Handle);\n+        }\n+\n+        /// <summary>\n+        /// Inserts a single object to the packbuilder.\n+        /// For an optimal pack it's mandatory to insert objects in recency order, commits followed by trees and blobs. (quoted from libgit2 API ref)\n+        /// </summary>\n+        /// <param name=\"gitObjectID\">The object ID to be inserted.</param>\n+        public void Add(ObjectId gitObjectID)\n+        {\n+            Ensure.ArgumentNotNull(gitObjectID, \"gitObject\");\n+\n+            Proxy.git_packbuilder_insert(packBuilderHandle, gitObjectID, null);\n+        }\n+\n+        /// <summary>\n+        /// Recursively insert an object and its referenced objects. Inserts the object as well as any object it references.\n+        /// </summary>\n+        /// <param name=\"gitObjectID\">The object ID to be recursively inserted.</param>\n+        public void AddRecursively(ObjectId gitObjectID)\n+        {\n+            Ensure.ArgumentNotNull(gitObjectID, \"gitObject\");\n+\n+            Proxy.git_packbuilder_insert_recur(packBuilderHandle, gitObjectID, null);\n+        }\n+\n+        /// <summary>\n+        /// Writes the new pack file and corresponding index file to path.\n+        /// </summary>\n+        /// <param name=\"path\">The path that pack and index files will be written to it.</param>\n+        internal void Write(string path)\n+        {\n+            Proxy.git_packbuilder_write(packBuilderHandle, path);\n+        }\n+\n+        /// <summary>\n+        /// Disposes the packbuilder object.\n+        /// </summary>\n+        public void Dispose()\n+        {\n+            packBuilderHandle.SafeDispose();\n+        }\n+\n+        /// <summary>\n+        /// Sets number of threads to spawn.\n+        /// </summary>\n+        /// <returns> Returns the number of actual threads to be used.</returns>\n+        /// <param name=\"nThread\">The Number of threads to spawn. An argument of 0 enusures using all available CPUs</param>\n+        internal int SetMaximumNumberOfThreads(int nThread)\n+        {\n+            // Libgit2 set the number of threads to 1 by default, 0 ensures git_online_cpus\n+            return (int)Proxy.git_packbuilder_set_threads(packBuilderHandle, (uint)nThread);\n+        }\n+\n+        /// <summary>\n+        /// Get the total number of objects the packbuilder will write out.\n+        /// </summary>\n+        internal long ObjectsCount\n+        {\n+            get { return Proxy.git_packbuilder_object_count(packBuilderHandle); }\n+        }\n+\n+        /// <summary>\n+        /// Number of objects the packbuilder has already written out. \n+        /// This is only correct after the packfile has been written.\n+        /// </summary>\n+        internal long WrittenObjectsCount\n+        {\n+            get { return Proxy.git_packbuilder_written(packBuilderHandle); }\n+        }\n+\n+        /// <summary>\n+        /// A refernce to the repository that the packbuilder is working on.\n+        /// </summary>\n+        public Repository Repository","path":"LibGit2Sharp/PackBuilder.cs","position":98,"original_position":98,"commit_id":"173bc64c05586d72e9e7275f67f8b9a714532aad","original_commit_id":"e24218c36cfa9377ddbf127c1e5b9f8c6bae257d","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":"> I don't know exactly what does that mean. To build pack files you need access to repository objects, branches, commits, tags ... etc. ... and you need access to the packbuilder. So I guess that should be accessible somehow from outside the API.\r\n\r\nMy point is, you should pass the `Repository` to whatever needs to get the branches or objects.  Just like if you (say) need to read an object out of the object database, when all you have is a branch name.","created_at":"2015-10-14T21:51:58Z","updated_at":"2015-10-14T21:51:58Z","html_url":"https://github.com/libgit2/libgit2sharp/pull/1183#discussion_r42058532","pull_request_url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183","_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/comments/42058532"},"html":{"href":"https://github.com/libgit2/libgit2sharp/pull/1183#discussion_r42058532"},"pull_request":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183"}}},"pull_request":{"url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183","id":43667454,"html_url":"https://github.com/libgit2/libgit2sharp/pull/1183","diff_url":"https://github.com/libgit2/libgit2sharp/pull/1183.diff","patch_url":"https://github.com/libgit2/libgit2sharp/pull/1183.patch","issue_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1183","number":1183,"state":"open","locked":false,"title":"Exposing Packbuilder capabilities of libgit2","user":{"login":"AMSadek","id":13529666,"avatar_url":"https://avatars.githubusercontent.com/u/13529666?v=3","gravatar_id":"","url":"https://api.github.com/users/AMSadek","html_url":"https://github.com/AMSadek","followers_url":"https://api.github.com/users/AMSadek/followers","following_url":"https://api.github.com/users/AMSadek/following{/other_user}","gists_url":"https://api.github.com/users/AMSadek/gists{/gist_id}","starred_url":"https://api.github.com/users/AMSadek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AMSadek/subscriptions","organizations_url":"https://api.github.com/users/AMSadek/orgs","repos_url":"https://api.github.com/users/AMSadek/repos","events_url":"https://api.github.com/users/AMSadek/events{/privacy}","received_events_url":"https://api.github.com/users/AMSadek/received_events","type":"User","site_admin":false},"body":"This pull request is intended to expose the the pack builder capabilities of libgit2, which is one way to produce the the .pack and .idx files for a repository. Some sample scenarios would be: Creating a pack file for a new or existing repo, splitting a repo over multiple pack files, build a pack file for certain branches/commits/trees if the entire repo is quite large, or build for commits returned by a revision walker.","created_at":"2015-08-28T20:14:57Z","updated_at":"2015-10-14T21:51:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b38158f462f7883fbe6ce2ace7db10959eab9599","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183/commits","review_comments_url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183/comments","review_comment_url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1183/comments","statuses_url":"https://api.github.com/repos/libgit2/libgit2sharp/statuses/173bc64c05586d72e9e7275f67f8b9a714532aad","head":{"label":"AMSadek:AMSadek/packbuilder","ref":"AMSadek/packbuilder","sha":"173bc64c05586d72e9e7275f67f8b9a714532aad","user":{"login":"AMSadek","id":13529666,"avatar_url":"https://avatars.githubusercontent.com/u/13529666?v=3","gravatar_id":"","url":"https://api.github.com/users/AMSadek","html_url":"https://github.com/AMSadek","followers_url":"https://api.github.com/users/AMSadek/followers","following_url":"https://api.github.com/users/AMSadek/following{/other_user}","gists_url":"https://api.github.com/users/AMSadek/gists{/gist_id}","starred_url":"https://api.github.com/users/AMSadek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AMSadek/subscriptions","organizations_url":"https://api.github.com/users/AMSadek/orgs","repos_url":"https://api.github.com/users/AMSadek/repos","events_url":"https://api.github.com/users/AMSadek/events{/privacy}","received_events_url":"https://api.github.com/users/AMSadek/received_events","type":"User","site_admin":false},"repo":{"id":41564730,"name":"libgit2sharp","full_name":"AMSadek/libgit2sharp","owner":{"login":"AMSadek","id":13529666,"avatar_url":"https://avatars.githubusercontent.com/u/13529666?v=3","gravatar_id":"","url":"https://api.github.com/users/AMSadek","html_url":"https://github.com/AMSadek","followers_url":"https://api.github.com/users/AMSadek/followers","following_url":"https://api.github.com/users/AMSadek/following{/other_user}","gists_url":"https://api.github.com/users/AMSadek/gists{/gist_id}","starred_url":"https://api.github.com/users/AMSadek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AMSadek/subscriptions","organizations_url":"https://api.github.com/users/AMSadek/orgs","repos_url":"https://api.github.com/users/AMSadek/repos","events_url":"https://api.github.com/users/AMSadek/events{/privacy}","received_events_url":"https://api.github.com/users/AMSadek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AMSadek/libgit2sharp","description":"Git + .NET/Mono = ❤","fork":true,"url":"https://api.github.com/repos/AMSadek/libgit2sharp","forks_url":"https://api.github.com/repos/AMSadek/libgit2sharp/forks","keys_url":"https://api.github.com/repos/AMSadek/libgit2sharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AMSadek/libgit2sharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AMSadek/libgit2sharp/teams","hooks_url":"https://api.github.com/repos/AMSadek/libgit2sharp/hooks","issue_events_url":"https://api.github.com/repos/AMSadek/libgit2sharp/issues/events{/number}","events_url":"https://api.github.com/repos/AMSadek/libgit2sharp/events","assignees_url":"https://api.github.com/repos/AMSadek/libgit2sharp/assignees{/user}","branches_url":"https://api.github.com/repos/AMSadek/libgit2sharp/branches{/branch}","tags_url":"https://api.github.com/repos/AMSadek/libgit2sharp/tags","blobs_url":"https://api.github.com/repos/AMSadek/libgit2sharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AMSadek/libgit2sharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AMSadek/libgit2sharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/AMSadek/libgit2sharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AMSadek/libgit2sharp/statuses/{sha}","languages_url":"https://api.github.com/repos/AMSadek/libgit2sharp/languages","stargazers_url":"https://api.github.com/repos/AMSadek/libgit2sharp/stargazers","contributors_url":"https://api.github.com/repos/AMSadek/libgit2sharp/contributors","subscribers_url":"https://api.github.com/repos/AMSadek/libgit2sharp/subscribers","subscription_url":"https://api.github.com/repos/AMSadek/libgit2sharp/subscription","commits_url":"https://api.github.com/repos/AMSadek/libgit2sharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/AMSadek/libgit2sharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/AMSadek/libgit2sharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/AMSadek/libgit2sharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/AMSadek/libgit2sharp/contents/{+path}","compare_url":"https://api.github.com/repos/AMSadek/libgit2sharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AMSadek/libgit2sharp/merges","archive_url":"https://api.github.com/repos/AMSadek/libgit2sharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AMSadek/libgit2sharp/downloads","issues_url":"https://api.github.com/repos/AMSadek/libgit2sharp/issues{/number}","pulls_url":"https://api.github.com/repos/AMSadek/libgit2sharp/pulls{/number}","milestones_url":"https://api.github.com/repos/AMSadek/libgit2sharp/milestones{/number}","notifications_url":"https://api.github.com/repos/AMSadek/libgit2sharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AMSadek/libgit2sharp/labels{/name}","releases_url":"https://api.github.com/repos/AMSadek/libgit2sharp/releases{/id}","created_at":"2015-08-28T19:19:02Z","updated_at":"2015-08-28T19:19:04Z","pushed_at":"2015-10-14T20:32:39Z","git_url":"git://github.com/AMSadek/libgit2sharp.git","ssh_url":"git@github.com:AMSadek/libgit2sharp.git","clone_url":"https://github.com/AMSadek/libgit2sharp.git","svn_url":"https://github.com/AMSadek/libgit2sharp","homepage":"http://libgit2.github.com","size":160418,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"vNext"}},"base":{"label":"libgit2:vNext","ref":"vNext","sha":"ac4c7d96b9833e926f2745fe9c5ca96558879d9f","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":1415168,"name":"libgit2sharp","full_name":"libgit2/libgit2sharp","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/libgit2sharp","description":"Git + .NET/Mono = ❤","fork":false,"url":"https://api.github.com/repos/libgit2/libgit2sharp","forks_url":"https://api.github.com/repos/libgit2/libgit2sharp/forks","keys_url":"https://api.github.com/repos/libgit2/libgit2sharp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/libgit2/libgit2sharp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/libgit2/libgit2sharp/teams","hooks_url":"https://api.github.com/repos/libgit2/libgit2sharp/hooks","issue_events_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/events{/number}","events_url":"https://api.github.com/repos/libgit2/libgit2sharp/events","assignees_url":"https://api.github.com/repos/libgit2/libgit2sharp/assignees{/user}","branches_url":"https://api.github.com/repos/libgit2/libgit2sharp/branches{/branch}","tags_url":"https://api.github.com/repos/libgit2/libgit2sharp/tags","blobs_url":"https://api.github.com/repos/libgit2/libgit2sharp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/libgit2/libgit2sharp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/libgit2/libgit2sharp/git/refs{/sha}","trees_url":"https://api.github.com/repos/libgit2/libgit2sharp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/libgit2/libgit2sharp/statuses/{sha}","languages_url":"https://api.github.com/repos/libgit2/libgit2sharp/languages","stargazers_url":"https://api.github.com/repos/libgit2/libgit2sharp/stargazers","contributors_url":"https://api.github.com/repos/libgit2/libgit2sharp/contributors","subscribers_url":"https://api.github.com/repos/libgit2/libgit2sharp/subscribers","subscription_url":"https://api.github.com/repos/libgit2/libgit2sharp/subscription","commits_url":"https://api.github.com/repos/libgit2/libgit2sharp/commits{/sha}","git_commits_url":"https://api.github.com/repos/libgit2/libgit2sharp/git/commits{/sha}","comments_url":"https://api.github.com/repos/libgit2/libgit2sharp/comments{/number}","issue_comment_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues/comments{/number}","contents_url":"https://api.github.com/repos/libgit2/libgit2sharp/contents/{+path}","compare_url":"https://api.github.com/repos/libgit2/libgit2sharp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/libgit2/libgit2sharp/merges","archive_url":"https://api.github.com/repos/libgit2/libgit2sharp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/libgit2/libgit2sharp/downloads","issues_url":"https://api.github.com/repos/libgit2/libgit2sharp/issues{/number}","pulls_url":"https://api.github.com/repos/libgit2/libgit2sharp/pulls{/number}","milestones_url":"https://api.github.com/repos/libgit2/libgit2sharp/milestones{/number}","notifications_url":"https://api.github.com/repos/libgit2/libgit2sharp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/libgit2/libgit2sharp/labels{/name}","releases_url":"https://api.github.com/repos/libgit2/libgit2sharp/releases{/id}","created_at":"2011-02-26T16:44:49Z","updated_at":"2015-10-14T12:55:00Z","pushed_at":"2015-10-14T20:32:39Z","git_url":"git://github.com/libgit2/libgit2sharp.git","ssh_url":"git@github.com:libgit2/libgit2sharp.git","clone_url":"https://github.com/libgit2/libgit2sharp.git","svn_url":"https://github.com/libgit2/libgit2sharp","homepage":"http://libgit2.github.com","size":238893,"stargazers_count":868,"watchers_count":868,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":355,"mirror_url":null,"open_issues_count":160,"forks":355,"open_issues":160,"watchers":868,"default_branch":"vNext"}},"_links":{"self":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183"},"html":{"href":"https://github.com/libgit2/libgit2sharp/pull/1183"},"issue":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1183"},"comments":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/issues/1183/comments"},"review_comments":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183/comments"},"review_comment":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/pulls/1183/commits"},"statuses":{"href":"https://api.github.com/repos/libgit2/libgit2sharp/statuses/173bc64c05586d72e9e7275f67f8b9a714532aad"}}}}