Skip to content

list: add --numeric-owner, and list ids when a header has no names - #405

Closed
ozenyunus35 wants to merge 4 commits into
uutils:mainfrom
ozenyunus35:numeric-owner
Closed

ozenyunus35 wants to merge 4 commits into
uutils:mainfrom
ozenyunus35:numeric-owner

Conversation

@ozenyunus35

Copy link
Copy Markdown
Contributor

Closes #203

  • tar -tv printed an empty owner and group (/) for an entry whose header records no user or group name, which is every archive tar-rs writes. Like GNU tar, it now prints the numeric uid/gid in that case.
  • --numeric-owner always prints the numeric ids, even when names are recorded.

Only listing is affected: create doesn't write names (tar-rs leaves them empty) and extract doesn't restore ownership yet, so there's nothing for the option to change there today.

list_archive gets a numeric_owner flag; the unit test and bench callers pass false. Added test_list_verbose_owner_names_and_numeric_owner, which builds an archive with and without names. It fails without the change.

I used an AI assistant to help draft parts of the code and tests; I reviewed the changes and ran the tests myself.

`tar -tv` printed an empty owner and group (`/`) for an entry whose header
records no user or group name, which is every archive tar-rs writes. Like
GNU tar, it now prints the numeric ids then, and `--numeric-owner` always
prints them.

Closes uutils#203
@ozenyunus35
ozenyunus35 requested a review from kaladron as a code owner October 14, 2026 14:49
@codspeed

codspeed Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 4 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 7 untouched benchmarks


Comparing ozenyunus35:numeric-owner (e6fafea) with main (fb55fee)

Open in CodSpeed

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.03%. Comparing base (791ae26) to head (e6fafea).
⚠️ Report is 90 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #405      +/-   ##
==========================================
+ Coverage   96.84%   98.03%   +1.18%     
==========================================
  Files          11       15       +4     
  Lines        1492     1887     +395     
  Branches       29       40      +11     
==========================================
+ Hits         1445     1850     +405     
+ Misses         46       36      -10     
  Partials        1        1              
Flag Coverage Δ
macos_latest 98.03% <100.00%> (+1.18%) ⬆️
ubuntu_latest 98.03% <100.00%> (+1.18%) ⬆️
windows_latest 0.00% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

input: impl Read,
_archive_path: &Path,
verbose: bool,
numeric_owner: bool,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

two bools in a row are easy to swap at the call site
not blocking, but an options struct could come later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I'd keep it as is here and move the list options into a struct in a follow-up once more of them show up.

Comment thread src/uu/tar/src/operations/list.rs Outdated
fn owner_label(name: Option<&str>, id: Option<u64>, numeric: bool) -> String {
match name {
Some(name) if !numeric && !name.is_empty() => name.to_owned(),
_ => id.unwrap_or(0).to_string(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if the uid field is corrupt we print 0, i.e. root
maybe better to keep it empty in that case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, an unreadable uid/gid is now left empty instead of 0, with a small unit test for owner_label.

Comment thread tests/by-util/test_tar.rs Outdated
.current_dir(at.as_string())
.succeeds()
.stdout_move_str();
for line in listing.lines() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this loop passes on empty output too
could you please assert there are 2 lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it now asserts there are exactly 2 lines before checking them.

@ozenyunus35

Copy link
Copy Markdown
Contributor Author

Closing this, as I can't follow up on it further. Thanks for the reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GNU tar compatibility: Add --numeric-owner

2 participants