Skip to content

source: add git.mtime attr for commit-time mtimes - #6600

Merged
tonistiigi merged 1 commit into
moby:masterfrom
tonistiigi:git-mtime-commit
Mar 25, 2026
Merged

tonistiigi merged 1 commit into
moby:masterfrom
tonistiigi:git-mtime-commit

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

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.

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>
Comment on lines +60 to +61
// MTime controls file modification time policy: "checkout" (default) or "commit".
MTime string

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some constants for the various states here? I think it's better if they're unexported constants but they seem to be used frequently enough that I think constants would be helpful to prevent accidental mistypes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into this but it doesn't look like it would help much. This is dfgitutil and there is only one usage of it. Then there is GitIdentifier in the solver that is created from proto attributes. So they are two distinct types (with the proto attr doing the conversion) and I don't really want to make them depend on each other.

@tonistiigi
tonistiigi merged commit 1fc2d12 into moby:master Mar 25, 2026
190 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants