diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2017-11-12 08:09:35 +0000 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2018-06-29 14:54:27 +0100 |
| commit | 7c56c49be58091f4d4c5fbe96429694e80befd0b (patch) | |
| tree | 31f19f22cda224d781636dbe2adb192b95b46201 /src/index.h | |
| parent | 4919e495ed257ee7528ac09aea1e4c12011c282c (diff) | |
| download | libgit2-7c56c49be58091f4d4c5fbe96429694e80befd0b.tar.gz | |
index: add a dirty bit reflecting unsaved changes
Teach the index when it is "dirty", and has unsaved changes. Consider
the index dirty whenever a caller has added or removed an entry from the
main index, REUC or NAME section, including when the index is completely
cleared. Similarly, consider the index _not_ dirty immediately after it
is written, or when it is read from the on-disk index.
This allows us to ensure that unsaved changes are not lost when we
automatically refresh the index.
Diffstat (limited to 'src/index.h')
| -rw-r--r-- | src/index.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/index.h b/src/index.h index 0f1c0956c..8bf100849 100644 --- a/src/index.h +++ b/src/index.h @@ -37,6 +37,7 @@ struct git_index { unsigned int ignore_case:1; unsigned int distrust_filemode:1; unsigned int no_symlinks:1; + unsigned int dirty:1; /* whether we have unsaved changes */ git_tree_cache *tree; git_pool tree_pool; @@ -143,6 +144,11 @@ extern int git_index_snapshot_find( /* Replace an index with a new index */ int git_index_read_index(git_index *index, const git_index *new_index); +GIT_INLINE(int) git_index_is_dirty(git_index *index) +{ + return index->dirty; +} + typedef struct { git_index *index; git_filebuf file; |
