diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2015-11-13 15:32:48 -0500 |
|---|---|---|
| committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-11-16 22:58:58 -0500 |
| commit | d1101263f751a33d70ec585da908bec938f587fd (patch) | |
| tree | e6680d1f92dc1a17e6d837fe23bbc75bd813d5ef /src/index.c | |
| parent | cb0ff012d3cb9658b88ad4f752046286ba5ea442 (diff) | |
| download | libgit2-d1101263f751a33d70ec585da908bec938f587fd.tar.gz | |
index: don't detect raciness in uptodate entries
Keep track of entries that we believe are up-to-date, because we
added the index entries since the index was loaded. This prevents
us from unnecessarily examining files that we wrote during the
cleanup of racy entries (when we smudge racily clean files that have
a timestamp newer than or equal to the index's timestamp when we
read it). Without keeping track of this, we would examine every
file that we just checked out for raciness, since all their timestamps
would be newer than the index's timestamp.
Diffstat (limited to 'src/index.c')
| -rw-r--r-- | src/index.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/index.c b/src/index.c index 9eb1289c3..b3fb077cc 100644 --- a/src/index.c +++ b/src/index.c @@ -767,7 +767,8 @@ static int truncate_racily_clean(git_index *index) diff_opts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE | GIT_DIFF_IGNORE_SUBMODULES | GIT_DIFF_DISABLE_PATHSPEC_MATCH; git_vector_foreach(&index->entries, i, entry) { - if (!is_racy_timestamp(&index->stamp.mtime, entry)) + if ((entry->flags_extended & GIT_IDXENTRY_UPTODATE) == 0 && + is_racy_timestamp(&index->stamp.mtime, entry)) git_vector_insert(&paths, (char *)entry->path); } @@ -1295,6 +1296,9 @@ static int index_insert( else entry->flags |= GIT_IDXENTRY_NAMEMASK; + /* this entry is now up-to-date and should not be checked for raciness */ + entry->flags_extended |= GIT_IDXENTRY_UPTODATE; + if (git_mutex_lock(&index->lock) < 0) { giterr_set(GITERR_OS, "Unable to acquire index lock"); return -1; @@ -2558,7 +2562,8 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry) if (entry->flags & GIT_IDXENTRY_EXTENDED) { struct entry_long *ondisk_ext; ondisk_ext = (struct entry_long *)ondisk; - ondisk_ext->flags_extended = htons(entry->flags_extended); + ondisk_ext->flags_extended = htons(entry->flags_extended & + GIT_IDXENTRY_EXTENDED_FLAGS); path = ondisk_ext->path; } else |
