Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-06-17 15:34:10 +0300
committerCarlos Martín Nieto <cmn@dwim.me>2015-06-22 13:47:30 +0300
commitff47537557f0ac1919e77c5cb21f36f2e98425de (patch)
treeb7164edbbc40fcdea677c1d178c1052e7b197ef0 /src/diff.c
parente96a97f18e8f961c434e4fa4fc2c7d950480b9e9 (diff)
diff: check files with the same or newer timestamps
When a file on the workdir has the same or a newer timestamp than the index, we need to perform a full check of the contents, as the update of the file may have happened just after we wrote the index. The iterator changes are such that we can reach inside the workdir iterator from the diff, though it may be better to have an accessor instead of moving these structs into the header.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/diff.c b/src/diff.c
index d7365ef77..cc93f57cd 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -816,11 +816,11 @@ static int maybe_modified(
} else if (git_oid_iszero(&nitem->id) && new_is_workdir) {
bool use_ctime = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_CTIME) != 0);
bool use_nanos = ((diff->diffcaps & GIT_DIFFCAPS_TRUST_NANOSECS) != 0);
+ git_index *index;
+ git_iterator_index(&index, info->new_iter);
status = GIT_DELTA_UNMODIFIED;
- /* TODO: add check against index file st_mtime to avoid racy-git */
-
if (S_ISGITLINK(nmode)) {
if ((error = maybe_modified_submodule(&status, &noid, diff, info)) < 0)
return error;
@@ -839,7 +839,8 @@ static int maybe_modified(
!diff_time_eq(&oitem->ctime, &nitem->ctime, use_nanos)) ||
oitem->ino != nitem->ino ||
oitem->uid != nitem->uid ||
- oitem->gid != nitem->gid)
+ oitem->gid != nitem->gid ||
+ (index && nitem->mtime.seconds >= index->stamp.mtime))
{
status = GIT_DELTA_MODIFIED;
modified_uncertain = true;