tar: add --backup[=CONTROL] and --suffix options#315
Conversation
Back up existing files before overwriting during extraction. CONTROL may be none/off, simple/never, numbered/t, existing/nil (default when flag is given: existing). --suffix overrides the simple backup suffix (default: ~). Related to uutils#250
Merging this PR will degrade performance by 11.61%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | build_cli_command |
44.3 µs | 50.1 µs | -11.61% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing nnosal:feat/backup (bb83a62) with main (9aa518b)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #315 +/- ##
==========================================
+ Coverage 96.84% 97.26% +0.41%
==========================================
Files 11 15 +4
Lines 1492 1976 +484
Branches 29 37 +8
==========================================
+ Hits 1445 1922 +477
- Misses 46 53 +7
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:
|
Summary
Implements
--backup[=CONTROL]and--suffix=STRINGextraction options as described in issue #250.--backup(no value) backs up existing files using theexistingstrategy (numbered if.~1~present, otherwise simple).--backup=CONTROLacceptsnone/off,simple/never,numbered/t,existing/nil.--suffix=STRINGoverrides the default suffix (~) used by the simple backup strategy.Backup logic lives in
src/uu/tar/src/operations/extract.rs. The three helper functions (simple_backup_path,numbered_backup_path,backup_file) are pure and independently testable.Test plan
cargo test --allpasses (113 tests including 9 new backup-specific unit tests)cargo fmt --all -- --checkcleancargo clippy --workspace --all-targets -ptarapp -D warningscleanBackupControlvariants, custom suffix, no-op when no existing file, numbered increment, andexistingfallback logicFixes #250