Merge pull request #1144 from lukas-ais/fix_StackOverflowException
fixed StackOverflowException in complex branch history (#848)
This commit is contained in:
@@ -248,6 +248,7 @@ namespace GitTfs.VsCommon
|
||||
|
||||
public IList<RootBranch> GetRootChangesetForBranch(string tfsPathBranchToCreate, int lastChangesetIdToCheck = -1, string tfsPathParentBranch = null)
|
||||
{
|
||||
Trace.WriteLine("Looking for root changeset tree on " + tfsPathBranchToCreate);
|
||||
var rootBranches = new List<RootBranch>();
|
||||
GetRootChangesetForBranch(rootBranches, tfsPathBranchToCreate, lastChangesetIdToCheck, tfsPathParentBranch);
|
||||
return rootBranches;
|
||||
@@ -284,8 +285,8 @@ namespace GitTfs.VsCommon
|
||||
|
||||
if (tfsParentBranch == null)
|
||||
{
|
||||
throw new GitTfsException("error : the branch you try to initialize '" + tfsPathBranchToCreate + "' is a root branch (e.g. has no parents).",
|
||||
new List<string> { "Clone this branch from Tfs instead of trying to initialize it!\n Command: git tfs clone " + Url + " " + tfsPathBranchToCreate });
|
||||
Trace.WriteLine("There is no parent branch for " + tfsPathBranchToCreate + ". Ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
tfsPathParentBranch = tfsParentBranch;
|
||||
@@ -362,9 +363,9 @@ namespace GitTfs.VsCommon
|
||||
rootChangesetMergeInfo.TargetChangeset : rootChangesetMergeInfo.SourceChangeset;
|
||||
|
||||
var rootBranch = new RootBranch(rootChangesetInParentBranch, rootChangesetInChildBranch, tfsPathBranchToCreate);
|
||||
AddNewRootBranch(rootBranches, rootBranch);
|
||||
var added = AddNewRootBranch(rootBranches, rootBranch);
|
||||
|
||||
if (renameFromBranch != null)
|
||||
if (added && renameFromBranch != null)
|
||||
{
|
||||
Trace.WriteLine("Found original branch '" + renameFromBranch + "' (renamed in branch '" + tfsPathBranchToCreate + "')");
|
||||
GetRootChangesetForBranch(rootBranches, renameFromBranch);
|
||||
@@ -531,11 +532,19 @@ namespace GitTfs.VsCommon
|
||||
});
|
||||
}
|
||||
|
||||
private static void AddNewRootBranch(IList<RootBranch> rootBranches, RootBranch rootBranch)
|
||||
private static bool AddNewRootBranch(IList<RootBranch> rootBranches, RootBranch rootBranch)
|
||||
{
|
||||
if (rootBranches.Any(x => x.TfsBranchPath == rootBranch.TfsBranchPath))
|
||||
{
|
||||
// already in
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rootBranches.Any())
|
||||
rootBranch.IsRenamedBranch = true;
|
||||
rootBranches.Insert(0, rootBranch);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private int AskForRootChangesetId()
|
||||
|
||||
Reference in New Issue
Block a user