@@ -27,15 +27,15 @@ public QueryBranches(string repo)
27
27
return branches ;
28
28
29
29
var lines = rs . StdOut . Split ( [ '\r ' , '\n ' ] , StringSplitOptions . RemoveEmptyEntries ) ;
30
- var remoteBranches = new HashSet < string > ( ) ;
30
+ var remoteHeads = new Dictionary < string , string > ( ) ;
31
31
foreach ( var line in lines )
32
32
{
33
33
var b = ParseLine ( line ) ;
34
34
if ( b != null )
35
35
{
36
36
branches . Add ( b ) ;
37
37
if ( ! b . IsLocal )
38
- remoteBranches . Add ( b . FullName ) ;
38
+ remoteHeads . Add ( b . FullName , b . Head ) ;
39
39
else
40
40
localBranchesCount ++ ;
41
41
}
@@ -44,7 +44,22 @@ public QueryBranches(string repo)
44
44
foreach ( var b in branches )
45
45
{
46
46
if ( b . IsLocal && ! string . IsNullOrEmpty ( b . Upstream ) )
47
- b . IsUpstreamGone = ! remoteBranches . Contains ( b . Upstream ) ;
47
+ {
48
+ if ( remoteHeads . TryGetValue ( b . Upstream , out var upstreamHead ) )
49
+ {
50
+ b . IsUpstreamGone = false ;
51
+
52
+ if ( b . TrackStatus == null )
53
+ b . TrackStatus = new QueryTrackStatus ( WorkingDirectory , b . Head , upstreamHead ) . Result ( ) ;
54
+ }
55
+ else
56
+ {
57
+ b . IsUpstreamGone = true ;
58
+
59
+ if ( b . TrackStatus == null )
60
+ b . TrackStatus = new Models . BranchTrackStatus ( ) ;
61
+ }
62
+ }
48
63
}
49
64
50
65
return branches ;
@@ -93,9 +108,10 @@ private Models.Branch ParseLine(string line)
93
108
branch . Upstream = parts [ 4 ] ;
94
109
branch . IsUpstreamGone = false ;
95
110
96
- if ( branch . IsLocal && ! string . IsNullOrEmpty ( parts [ 5 ] ) && ! parts [ 5 ] . Equals ( "=" , StringComparison . Ordinal ) )
97
- branch . TrackStatus = new QueryTrackStatus ( WorkingDirectory , branch . Name , branch . Upstream ) . Result ( ) ;
98
- else
111
+ if ( ! branch . IsLocal ||
112
+ string . IsNullOrEmpty ( branch . Upstream ) ||
113
+ string . IsNullOrEmpty ( parts [ 5 ] ) ||
114
+ parts [ 5 ] . Equals ( "=" , StringComparison . Ordinal ) )
99
115
branch . TrackStatus = new Models . BranchTrackStatus ( ) ;
100
116
101
117
return branch ;
0 commit comments