summaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-20 16:17:28 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-20 16:17:28 +0200
commit624c949f01ca553fdd0b42fbac439e822c1bdd5f (patch)
treec506e0d65967c0f6e51c7595aa383fe0107e29e8 /src/index.c
parent5e947c91d49aacc8abb5b3f018737c72c52486a9 (diff)
downloadlibgit2-624c949f01ca553fdd0b42fbac439e822c1bdd5f.tar.gz
index: make relative comparison use the checksum as wellcmn/index-checksum
This is used by the submodule in order to figure out if the index has changed since it last read it. Using a timestamp is racy, so let's make it use the checksum, just like we now do for reloading the index itself.
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c
index ba101ea14..1fb3c48f3 100644
--- a/src/index.c
+++ b/src/index.c
@@ -679,15 +679,13 @@ int git_index_read(git_index *index, int force)
}
int git_index__changed_relative_to(
- git_index *index, const git_futils_filestamp *fs)
+ git_index *index, const git_oid *checksum)
{
/* attempt to update index (ignoring errors) */
if (git_index_read(index, false) < 0)
giterr_clear();
- return (index->stamp.mtime != fs->mtime ||
- index->stamp.size != fs->size ||
- index->stamp.ino != fs->ino);
+ return !!git_oid_cmp(&index->checksum, checksum);
}
/*