Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash with repository with one commit #80

Merged
merged 1 commit into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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