diff options
-rw-r--r-- | cache.h | 4 | ||||
-rw-r--r-- | read-cache.c | 5 |
2 files changed, 6 insertions, 3 deletions
@@ -734,6 +734,10 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); extern int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg); extern struct cache_entry *refresh_cache_entry(struct cache_entry *, unsigned int); +/* + * Opportunistically update the index but do not complain if we can't. + * The lockfile is always committed or rolled back. + */ extern void update_index_if_able(struct index_state *, struct lock_file *); extern int hold_locked_index(struct lock_file *, int); diff --git a/read-cache.c b/read-cache.c index 0d8d2dedee..87188d390d 100644 --- a/read-cache.c +++ b/read-cache.c @@ -2176,14 +2176,13 @@ static int has_racy_timestamp(struct index_state *istate) return 0; } -/* - * Opportunistically update the index but do not complain if we can't - */ void update_index_if_able(struct index_state *istate, struct lock_file *lockfile) { if ((istate->cache_changed || has_racy_timestamp(istate)) && verify_index(istate)) write_locked_index(istate, lockfile, COMMIT_LOCK); + else + rollback_lock_file(lockfile); } /* |