From e256d21f238f83a48a3668ec07c80b5c004cbea0 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 10 Apr 2026 11:10:48 -0700 Subject: [PATCH] CodingGuidelines: st_mtimespec vs st_mtim vs st_mtime Most unfortunately macOS does not support st_[amc]tim for timestamps down to nanosecond resolution as POSIX systems. Signed-off-by: Junio C Hamano --- Documentation/CodingGuidelines | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index b8670751f5..db0d6800ea 100644 --- a/Documentation/CodingGuidelines +++ b/Documentation/CodingGuidelines @@ -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 timestamp in whole + second resolution, "st_mtime" should work fine everywhere. + + For Perl programs: - Most of the C guidelines above apply.