diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2015-01-17 20:49:04 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-02-14 09:25:35 -0500 |
| commit | 55798fd1536f055fc23a760c41d679fc60cd2ead (patch) | |
| tree | f1633dbbdb53bab4e55fdcd024beceef855b9dde /src/index.h | |
| parent | 42f98a26a5da450b3ef8600b85711112dd9860f4 (diff) | |
| download | libgit2-55798fd1536f055fc23a760c41d679fc60cd2ead.tar.gz | |
git_indexwriter: lock then write the index
Introduce `git_indexwriter`, to allow us to lock the index while
performing additional operations, then complete the write (or abort,
unlocking the index).
Diffstat (limited to 'src/index.h')
| -rw-r--r-- | src/index.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/index.h b/src/index.h index 2eb93fb17..d151f6614 100644 --- a/src/index.h +++ b/src/index.h @@ -94,4 +94,22 @@ extern int git_index_snapshot_find( const char *path, size_t path_len, int stage); +typedef struct { + git_index *index; + git_filebuf file; +} git_indexwriter; + +#define GIT_INDEXWRITER_INIT { NULL, GIT_FILEBUF_INIT } + +/* Lock the index for eventual writing. */ +extern int git_indexwriter_init(git_indexwriter *writer, git_index *index); + +/* Write the index and unlock it. */ +extern int git_indexwriter_commit(git_indexwriter *writer); + +/* Cleanup an index writing session, unlocking the file (if it is still + * locked and freeing any data structures. + */ +extern void git_indexwriter_cleanup(git_indexwriter *writer); + #endif |
