From 41fae48df21c7d1140da539cb61fa3fd0598a3e7 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 3 Feb 2015 22:31:10 -0500 Subject: indexwriter: an indexwriter for repo operations Provide git_indexwriter_init_for_operation for the common locking pattern in merge, rebase, revert and cherry-pick. --- src/index.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/index.h') diff --git a/src/index.h b/src/index.h index d151f6614..6d2904fdc 100644 --- a/src/index.h +++ b/src/index.h @@ -97,6 +97,7 @@ extern int git_index_snapshot_find( typedef struct { git_index *index; git_filebuf file; + unsigned int should_write:1; } git_indexwriter; #define GIT_INDEXWRITER_INIT { NULL, GIT_FILEBUF_INIT } @@ -104,6 +105,16 @@ typedef struct { /* Lock the index for eventual writing. */ extern int git_indexwriter_init(git_indexwriter *writer, git_index *index); +/* Lock the index for eventual writing by a repository operation: a merge, + * revert, cherry-pick or a rebase. Note that the given checkout strategy + * will be updated for the operation's use so that checkout will not write + * the index. + */ +extern int git_indexwriter_init_for_operation( + git_indexwriter *writer, + git_repository *repo, + unsigned int *checkout_strategy); + /* Write the index and unlock it. */ extern int git_indexwriter_commit(git_indexwriter *writer); -- cgit v1.2.1