]> git.ipfire.org Git - thirdparty/git.git/commitdiff
CodingGuidelines: st_mtimespec vs st_mtim vs st_mtime
authorJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2026 18:10:48 +0000 (11:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Apr 2026 04:25:29 +0000 (21:25 -0700)
Most unfortunately macOS does not support st_[amc]tim for timestamps
down to nanosecond resolution as POSIX systems.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/CodingGuidelines

index b8670751f5c705ba5f411cd92cacafb33c3c95e0..b9a29e39f2eec45d536801bd9e96e1eb9147a342 100644 (file)
@@ -681,6 +681,12 @@ For C programs:
          char *dogs[] = ...;
          walk_all_dogs(dogs);
 
+ - For file timestamps, do not use "st_mtim" (and other timestamp
+   members in "struct stat") unconditionally; not everybody is POSIX
+   (grep for USE_ST_TIMESPEC).  If you only need a timestamp in whole
+   second resolution, "st_mtime" should work fine everywhere.
+
+
 For Perl programs:
 
  - Most of the C guidelines above apply.