File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,26 @@ export abstract class ShadowCheckpointService extends EventEmitter {
9090 this . log ( `[${ this . constructor . name } #initShadowGit] shadow git repo already exists at ${ this . dotGitDir } ` )
9191 const worktree = await this . getShadowGitConfigWorktree ( git )
9292
93- if ( worktree !== this . workspaceDir ) {
93+ // Normalize and compare paths in a cross-platform safe way (handles:
94+ // - Windows path separators
95+ // - Case-insensitivity
96+ // - Short (8.3) vs long paths via realpath fallback)
97+ const normalizeFsPath = ( p : string ) => {
98+ const normalized = path . normalize ( p )
99+ return process . platform === "win32" ? normalized . toLowerCase ( ) : normalized
100+ }
101+ const pathsEqual = async ( a ?: string , b ?: string ) => {
102+ if ( ! a || ! b ) return false
103+ try {
104+ const [ ra , rb ] = await Promise . all ( [ fs . realpath ( a ) , fs . realpath ( b ) ] )
105+ return normalizeFsPath ( ra ) === normalizeFsPath ( rb )
106+ } catch {
107+ return normalizeFsPath ( a ) === normalizeFsPath ( b )
108+ }
109+ }
110+
111+ const sameWorkspace = await pathsEqual ( worktree , this . workspaceDir )
112+ if ( ! sameWorkspace ) {
94113 throw new Error (
95114 `Checkpoints can only be used in the original workspace: ${ worktree } !== ${ this . workspaceDir } ` ,
96115 )
You can’t perform that action at this time.
0 commit comments