Skip to content

Commit

Permalink
Fix crash with repository with one commit
Browse files Browse the repository at this point in the history
Efficient Sugiyama crashes if we have a single commit repository. So we
use "CompoundFDP" when there's only one commit.
The original attempt to fix this,
50ca739, had a bug where we never
changed the algorithm back to Efficient Sugiyama. This fixes that.
  • Loading branch information
haacked committed Oct 8, 2015
1 parent 2b2622e commit dacbaab
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 dacbaab

Please sign in to comment.