diff options
| author | Russell Belfer <rb@github.com> | 2012-11-01 14:16:19 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-11-01 14:16:19 -0700 |
| commit | 60ad7d52b8828a7c1fd0720e166d00a6ea3fe6bc (patch) | |
| tree | ed40a431c2884cb87ea489640e4217463df9e325 /include/git2 | |
| parent | dbd6850d06111eb0761499d7c876ff7cd4ad57fa (diff) | |
| parent | 1e808f9cda598fef83ff93deb007212ebf61be6d (diff) | |
| download | libgit2-60ad7d52b8828a7c1fd0720e166d00a6ea3fe6bc.tar.gz | |
Merge pull request #1037 from libgit2/index-open-cleanup
Some more changes to the Index API
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/index.h | 45 | ||||
| -rw-r--r-- | include/git2/tree.h | 18 |
2 files changed, 45 insertions, 18 deletions
diff --git a/include/git2/index.h b/include/git2/index.h index 1d91663d8..bca9791c5 100644 --- a/include/git2/index.h +++ b/include/git2/index.h @@ -126,6 +126,19 @@ enum { GIT_EXTERN(int) git_index_open(git_index **index, const char *index_path); /** + * Create an in-memory index object. + * + * This index object cannot be read/written to the filesystem, + * but may be used to perform in-memory index operations. + * + * The index must be freed once it's no longer in use. + * + * @param index the pointer for the new index + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_new(git_index **index); + +/** * Free an existing index object. * * @param index an existing index object @@ -190,6 +203,38 @@ GIT_EXTERN(int) git_index_write(git_index *index); */ GIT_EXTERN(int) git_index_read_tree(git_index *index, git_tree *tree); +/** + * Write the index as a tree + * + * This method will scan the index and write a representation + * of its current state back to disk; it recursively creates + * tree objects for each of the subtrees stored in the index, + * but only returns the OID of the root tree. This is the OID + * that can be used e.g. to create a commit. + * + * The index instance cannot be bare, and needs to be associated + * to an existing repository. + * + * @param oid Pointer where to store the OID of the written tree + * @param index Index to write + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_write_tree(git_oid *oid, git_index *index); + +/** + * Write the index as a tree to the given repository + * + * This method will do the same as `git_index_write_tree`, but + * letting the user choose the repository where the tree will + * be written. + * + * @param oid Pointer where to store OID of the the written tree + * @param index Index to write + * @param repo Repository where to write the tree + * @return 0 or an error code + */ +GIT_EXTERN(int) git_index_write_tree_to(git_oid *oid, git_index *index, git_repository *repo); + /**@}*/ /** @name Raw Index Entry Functions diff --git a/include/git2/tree.h b/include/git2/tree.h index 2ee1f4afa..527f81819 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -185,24 +185,6 @@ GIT_EXTERN(int) git_tree_entry_to_object( const git_tree_entry *entry); /** - * Write a tree to the ODB from the index file - * - * This method will scan the index and write a representation - * of its current state back to disk; it recursively creates - * tree objects for each of the subtrees stored in the index, - * but only returns the OID of the root tree. This is the OID - * that can be used e.g. to create a commit. - * - * The index instance cannot be bare, and needs to be associated - * to an existing repository. - * - * @param oid Pointer where to store the written tree - * @param index Index to write - * @return 0 or an error code - */ -GIT_EXTERN(int) git_tree_create_fromindex(git_oid *oid, git_index *index); - -/** * Create a new tree builder. * * The tree builder can be used to create or modify |
