git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/3] treewide: migrate from legacy utime.h to utimensat

From
AGAlexey Samsonov via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 21, 2026, 14:23 UTC
Message-ID
<pull.2209.git.1787322203.gitgitgadget@gmail.com>

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.

Signed-off-by: Alexey Samsonov vonosmas@gmail.com
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
-- 
gitgitgadget
Next: Alexey Samsonov via GitGitGadget
Message 1 of 19 in “treewide: migrate from legacy utime.h to utimensat”
  1. 0/3 treewide: migrate from legacy utime.h to utimensatAlexey Samsonov via GitGitGadget, Aug 21, 2026
  2. 1/3 compat/posix: introduce utimensat(2) wrapperAlexey Samsonov via GitGitGadget, Aug 21, 2026
  3. 2/3 treewide: use utimensat(2) instead of legacy utime(3p)Alexey Samsonov via GitGitGadget, Aug 21, 2026
  4. 3/3 compat/posix: drop legacy <utime.h> header and shimsAlexey Samsonov via GitGitGadget, Aug 21, 2026
  5. Junio C HamanoAug 21, 2026
  6. brian m. carlsonAug 22, 2026
  7. Junio C HamanoAug 22, 2026
  8. brian m. carlsonAug 22, 2026
  9. Junio C HamanoAug 23, 2026
  10. Weijie YuanAug 23, 2026
  11. Junio C HamanoAug 23, 2026
  12. Weijie YuanAug 23, 2026
  13. Junio C HamanoAug 24, 2026
  14. Weijie YuanAug 24, 2026
  15. Weijie YuanAug 24, 2026
  16. Junio C HamanoAug 24, 2026
  17. Junio C HamanoAug 24, 2026
  18. Weijie YuanAug 24, 2026
  19. Oswald BuddenhagenAug 24, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.