mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-05 11:05:00 +00:00
fix: sometimes track status is not correct because the local branch name is ambiguous to git
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
ac26d5bb06
commit
cfc80d41a1
1 changed files with 22 additions and 6 deletions
|
@ -27,7 +27,7 @@ namespace SourceGit.Commands
|
||||||
return branches;
|
return branches;
|
||||||
|
|
||||||
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
|
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
|
||||||
var remoteBranches = new HashSet<string>();
|
var remoteHeads = new Dictionary<string, string>();
|
||||||
foreach (var line in lines)
|
foreach (var line in lines)
|
||||||
{
|
{
|
||||||
var b = ParseLine(line);
|
var b = ParseLine(line);
|
||||||
|
@ -35,7 +35,7 @@ namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
branches.Add(b);
|
branches.Add(b);
|
||||||
if (!b.IsLocal)
|
if (!b.IsLocal)
|
||||||
remoteBranches.Add(b.FullName);
|
remoteHeads.Add(b.FullName, b.Head);
|
||||||
else
|
else
|
||||||
localBranchesCount++;
|
localBranchesCount++;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,22 @@ namespace SourceGit.Commands
|
||||||
foreach (var b in branches)
|
foreach (var b in branches)
|
||||||
{
|
{
|
||||||
if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream))
|
if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream))
|
||||||
b.IsUpstreamGone = !remoteBranches.Contains(b.Upstream);
|
{
|
||||||
|
if (remoteHeads.TryGetValue(b.Upstream, out var upstreamHead))
|
||||||
|
{
|
||||||
|
b.IsUpstreamGone = false;
|
||||||
|
|
||||||
|
if (b.TrackStatus == null)
|
||||||
|
b.TrackStatus = new QueryTrackStatus(WorkingDirectory, b.Head, upstreamHead).Result();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
b.IsUpstreamGone = true;
|
||||||
|
|
||||||
|
if (b.TrackStatus == null)
|
||||||
|
b.TrackStatus = new Models.BranchTrackStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return branches;
|
return branches;
|
||||||
|
@ -93,9 +108,10 @@ namespace SourceGit.Commands
|
||||||
branch.Upstream = parts[4];
|
branch.Upstream = parts[4];
|
||||||
branch.IsUpstreamGone = false;
|
branch.IsUpstreamGone = false;
|
||||||
|
|
||||||
if (branch.IsLocal && !string.IsNullOrEmpty(parts[5]) && !parts[5].Equals("=", StringComparison.Ordinal))
|
if (!branch.IsLocal ||
|
||||||
branch.TrackStatus = new QueryTrackStatus(WorkingDirectory, branch.Name, branch.Upstream).Result();
|
string.IsNullOrEmpty(branch.Upstream) ||
|
||||||
else
|
string.IsNullOrEmpty(parts[5]) ||
|
||||||
|
parts[5].Equals("=", StringComparison.Ordinal))
|
||||||
branch.TrackStatus = new Models.BranchTrackStatus();
|
branch.TrackStatus = new Models.BranchTrackStatus();
|
||||||
|
|
||||||
return branch;
|
return branch;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue