fix(ignore, fs): allow loading ignore patterns behind symlink (fixes #10785) (#10786)

The recent change to disallow following symlinks by default conflicts
with the expected behavior of .stignore. This adds a new flag which may
be passed to OpenFile to skip default symlink-forbidding open flag.

---------

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-07-16 09:19:13 +08:00
committed by GitHub
parent d4cffd848e
commit c1d8045d86
6 changed files with 60 additions and 5 deletions
+11
View File
@@ -12,6 +12,7 @@ import (
"fmt"
"io"
"io/fs"
"math/bits"
"os"
"path/filepath"
"strings"
@@ -173,8 +174,18 @@ const (
OptSync = os.O_SYNC
OptTruncate = os.O_TRUNC
OptWriteOnly = os.O_WRONLY
OptFollow = 1 << (bits.UintSize - 2)
)
func init() {
// Ensure OptFollow doesn't clash with any other flag.
flags := OptAppend | OptCreate | OptExclusive | OptReadOnly | OptReadWrite | OptSync | OptTruncate | OptWriteOnly
flags &= OptFollow
if flags != 0 {
panic("bug: flag clash")
}
}
// SkipDir is used as a return value from WalkFuncs to indicate that
// the directory named in the call is to be skipped. It is not returned
// as an error by any function.