@@ -1358,6 +1358,37 @@ describePosix("scripts/pr per-PR operation lock", () => {
13581358 }
13591359 } ) ;
13601360
1361+ it ( "joins worktree-list producers before releasing a successful operation lock" , async ( ) => {
1362+ const repoDir = createRepo ( ) ;
1363+ const producerExited = join ( repoDir , "worktree-producer-exited" ) ;
1364+ const fixture = writeOperationFixture ( repoDir , "joined-worktree-operation.sh" , [
1365+ "acquire_pr_operation_lock 42" ,
1366+ "git() {" ,
1367+ ' if [ "$1" = worktree ] && [ "$2" = list ]; then' ,
1368+ " printf 'worktree %s\\0branch refs/heads/pr-42\\0\\0' \"$PWD\"" ,
1369+ " exec 1>&-" ,
1370+ " sleep 0.1" ,
1371+ " : >worktree-producer-exited" ,
1372+ " return 0" ,
1373+ " fi" ,
1374+ ' command git "$@"' ,
1375+ "}" ,
1376+ 'worktree_is_registered "$PWD"' ,
1377+ "test -f worktree-producer-exited" ,
1378+ "rm worktree-producer-exited" ,
1379+ 'resolved="$(worktree_path_for_branch pr-42)"' ,
1380+ 'test "$resolved" = "$PWD"' ,
1381+ "test -f worktree-producer-exited" ,
1382+ ] ) ;
1383+
1384+ const result = await runSupervisedFixture ( repoDir , fixture ) ;
1385+
1386+ expect ( result . status , result . stdout + "\n" + result . stderr ) . toBe ( 0 ) ;
1387+ expect ( existsSync ( producerExited ) ) . toBe ( true ) ;
1388+ expect ( refExists ( repoDir ) ) . toBe ( false ) ;
1389+ expect ( result . stderr ) . not . toContain ( "process group remained active after wrapper exit" ) ;
1390+ } ) ;
1391+
13611392 it ( "retains a failed operation lock when a detached child outlives its launcher" , async ( ) => {
13621393 const repoDir = createRepo ( ) ;
13631394 const nestedPidFile = join ( repoDir , "failed-nested-pgid" ) ;
@@ -2083,8 +2114,8 @@ describePosix("scripts/pr per-PR operation lock", () => {
20832114 expect ( existsSync ( worktreeDir ) ) . toBe ( true ) ;
20842115 } ) ;
20852116
2086- it ( "removes a registered relative worktree under a repo path with escapes " , ( ) => {
2087- const repoDir = createRepo ( "repo with space \\ backslash" ) ;
2117+ it ( "removes a registered relative worktree under a NUL-framed escaped Unicode path " , ( ) => {
2118+ const repoDir = createRepo ( "repo with space \\ backslash\n雪 " ) ;
20882119 const worktreeDir = join ( repoDir , ".worktrees" , "pr-42" ) ;
20892120 mkdirSync ( dirname ( worktreeDir ) , { recursive : true } ) ;
20902121 execFileSync ( "git" , [ "worktree" , "add" , "-q" , "-b" , "pr-42" , worktreeDir ] , {
@@ -2113,6 +2144,45 @@ describePosix("scripts/pr per-PR operation lock", () => {
21132144 ) . toBe ( 1 ) ;
21142145 } ) ;
21152146
2147+ it ( "propagates producer failures from NUL-framed worktree listings" , ( ) => {
2148+ const repoDir = createRepo ( ) ;
2149+ const result = runLockShell ( repoDir , [
2150+ "git() {" ,
2151+ ' if [ "$1" = worktree ] && [ "$2" = list ]; then' ,
2152+ " printf 'worktree %s\\0branch refs/heads/pr-42\\0\\0' \"$PWD\"" ,
2153+ " return 23" ,
2154+ " fi" ,
2155+ ' command git "$@"' ,
2156+ "}" ,
2157+ "set +e" ,
2158+ 'worktree_is_registered "$PWD"' ,
2159+ 'registered_status="$?"' ,
2160+ "worktree_path_for_branch pr-42 >/dev/null" ,
2161+ 'branch_status="$?"' ,
2162+ 'printf "%s %s\\n" "$registered_status" "$branch_status"' ,
2163+ ] ) ;
2164+
2165+ expect ( result . status , result . stdout + "\n" + result . stderr ) . toBe ( 0 ) ;
2166+ expect ( result . stdout . trim ( ) ) . toBe ( "23 23" ) ;
2167+ } ) ;
2168+
2169+ it ( "accepts only nonempty docs-only file lists" , ( ) => {
2170+ const repoDir = createRepo ( ) ;
2171+ const result = runLockShell ( repoDir , [
2172+ "set +e" ,
2173+ "file_list_is_docsish_only ''" ,
2174+ 'empty_status="$?"' ,
2175+ "file_list_is_docsish_only $'docs/guide.md\\nREADME.md'" ,
2176+ 'docs_status="$?"' ,
2177+ "file_list_is_docsish_only $'docs/guide.md\\nsrc/index.ts'" ,
2178+ 'mixed_status="$?"' ,
2179+ 'printf "%s %s %s\\n" "$empty_status" "$docs_status" "$mixed_status"' ,
2180+ ] ) ;
2181+
2182+ expect ( result . status , result . stdout + "\n" + result . stderr ) . toBe ( 0 ) ;
2183+ expect ( result . stdout . trim ( ) ) . toBe ( "1 0 1" ) ;
2184+ } ) ;
2185+
21162186 it ( "prunes a registered worktree whose directory is already gone" , ( ) => {
21172187 const repoDir = createRepo ( ) ;
21182188 const worktreeDir = join ( repoDir , ".worktrees" , "pr-42" ) ;
0 commit comments