Skip to content

Commit

Permalink
Merge pull request #80 from Haacked/fix-layout-crash
Browse files Browse the repository at this point in the history
Fix crash with repository with one commit
  • Loading branch information
haacked committed Oct 8, 2015
2 parents 2b2622e + dacbaab commit 91b4784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 8 additions & 3 deletions SeeGitApp/Models/RepositoryGraphBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ public RepositoryGraph Graph()
AddBranchReferences();
AddHeadReference();

_graph.LayoutAlgorithmType = App.LayoutAlgorithm;
// Efficient Sugiyama crashes if we have a single commit repository. So we start with CompoundFDP.
// The original attempt to fix this, 50ca739aaadd7249f864d17cae060b1a27e22029, had a bug where we never
// changed the algorithm back to Efficient Sugiyama. This fixes that.
_graph.LayoutAlgorithmType =
_graph.VertexCount == 1
? "CompoundFDP"
: App.LayoutAlgorithm;
return _graph;
}

Expand Down Expand Up @@ -130,12 +136,11 @@ private void AddCommitsToGraph(Commit commit, CommitVertex childVertex)
// KeyValuePair is faster than a Tuple in this case.
// We create as many instances as we pass to the AddCommitToGraph.
Queue<CommitWithChildVertex> queue = new Queue<CommitWithChildVertex>();
CommitWithChildVertex commitIter;
queue.Enqueue(new CommitWithChildVertex(commit, childVertex));

while (queue.Count != 0)
{
commitIter = queue.Dequeue();
var commitIter = queue.Dequeue();
if (!AddCommitToGraph(commitIter.Key, commitIter.Value))
continue;

Expand Down
5 changes: 1 addition & 4 deletions SeeGitApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ public void MonitorRepository(string repositoryWorkingPath)

_graphBuilder = _graphBuilderThunk(gitPath);
RepositoryPath = Directory.GetParent(gitPath).FullName;
var graph = _graphBuilder.Graph();

if (graph.VertexCount > 1)
graph.LayoutAlgorithmType = App.LayoutAlgorithm;
Graph = graph;
Graph = _graphBuilder.Graph();

if (!Directory.Exists(gitPath))
MonitorForRepositoryCreation(RepositoryPath);
Expand Down

0 comments on commit 91b4784

Please sign in to comment.