treewide: migrate from legacy utime.h to utimensat
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest3 patches 15 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | compat/posix: introduce utimensat(2) wrapperMakefile compat/ compat/ +5 more | +127 | 0 replies | |
| 2/3 | treewide: use utimensat(2) instead of legacy utime(3p)builtin/ commit-graph.c copy.c +5 more | +52 | 0 replies | |
| 3/3 | compat/posix: drop legacy <utime.h> header and shimscompat/ compat/ compat/ +4 more | +0 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/3] treewide: migrate from legacy utime.h to utimensat
utime() function for setting access/modification time for files (and a corresponding <utime.h> header) have been officially removed from POSIX starting from POSIX.1-2024. While existing system library implementations still provide this function for compatibility reasons, its implementation may be removed in the future, or otherwise degrade over time. Some newer libc implementations (e.g. LLVM-libc, currently under development) don't provide utime() function at all.
This PR switches the git codebase to recommended alternative: utimensat() POSIX function (which supports nanosecond-level precision) from <fcntl.h>, and, as a possible fallback for older systems compatibility, utimes() function from <sys/stat.h>. It also provides the corresponding MinGW wrapper.
The alternative is to unconditionally use utimes() where possible, but given that utimensat is available in glibc starting from 2007, and on BSD systems since 2012 or so, it makes sense to use the newer variant by default.
No behavior changes is intended or expected (except for Git explicitly passing nanosecond-precision timestamps to kernel, where previously only second-level precision was used).
This change is generated by Gemini Flash from Antigravity, but all the code has been manually verified by me, and, where applicable, adjusted to match the existing behavior as closely as possible.
Alexey Samsonov (3):
compat/posix: introduce utimensat(2) wrapper
treewide: use utimensat(2) instead of legacy utime(3p) compat/posix: drop legacy <utime.h> header and shims
Makefile | 6 +++++ builtin/pack-objects.c | 12 +++++---- commit-graph.c | 17 +++++-------- compat/mingw-posix.h | 4 +-- compat/mingw.c | 36 ++++++++++++++++++++------ compat/posix.h | 22 +++++++++++++++- compat/utimensat.c | 39 +++++++++++++++++++++++++++++ compat/vcbuild/include/sys/utime.h | 34 ------------------------- compat/vcbuild/include/utime.h | 1 - configure.ac | 6 +++++ contrib/buildsystems/CMakeLists.txt | 8 ++++-- copy.c | 10 +++++--- meson.build | 2 ++ object-file.c | 12 +++++---- odb/source-loose.c | 10 ++++---- odb/source-packed.c | 12 +++++---- rerere.c | 4 +-- t/helper/test-chmtime.c | 20 +++++++++------ t/t4051/includes.c | 1 - 19 files changed, 163 insertions(+), 93 deletions(-) create mode 100644 compat/utimensat.c delete mode 100644 compat/vcbuild/include/sys/utime.h delete mode 100644 compat/vcbuild/include/utime.h
base-commit: dea0ea3582e6980ddbc1173cc8e3e9f9db91cde0
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2209%2Fvonosmas%2Fdrop-utime-h-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2209/vonosmas/drop-utime-h-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2209
Signature · 1 line
gitgitgadget