diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2018-06-22 19:17:08 +0900 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-06-29 14:54:29 +0100 |
commit | bfa1f02292d1b637928fe18663a5f2d0aa993400 (patch) | |
tree | 0d08a6eb80acf9b6114d2f817cd9e8cd711daf10 /include | |
parent | 787768c2d70dfcd1c9ebc1854b5d0f67d2e6d4d9 (diff) | |
download | libgit2-bfa1f02292d1b637928fe18663a5f2d0aa993400.tar.gz |
settings: optional unsaved index safety
Add the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option, which will cause
commands that reload the on-disk index to fail if the current
`git_index` has changed that have not been saved. This will prevent
users from - for example - adding a file to the index then calling a
function like `git_checkout` and having that file be silently removed
from the index since it was re-read from disk.
Now calls that would re-read the index will fail if the index is
"dirty", meaning changes have been made to it but have not been written.
Users can either `git_index_read` to discard those changes explicitly,
or `git_index_write` to write them.
Diffstat (limited to 'include')
-rw-r--r-- | include/git2/common.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/include/git2/common.h b/include/git2/common.h index fc820cae7..8c9347413 100644 --- a/include/git2/common.h +++ b/include/git2/common.h @@ -194,7 +194,8 @@ typedef enum { GIT_OPT_GET_WINDOWS_SHAREMODE, GIT_OPT_SET_WINDOWS_SHAREMODE, GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, - GIT_OPT_SET_ALLOCATOR + GIT_OPT_SET_ALLOCATOR, + GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY } git_libgit2_opt_t; /** @@ -363,6 +364,14 @@ typedef enum { * > allocator will then be used to make all memory allocations for * > libgit2 operations. * + * opts(GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY, int enabled) + * + * > Ensure that there are no unsaved changes in the index before + * > beginning any operation that reloads the index from disk (eg, + * > checkout). If there are unsaved changes, the instruction will + * > fail. (Using the FORCE flag to checkout will still overwrite + * > these changes.) + * * @param option Option key * @param ... value to set the option * @return 0 on success, <0 on failure |