Duy Nguyen <pclouds@xxxxxxxxx> writes: > On Sun, Oct 23, 2016 at 4:26 PM, Christian Couder > <christian.couder@xxxxxxxxx> wrote: >> @@ -2268,6 +2268,12 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock, > > Doing this in read_index_from() would keep the shared file even more > "fresher" since read happens a lot more often than write. But I think > our main concern is not the temporary index files created by the user > scripts, but $GIT_DIR/index.lock (make sure we don't accidentally > delete its shared file before it gets renamed to $GIT_DIR/index). For > this case, I think refreshing in write_locked_index is enough. Also warning() is unwarranted. You may be accessing somebody else's repository to help diagnose the issue without having any write access. Treat the utime() like the opportunistic index refresh done by "git status"---if we can write, great, but it is not a problem if we can't. > >> int ret = write_shared_index(istate, lock, flags); >> if (ret) >> return ret; >> + } else { >> + /* Signal that the shared index is used */ >> + const char *shared_index = git_path("sharedindex.%s", >> + sha1_to_hex(si->base_sha1)); >> + if (!check_and_freshen_file(shared_index, 1)) >> + warning("could not freshen '%s'", shared_index); > > _()