drop redundant ExcludePatterns initialization - #62
Conversation
Remove the explicit initialization of nil ExcludePatterns to an empty
slice.
This normalization was introduced in moby/moby commit 62d83404
("Pass options to chroot archive untar"):
moby/moby@62d8340
The current go-archive unpack paths no longer serialize or otherwise
distinguish nil and empty slices, so the initialization is redundant.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
There was a problem hiding this comment.
Pull request overview
This PR removes redundant normalization that converted TarOptions.ExcludePatterns from nil to an empty slice ([]string{}) in several unpack-related paths. Since the current unpack logic treats nil and empty slices equivalently (e.g., range over a nil slice is safe), the explicit initialization is unnecessary.
Changes:
- Removed
ExcludePatternsnil-to-empty initialization in archive/chrootarchive unpack handlers. - Simplified
TestChrootUntarWithHugeExcludesListto passTarOptionsvia a struct literal.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| diff.go | Removes redundant ExcludePatterns slice initialization in UnpackLayer. |
| chrootarchive/diff_unix.go | Removes redundant ExcludePatterns slice initialization in applyLayerHandler. |
| chrootarchive/archive.go | Removes redundant ExcludePatterns slice initialization in untarHandler. |
| chrootarchive/archive_test.go | Adjusts test to construct TarOptions inline while preserving behavior. |
| archive.go | Removes redundant ExcludePatterns slice initialization in untarHandler. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #62 +/- ##
==========================================
- Coverage 65.75% 63.97% -1.78%
==========================================
Files 42 42
Lines 2038 2634 +596
==========================================
+ Hits 1340 1685 +345
- Misses 528 777 +249
- Partials 170 172 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Remove the explicit initialization of nil ExcludePatterns to an empty slice.
This normalization was introduced in moby/moby commit 62d83404 ("Pass options to chroot archive untar"):
moby/moby@62d8340
The current go-archive unpack paths no longer serialize or otherwise distinguish nil and empty slices, so the initialization is redundant.