Download raw body.
vi struggling to save commit messages
On Wed, Mar 08, 2023 at 01:54:24PM -0700, Ted Bullock wrote: > > On 2023-03-08 1:24 p.m., Todd C. Miller wrote: > > On Wed, 08 Mar 2023 13:19:39 -0700, Ted Bullock wrote: > > > >> I can see why it triggers, it's comparing identical timestamps, not > >> relative. This is inconsistent with the error text too which explicitly > >> says "file modified more recently than this copy". > >> > >> timespeccmp(&sb.st_mtim, &ep->mtim, !=) > >> > >> should be > >> > >> timespeccmp(&sb.st_mtim, &ep->mtim, <=) > > > > Are you saying that the current mtime is _older_ than the original? > > Is this just a matter of the nsec portion being truncated? > > > > - todd > > Here is a sample of the actual numbers, it's not a truncation. > > sb.st_mtim.tv_sec: 1678308226, sb.st_mtim.tv_nsec: 125222348 > ep->mtim.tv_sec: 1678308226, ep->mtim.tv_nsec: 55250221 I can reproduce this with Vim on an NFS share between two amd64 systems. Running fsync() before starting the editor fixes it for me. diff /home/stsp/src/got commit - 4931293229292383086fb2ddd615c3df18de0bba path + /home/stsp/src/got blob - e95ba2936e96e58c1f16c13b3a81b482f35d02a4 file + got/got.c --- got/got.c +++ got/got.c @@ -518,6 +518,10 @@ collect_import_msg(char **logmsg, char **logmsg_path, err = got_error_from_errno2("write", *logmsg_path); goto done; } + if (fsync(fd) == -1) { + err = got_error_from_errno2("fsync", *logmsg_path); + goto done; + } err = edit_logmsg(logmsg, editor, *logmsg_path, initial_content, initial_content_len, 1); @@ -7407,6 +7411,10 @@ get_tag_message(char **tagmsg, char **tagmsg_path, con err = got_error_from_errno2("write", *tagmsg_path); goto done; } + if (fsync(fd) == -1) { + err = got_error_from_errno2("fsync", *tagmsg_path); + goto done; + } err = get_editor(&editor); if (err) @@ -8911,7 +8919,10 @@ collect_commit_logmsg(struct got_pathlist_head *commit dprintf(fd, "# detailed changes can be viewed in %s\n", diff_path); } - + if (fsync(fd) == -1) { + err = got_error_from_errno2("fsync", a->logmsg_path); + goto done; + } err = edit_logmsg(logmsg, a->editor, a->logmsg_path, initial_content, initial_content_len, a->prepared_log ? 0 : 1); done: @@ -11710,8 +11721,14 @@ histedit_edit_logmsg(struct got_histedit_list_entry *h if (err) goto done; - write(fd, logmsg, logmsg_len); - close(fd); + if (write(fd, logmsg, logmsg_len) == -1) { + err = got_error_from_errno2("write", logmsg_path); + goto done; + } + if (fsync(fd) == -1) { + err = got_error_from_errno2("fsync", logmsg_path); + goto done; + } err = get_editor(&editor); if (err)
vi struggling to save commit messages