internal static void CopyAllBlobs(this ObjectDatabase source, OdbBackend backend) { foreach (var blob in source.OfType <Blob>()) { if (!backend.Exists(blob.Id)) { var stream = blob.GetContentStream(); backend.Write(blob.Id, stream, stream.Length, ObjectType.Blob); } } }
/// <summary> /// Stores the content of the <see cref = "Repository.Index" /> as a new <see cref = "Commit" /> into the repository. /// The tip of the <see cref = "Repository.Head"/> will be used as the parent of this new Commit. /// Once the commit is created, the <see cref = "Repository.Head"/> will move forward to point at it. /// </summary> /// <param name = "message">The description of why a change was made to the repository.</param> /// <param name = "author">The <see cref = "Signature" /> of who made the change.</param> /// <param name = "committer">The <see cref = "Signature" /> of who added the change to the repository.</param> /// <param name = "amendPreviousCommit">True to amend the current <see cref = "Commit"/> pointed at by <see cref = "Repository.Head"/>, false otherwise.</param> /// <returns>The generated <see cref = "Commit" />.</returns> public Commit Commit(string message, Signature author, Signature committer, bool amendPreviousCommit = false) { if (amendPreviousCommit && Info.IsHeadOrphaned) { throw new LibGit2SharpException("Can not amend anything. The Head doesn't point at any commit."); } var treeId = Proxy.git_tree_create_fromindex(Index); var tree = this.Lookup <Tree>(treeId); var parents = RetrieveParentsOfTheCommitBeingCreated(amendPreviousCommit); Commit result = ObjectDatabase.CreateCommit(message, author, committer, tree, parents, "HEAD"); Proxy.git_repository_merge_cleanup(handle); return(result); }
/// <summary> /// Stores the content of the <see cref="Repository.Index"/> as a new <see cref="Commit"/> into the repository. /// The tip of the <see cref="Repository.Head"/> will be used as the parent of this new Commit. /// Once the commit is created, the <see cref="Repository.Head"/> will move forward to point at it. /// </summary> /// <param name="message">The description of why a change was made to the repository.</param> /// <param name="author">The <see cref="Signature"/> of who made the change.</param> /// <param name="committer">The <see cref="Signature"/> of who added the change to the repository.</param> /// <param name="amendPreviousCommit">True to amend the current <see cref="Commit"/> pointed at by <see cref="Repository.Head"/>, false otherwise.</param> /// <returns>The generated <see cref="Commit"/>.</returns> public Commit Commit(string message, Signature author, Signature committer, bool amendPreviousCommit = false) { bool isHeadOrphaned = Info.IsHeadUnborn; if (amendPreviousCommit && isHeadOrphaned) { throw new UnbornBranchException("Can not amend anything. The Head doesn't point at any commit."); } var treeId = Proxy.git_tree_create_fromindex(Index); var tree = this.Lookup <Tree>(treeId); var parents = RetrieveParentsOfTheCommitBeingCreated(amendPreviousCommit); Commit result = ObjectDatabase.CreateCommit(message, author, committer, tree, parents, "HEAD"); Proxy.git_repository_state_cleanup(handle); // Insert reflog entry LogCommit(result, amendPreviousCommit, isHeadOrphaned, parents.Count() > 1); return(result); }
public GitTreeBuilder(ObjectDatabase objectDatabase, Tree tree) { _treeDefinition = TreeDefinition.From(tree); _objectDatabase = objectDatabase; }
public GitTreeBuilder(ObjectDatabase objectDatabase) { _treeDefinition = new TreeDefinition(); _objectDatabase = objectDatabase; }