Skip to content

Commit 0972af1

Browse files
authored
Merge pull request #6025 from jsternberg/unconditional-clear-mode-irregular
contenthash: unconditionally clear ModeIrregular during content hash
2 parents 25c7c80 + 450362a commit 0972af1

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

cache/contenthash/filehash.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,8 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
4141
}
4242

4343
func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
44-
// Clear the irregular file bit if this is some kind of special
45-
// file. Pre-Go 1.23 behavior would only add the irregular file
46-
// bit to regular files with non-handled reparse points.
47-
// Current versions of Go now apply them to directories too.
48-
// archive/tar.FileInfoHeader does not handle the irregular bit.
49-
if stat.Mode&uint32(os.ModeType&^os.ModeIrregular) != 0 {
50-
stat.Mode &^= uint32(os.ModeIrregular)
51-
}
52-
53-
// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
54-
stat.Mode &^= uint32(os.ModeSocket)
44+
// Clear the socket and irregular bits since archive/tar.FileInfoHeader does not handle them
45+
stat.Mode &^= uint32(os.ModeSocket | os.ModeIrregular)
5546

5647
fi := &statInfo{stat}
5748
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)

0 commit comments

Comments
 (0)