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 {
867
867
export interface Worktree {
868
868
readonly name : string ;
869
869
readonly path : string ;
870
+ readonly ref : string ;
870
871
}
871
872
872
873
export interface Submodule {
@@ -2805,13 +2806,20 @@ export class Repository {
2805
2806
continue ;
2806
2807
}
2807
2808
2808
- const gitdirPath = path . join ( worktreesPath , dirent . name , 'gitdir' ) ;
2809
-
2810
2809
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' ) ;
2811
2814
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
+ } ) ;
2815
2823
} catch ( err ) {
2816
2824
if ( / E N O E N T / . test ( err . message ) ) {
2817
2825
continue ;
You can’t perform that action at this time.
0 commit comments