Repository navigation
list: add --numeric-owner, and list ids when a header has no names - #405
ozenyunus35 wants to merge 4 commits into
Conversation
`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
Merging this PR will not alter performance
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| input: impl Read, | ||
| _archive_path: &Path, | ||
| verbose: bool, | ||
| numeric_owner: bool, |
There was a problem hiding this comment.
two bools in a row are easy to swap at the call site
not blocking, but an options struct could come later
There was a problem hiding this comment.
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.
| 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(), |
There was a problem hiding this comment.
if the uid field is corrupt we print 0, i.e. root
maybe better to keep it empty in that case?
There was a problem hiding this comment.
Agreed, an unreadable uid/gid is now left empty instead of 0, with a small unit test for owner_label.
| .current_dir(at.as_string()) | ||
| .succeeds() | ||
| .stdout_move_str(); | ||
| for line in listing.lines() { |
There was a problem hiding this comment.
this loop passes on empty output too
could you please assert there are 2 lines?
There was a problem hiding this comment.
Good catch, it now asserts there are exactly 2 lines before checking them.
# Conflicts: # src/uu/tar/src/tar.rs
|
Closing this, as I can't follow up on it further. Thanks for the reviews. |
Closes #203
tar -tvprinted 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-owneralways 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_archivegets anumeric_ownerflag; the unit test and bench callers passfalse. Addedtest_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.