@@ -15,7 +15,7 @@ public QueryBranches(string repo)
15
15
{
16
16
WorkingDirectory = repo ;
17
17
Context = repo ;
18
- Args = "branch -l --all -v --format=\" %(refname)%00%(committerdate:unix)%00%(objectname)%00%(HEAD)%00%(upstream)%00%(upstream:trackshort)\" " ;
18
+ Args = "branch -l --all -v --format=\" %(refname)%00%(committerdate:unix)%00%(objectname)%00%(HEAD)%00%(upstream)%00%(upstream:trackshort)%00%(worktreepath) \" " ;
19
19
}
20
20
21
21
public async Task < List < Models . Branch > > GetResultAsync ( )
@@ -26,42 +26,44 @@ public QueryBranches(string repo)
26
26
return branches ;
27
27
28
28
var lines = rs . StdOut . Split ( [ '\r ' , '\n ' ] , StringSplitOptions . RemoveEmptyEntries ) ;
29
- var remoteHeads = new Dictionary < string , string > ( ) ;
29
+ var mismatched = new HashSet < string > ( ) ;
30
+ var remotes = new Dictionary < string , Models . Branch > ( ) ;
30
31
foreach ( var line in lines )
31
32
{
32
- var b = ParseLine ( line ) ;
33
+ var b = ParseLine ( line , mismatched ) ;
33
34
if ( b != null )
34
35
{
35
36
branches . Add ( b ) ;
36
37
if ( ! b . IsLocal )
37
- remoteHeads . Add ( b . FullName , b . Head ) ;
38
+ remotes . Add ( b . FullName , b ) ;
38
39
}
39
40
}
40
41
41
42
foreach ( var b in branches )
42
43
{
43
44
if ( b . IsLocal && ! string . IsNullOrEmpty ( b . Upstream ) )
44
45
{
45
- if ( remoteHeads . TryGetValue ( b . Upstream , out var upstreamHead ) )
46
+ if ( remotes . TryGetValue ( b . Upstream , out var upstream ) )
46
47
{
47
48
b . IsUpstreamGone = false ;
48
- b . TrackStatus ??= await new QueryTrackStatus ( WorkingDirectory , b . Head , upstreamHead ) . GetResultAsync ( ) . ConfigureAwait ( false ) ;
49
+
50
+ if ( mismatched . Contains ( b . FullName ) )
51
+ await new QueryTrackStatus ( WorkingDirectory ) . GetResultAsync ( b , upstream ) . ConfigureAwait ( false ) ;
49
52
}
50
53
else
51
54
{
52
55
b . IsUpstreamGone = true ;
53
- b . TrackStatus ??= new Models . BranchTrackStatus ( ) ;
54
56
}
55
57
}
56
58
}
57
59
58
60
return branches ;
59
61
}
60
62
61
- private Models . Branch ParseLine ( string line )
63
+ private Models . Branch ParseLine ( string line , HashSet < string > mismatched )
62
64
{
63
65
var parts = line . Split ( '0円 ' ) ;
64
- if ( parts . Length != 6 )
66
+ if ( parts . Length != 7 )
65
67
return null ;
66
68
67
69
var branch = new Models . Branch ( ) ;
@@ -103,12 +105,13 @@ private Models.Branch ParseLine(string line)
103
105
branch . Upstream = parts [ 4 ] ;
104
106
branch . IsUpstreamGone = false ;
105
107
106
- if ( ! branch . IsLocal ||
107
- string . IsNullOrEmpty ( branch . Upstream ) ||
108
- string . IsNullOrEmpty ( parts [ 5 ] ) ||
109
- parts [ 5 ] . Equals ( "=" , StringComparison . Ordinal ) )
110
- branch . TrackStatus = new Models . BranchTrackStatus ( ) ;
108
+ if ( branch . IsLocal &&
109
+ ! string . IsNullOrEmpty ( branch . Upstream ) &&
110
+ ! string . IsNullOrEmpty ( parts [ 5 ] ) &&
111
+ ! parts [ 5 ] . Equals ( "=" , StringComparison . Ordinal ) )
112
+ mismatched . Add ( branch . FullName ) ;
111
113
114
+ branch . WorktreePath = parts [ 6 ] ;
112
115
return branch ;
113
116
}
114
117
}
0 commit comments