Files
buildkit/source/git/mtime_unix.go
Tonis Tiigi 508dd62bf7 source: add git.mtime attr for commit-time mtimes
Add git.mtime=commit option that normalizes all file, symlink,
and directory mtimes in a git snapshot to the resolved commit
timestamp. This enables reproducible builds from git sources.

When SOURCE_DATE_EPOCH is set in the Dockerfile frontend, the
git context automatically uses commit-time mtimes. The URL
query parameter ?mtime=commit|checkout can override this.

New LLB attr (git.mtime) and capability (source.git.mtime) are
registered as experimental. Cache keys include the mtime policy
so that commit-time and checkout-time snapshots are distinct.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2026-03-23 11:58:24 -07:00

15 lines
269 B
Go

//go:build !windows
package git
import (
"time"
"golang.org/x/sys/unix"
)
func lchtimes(path string, t time.Time) error {
ts := unix.NsecToTimespec(t.UnixNano())
return unix.UtimesNanoAt(unix.AT_FDCWD, path, []unix.Timespec{ts, ts}, unix.AT_SYMLINK_NOFOLLOW)
}