[System.Formats.Tar] Add deterministic TarWriter options - #132050
Closed
jetersen wants to merge 1 commit into
Closed
[System.Formats.Tar] Add deterministic TarWriter options#132050jetersen wants to merge 1 commit into
jetersen wants to merge 1 commit into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new deterministic metadata mode to System.Formats.Tar’s TarWriter via TarWriterOptions, aiming to make produced PAX archives byte-stable across runs by removing process- and host-dependent variability.
Changes:
- Introduces
TarWriterOptions.DeterministicandOverride*metadata properties (mtime/uid/gid/uname/gname) and threads these settings throughTarWriter’s path-based entry construction. - Updates PAX header-writing to generate process-independent extended/global header names when deterministic mode is enabled.
- Adds unit tests covering option defaults, deterministic path-metadata normalization, override precedence, stable output, and PAX header name stability.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Formats.Tar/tests/TarWriterOptions.Tests.cs | Verifies default values and basic set/get for new TarWriterOptions properties. |
| src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs | Adds Unix-only privileged coverage ensuring deterministic mode doesn’t capture source ownership. |
| src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.cs | Adds cross-platform tests for deterministic normalization, override precedence, and byte-stable output. |
| src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.Entry.Pax.Tests.cs | Adds tests validating deterministic PAX extended/global header naming and preserving explicit entry metadata. |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriterOptions.cs | Adds the new public options API surface with XML documentation. |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.cs | Plumbs options into the writer, passes deterministic flag into PAX header writers, and centralizes mtime override logic. |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Unix.cs | Applies deterministic defaults and override metadata when constructing entries from filesystem paths on Unix. |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarWriter.Windows.cs | Applies mtime override and sets uid/gid/uname/gname defaults/overrides for path-based entries on Windows. |
| src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs | Adds deterministic-aware PAX extended/global header name generation and threads the flag through write helpers. |
| src/libraries/System.Formats.Tar/ref/System.Formats.Tar.cs | Exposes the new public API surface in the reference assembly contract. |
Comment on lines
140
to
+150
| public sealed partial class TarWriterOptions | ||
| { | ||
| public TarWriterOptions() { } | ||
| public bool Deterministic { get { throw null; } set { } } | ||
| public System.Formats.Tar.TarEntryFormat Format { get { throw null; } set { } } | ||
| public System.Formats.Tar.TarHardLinkMode HardLinkMode { get { throw null; } set { } } | ||
| public int? OverrideGid { get { throw null; } set { } } | ||
| public string? OverrideGName { get { throw null; } set { } } | ||
| public System.DateTimeOffset? OverrideModificationTime { get { throw null; } set { } } | ||
| public int? OverrideUid { get { throw null; } set { } } | ||
| public string? OverrideUName { get { throw null; } set { } } |
Comment on lines
+143
to
+150
| public bool Deterministic { get { throw null; } set { } } | ||
| public System.Formats.Tar.TarEntryFormat Format { get { throw null; } set { } } | ||
| public System.Formats.Tar.TarHardLinkMode HardLinkMode { get { throw null; } set { } } | ||
| public int? OverrideGid { get { throw null; } set { } } | ||
| public string? OverrideGName { get { throw null; } set { } } | ||
| public System.DateTimeOffset? OverrideModificationTime { get { throw null; } set { } } | ||
| public int? OverrideUid { get { throw null; } set { } } | ||
| public string? OverrideUName { get { throw null; } set { } } |
This was referenced Aug 9, 2026
Contributor
|
Hello, and thanks for your contribution. According to the process, Pull Requests that add new APIs must be opened after the API gets approved, which means that I have to close this. Feel free to open a new PR after that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #132049
Summary
Adds an opt-in deterministic mode to
TarWriterOptionstogether with explicit filesystem metadata overrides.0, and empty user/group names when deterministic mode is enabled.TarEntryinstances passed toWriteEntry(TarEntry).This provides the behavior needed by deterministic archive and container-image builders without requiring them to reproduce
TarWriter's internal PAX serialization.Validation
System.Formats.Tarsource and reference assemblies in Release with zero warnings and errors.System.Formats.Tar.Testsfor the Unix and Windows targets.