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)
30
30
last = new Models . Worktree ( ) { FullPath = line . Substring ( 9 ) . Trim ( ) } ;
31
31
last . RelativePath = Path . GetRelativePath ( WorkingDirectory , last . FullPath ) ;
32
32
worktrees . Add ( last ) ;
33
+ continue ;
33
34
}
34
- else if ( line . StartsWith ( "bare" , StringComparison . Ordinal ) )
35
+
36
+ if ( last == null )
37
+ continue ;
38
+
39
+ if ( line . StartsWith ( "bare" , StringComparison . Ordinal ) )
35
40
{
36
- last ! . IsBare = true ;
41
+ worktrees . Remove ( last ) ;
42
+ last = null ;
37
43
}
38
44
else if ( line . StartsWith ( "HEAD " , StringComparison . Ordinal ) )
39
45
{
40
- last ! . Head = line . Substring ( 5 ) . Trim ( ) ;
46
+ last . Head = line . Substring ( 5 ) . Trim ( ) ;
41
47
}
42
48
else if ( line . StartsWith ( "branch " , StringComparison . Ordinal ) )
43
49
{
44
- last ! . Branch = line . Substring ( 7 ) . Trim ( ) ;
50
+ last . Branch = line . Substring ( 7 ) . Trim ( ) ;
45
51
}
46
52
else if ( line . StartsWith ( "detached" , StringComparison . Ordinal ) )
47
53
{
48
- last ! . IsDetached = true ;
54
+ last . IsDetached = true ;
49
55
}
50
56
else if ( line . StartsWith ( "locked" , StringComparison . Ordinal ) )
51
57
{
52
- last ! . IsLocked = true ;
58
+ last . IsLocked = true ;
53
59
}
54
60
}
55
61
}
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ public class Worktree : ObservableObject
9
9
public string FullPath { get ; set ; } = string . Empty ;
10
10
public string RelativePath { get ; set ; } = string . Empty ;
11
11
public string Head { get ; set ; } = string . Empty ;
12
- public bool IsBare { get ; set ; } = false ;
13
12
public bool IsDetached { get ; set ; } = false ;
14
13
15
14
public bool IsLocked
Original file line number Diff line number Diff line change @@ -1219,25 +1219,32 @@ public void RefreshBranches()
1219
1219
public void RefreshWorktrees ( )
1220
1220
{
1221
1221
var worktrees = new Commands . Worktree ( _fullpath ) . ReadAllAsync ( ) . Result ;
1222
- string commonDir = null ;
1223
1222
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 )
1228
1223
{
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 ( '\\ ' , '/' ) ;
1233
1226
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 ;
1236
1232
1237
- Dispatcher . UIThread . Invoke ( ( ) =>
1233
+ cleaned . Add ( worktree ) ;
1234
+ }
1235
+
1236
+ Dispatcher . UIThread . Invoke ( ( ) =>
1237
+ {
1238
+ Worktrees = cleaned ;
1239
+ } ) ;
1240
+ }
1241
+ else
1238
1242
{
1239
- Worktrees = cleaned ;
1240
- } ) ;
1243
+ Dispatcher . UIThread . Invoke ( ( ) =>
1244
+ {
1245
+ Worktrees = worktrees ;
1246
+ } ) ;
1247
+ }
1241
1248
}
1242
1249
1243
1250
public void RefreshTags ( )
You can’t perform that action at this time.
0 commit comments