Skip to content

Commit 4a8c8f7

Browse files
committed
Clarify why the glob/tilde guard is duplicated in auto-shell-policy.ts
1 parent d5cd074 commit 4a8c8f7

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/permission/auto-shell-policy.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,15 @@ function isContainedWorktreePath(
307307
rootsProvider: RootsProvider,
308308
): boolean {
309309
if (!pathArg) return false;
310-
// Shell-syntax the containment check below cannot resolve correctly:
311-
// `resolve()` treats a leading `~` as a literal path segment rather than
312-
// expanding it, so a home-relative path would otherwise read as "inside
313-
// cwd"; a glob is not a single concrete destination at all.
310+
// Shell-syntax `isRestricted` below cannot resolve correctly: `resolve()`
311+
// treats a leading `~` as a literal path segment rather than expanding it,
312+
// so a home-relative path would otherwise read as "inside cwd" on the very
313+
// next line; a glob is not a single concrete destination at all. This
314+
// duplicates isPermittedSiblingWorktreePath's own guard against the same
315+
// two forms, but that duplication is required, not incidental: this check
316+
// has to run before the isRestricted() shortcut below even executes, while
317+
// isPermittedSiblingWorktreePath's copy protects direct/standalone callers
318+
// of that exported function.
314319
if (/[*?[]/.test(pathArg)) return false;
315320
if (pathArg.startsWith("~")) return false;
316321

0 commit comments

Comments
 (0)