File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -867,6 +867,7 @@ export class GitStatusParser {
867867export interface Worktree {
868868 readonly name : string ;
869869 readonly path : string ;
870+ readonly ref : string ;
870871}
871872
872873export interface Submodule {
@@ -2805,13 +2806,20 @@ export class Repository {
28052806 continue ;
28062807 }
28072808
2808- const gitdirPath = path . join ( worktreesPath , dirent . name , 'gitdir' ) ;
2809-
28102809 try {
2810+ const headPath = path . join ( worktreesPath , dirent . name , 'HEAD' ) ;
2811+ const headContent = ( await fs . readFile ( headPath , 'utf8' ) ) . trim ( ) ;
2812+
2813+ const gitdirPath = path . join ( worktreesPath , dirent . name , 'gitdir' ) ;
28112814 const gitdirContent = ( await fs . readFile ( gitdirPath , 'utf8' ) ) . trim ( ) ;
2812- // Remove trailing '/.git'
2813- const gitdirTrimmed = gitdirContent . replace ( / \. g i t .* $ / , '' ) ;
2814- result . push ( { name : dirent . name , path : gitdirTrimmed } ) ;
2815+
2816+ result . push ( {
2817+ name : dirent . name ,
2818+ // Remove '/.git' suffix
2819+ path : gitdirContent . replace ( / \. g i t .* $ / , '' ) ,
2820+ // Remove 'ref: ' prefix
2821+ ref : headContent . replace ( / ^ r e f : / , '' ) ,
2822+ } ) ;
28152823 } catch ( err ) {
28162824 if ( / E N O E N T / . test ( err . message ) ) {
28172825 continue ;
You can’t perform that action at this time.
0 commit comments