File tree Expand file tree Collapse file tree 3 files changed +33
-21
lines changed Expand file tree Collapse file tree 3 files changed +33
-21
lines changed Original file line number Diff line number Diff line change @@ -30,26 +30,32 @@ public Worktree(string repo)
3030 last = new Models . Worktree ( ) { FullPath = line . Substring ( 9 ) . Trim ( ) } ;
3131 last . RelativePath = Path . GetRelativePath ( WorkingDirectory , last . FullPath ) ;
3232 worktrees . Add ( last ) ;
33+ continue ;
3334 }
34- else if ( line . StartsWith ( "bare" , StringComparison . Ordinal ) )
35+
36+ if ( last == null )
37+ continue ;
38+
39+ if ( line . StartsWith ( "bare" , StringComparison . Ordinal ) )
3540 {
36- last ! . IsBare = true ;
41+ worktrees . Remove ( last ) ;
42+ last = null ;
3743 }
3844 else if ( line . StartsWith ( "HEAD " , StringComparison . Ordinal ) )
3945 {
40- last ! . Head = line . Substring ( 5 ) . Trim ( ) ;
46+ last . Head = line . Substring ( 5 ) . Trim ( ) ;
4147 }
4248 else if ( line . StartsWith ( "branch " , StringComparison . Ordinal ) )
4349 {
44- last ! . Branch = line . Substring ( 7 ) . Trim ( ) ;
50+ last . Branch = line . Substring ( 7 ) . Trim ( ) ;
4551 }
4652 else if ( line . StartsWith ( "detached" , StringComparison . Ordinal ) )
4753 {
48- last ! . IsDetached = true ;
54+ last . IsDetached = true ;
4955 }
5056 else if ( line . StartsWith ( "locked" , StringComparison . Ordinal ) )
5157 {
52- last ! . IsLocked = true ;
58+ last . IsLocked = true ;
5359 }
5460 }
5561 }
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ public class Worktree : ObservableObject
99 public string FullPath { get ; set ; } = string . Empty ;
1010 public string RelativePath { get ; set ; } = string . Empty ;
1111 public string Head { get ; set ; } = string . Empty ;
12- public bool IsBare { get ; set ; } = false ;
1312 public bool IsDetached { get ; set ; } = false ;
1413
1514 public bool IsLocked
Original file line number Diff line number Diff line change @@ -1219,25 +1219,32 @@ public void RefreshBranches()
12191219 public void RefreshWorktrees ( )
12201220 {
12211221 var worktrees = new Commands . Worktree ( _fullpath ) . ReadAllAsync ( ) . Result ;
1222- string commonDir = null ;
12231222 if ( worktrees . Count > 0 )
1224- commonDir = new Commands . QueryGitCommonDir ( _fullpath ) . GetResultAsync ( ) . Result ;
1225- var cleaned = new List < Models . Worktree > ( ) ;
1226-
1227- foreach ( var worktree in worktrees )
12281223 {
1229- if ( worktree . IsBare || worktree . FullPath . Equals ( _fullpath ) )
1230- continue ;
1231- if ( ! string . IsNullOrEmpty ( commonDir ) && worktree . FullPath . Equals ( commonDir ) )
1232- continue ;
1224+ var cleaned = new List < Models . Worktree > ( ) ;
1225+ var normalizedGitDir = _gitDir . Replace ( '\\ ' , '/' ) ;
12331226
1234- cleaned . Add ( worktree ) ;
1235- }
1227+ foreach ( var worktree in worktrees )
1228+ {
1229+ if ( worktree . FullPath . Equals ( _fullpath , StringComparison . Ordinal ) ||
1230+ worktree . FullPath . Equals ( normalizedGitDir , StringComparison . Ordinal ) )
1231+ continue ;
12361232
1237- Dispatcher . UIThread . Invoke ( ( ) =>
1233+ cleaned . Add ( worktree ) ;
1234+ }
1235+
1236+ Dispatcher . UIThread . Invoke ( ( ) =>
1237+ {
1238+ Worktrees = cleaned ;
1239+ } ) ;
1240+ }
1241+ else
12381242 {
1239- Worktrees = cleaned ;
1240- } ) ;
1243+ Dispatcher . UIThread . Invoke ( ( ) =>
1244+ {
1245+ Worktrees = worktrees ;
1246+ } ) ;
1247+ }
12411248 }
12421249
12431250 public void RefreshTags ( )
You can’t perform that action at this time.
0 commit comments