commit 867630bb8fa7066172802243ca8abacb1e9aab6a from: Stefan Sperling date: Fri Jan 17 11:54:27 2020 UTC Sleep for one nanosecond after syncing the file index to disk Ensures that files modified after got exits have a different timestamp from the one which was recorded in the file index. Previously, 'got status' did not always detect such files as modified. Problem reported by Steven McDonald. commit - 7d2e9986b9ba65468743b9dcaba2b62a031ca3b9 commit + 867630bb8fa7066172802243ca8abacb1e9aab6a blob - 3027c28911360bf6c9f6f2dcdc85e417cf77dc37 blob + 1f65b9c40a9b2c45eb6476451a40c71d35d259e7 --- lib/worktree.c +++ lib/worktree.c @@ -1743,6 +1743,7 @@ sync_fileindex(struct got_fileindex *fileindex, const const struct got_error *err = NULL; char *new_fileindex_path = NULL; FILE *new_index = NULL; + struct timespec timeout; err = got_opentemp_named(&new_fileindex_path, &new_index, fileindex_path); @@ -1758,6 +1759,15 @@ sync_fileindex(struct got_fileindex *fileindex, const fileindex_path); unlink(new_fileindex_path); } + + /* + * Sleep for a short amount of time to ensure that files modified after + * this program exits have a different time stamp from the one which + * was recorded in the file index. + */ + timeout.tv_sec = 0; + timeout.tv_nsec = 1; + nanosleep(&timeout, NULL); done: if (new_index) fclose(new_index);