summaryrefslogtreecommitdiff
path: root/src/index.h
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-19 22:05:08 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-19 22:05:08 +0200
commit5e947c91d49aacc8abb5b3f018737c72c52486a9 (patch)
tree692d72036f7f06c03571652107b9b279948e9106 /src/index.h
parent46c84c72600c0aed379e0df659ad1ca518fdd7cb (diff)
downloadlibgit2-5e947c91d49aacc8abb5b3f018737c72c52486a9.tar.gz
index: use the checksum to check whether it's been modified
We currently use a timetamp to check whether an index file has been modified since we last read it, but this is racy. If two updates happen in the same second and we read after the first one, we won't detect the second one. Instead read the SHA-1 checksum of the file, which are its last 20 bytes which gives us a sure-fire way to detect whether the file has changed since we last read it. As we're now keeping track of it, expose an accessor to this data.
Diffstat (limited to 'src/index.h')
-rw-r--r--src/index.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/index.h b/src/index.h
index 0f6f4e86e..615d703c4 100644
--- a/src/index.h
+++ b/src/index.h
@@ -22,6 +22,7 @@ struct git_index {
char *index_file_path;
git_futils_filestamp stamp;
+ git_oid checksum; /* checksum at the end of the file */
git_vector entries;