fn create_initial_commit(repo: &Repository) -> Result<(), Error> {
    // First use the config to initialize a commit signature for the user.
    let sig = try!(repo.signature());

    // Now let's create an empty tree for this commit
    let tree_id = {
        let mut index = try!(repo.index());

        // Outside of this example, you could call index.add_path()
        // here to put actual files into the index. For our purposes, we'll
        // leave it empty for now.

        try!(index.write_tree())
    };

    let tree = try!(repo.find_tree(tree_id));

    // Ready to create the initial commit.
    //
    // Normally creating a commit would involve looking up the current HEAD
    // commit and making that be the parent of the initial commit, but here this
    // is the first commit so there will be no parent.
    try!(repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[]));

    Ok(())
}
/// Unlike regular "git init", this example shows how to create an initial empty
/// commit in the repository. This is the helper function that does that.
Unlike regular "git init", this example shows how to create an initial empty
commit in the repository. This is the helper function that does that.
Unlike regular " git init " this example shows how to create an initial empty commit in the repository . This is the helper function that does that .
fn create_initial_commit(repo: &Repository) -> Result<(), Error> {
    // First use the config to initialize a commit signature for the user.
    let sig = try!(repo.signature());
    // Now let's create an empty tree for this commit
    let tree_id = {
        let mut index = try!(repo.index());
        // Outside of this example, you could call index.add_path()
        // here to put actual files into the index. For our purposes, we'll
        // leave it empty for now.
        try!(index.write_tree())
    };
    let tree = try!(repo.find_tree(tree_id));
    // Ready to create the initial commit.
    //
    // Normally creating a commit would involve looking up the current HEAD
    // commit and making that be the parent of the initial commit, but here this
    // is the first commit so there will be no parent.
    try!(repo.commit(Some("HEAD"), &sig, &sig, "Initial commit", &tree, &[]));
    Ok(())
}
fn create_initial_commit ( repo : & Repository ) -> Result < ( ) , Error > { // First use the config to initialize a commit signature for the user. let sig = try ! ( repo signature ( ) ) ; // Now let's create an empty tree for this commit let tree_id = { let mut index = try ! ( repo index ( ) ) ; // Outside of this example, you could call index.add_path() // here to put actual files into the index. For our purposes, we'll // leave it empty for now. try ! ( index write_tree ( ) ) } ; let tree = try ! ( repo find_tree ( tree_id ) ) ; // Ready to create the initial commit. // // Normally creating a commit would involve looking up the current HEAD // commit and making that be the parent of the initial commit, but here this // is the first commit so there will be no parent. try ! ( repo commit ( Some ( " " ) sig sig " " tree [ ] ) ) ; Ok ( ( ) ) }
Unlike regular "git init", this example shows how to create an initial empty
commit in the repository.
Unlike regular " git init " this example shows how to create an initial empty commit in the repository .
repo
&Repository
repo
&Repository