diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/diff.c | 7 | ||||
-rw-r--r-- | src/iterator.c | 12 | ||||
-rw-r--r-- | src/iterator.h | 8 |
3 files changed, 24 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; diff --git a/src/iterator.c b/src/iterator.c index 7807a1636..d5f7eec34 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -1762,6 +1762,18 @@ int git_iterator_current_workdir_path(git_buf **path, git_iterator *iter) return 0; } +int git_iterator_index(git_index **out, git_iterator *iter) +{ + workdir_iterator *wi = (workdir_iterator *)iter; + + if (iter->type != GIT_ITERATOR_TYPE_WORKDIR) + *out = NULL; + + *out = wi->index; + + return 0; +} + int git_iterator_advance_over_with_status( const git_index_entry **entryptr, git_iterator_status_t *status, diff --git a/src/iterator.h b/src/iterator.h index db1f325a7..57f82416a 100644 --- a/src/iterator.h +++ b/src/iterator.h @@ -11,6 +11,7 @@ #include "git2/index.h" #include "vector.h" #include "buffer.h" +#include "ignore.h" typedef struct git_iterator git_iterator; @@ -286,4 +287,11 @@ typedef enum { extern int git_iterator_advance_over_with_status( const git_index_entry **entry, git_iterator_status_t *status, git_iterator *iter); +/** + * Retrieve the index stored in the iterator. + * + * Only implemented for the workdir iterator + */ +extern int git_iterator_index(git_index **out, git_iterator *iter); + #endif |