diff --git a/LibGit2Sharp/TreeDefinition.cs b/LibGit2Sharp/TreeDefinition.cs index 62efd4fb9..a88a24b53 100644 --- a/LibGit2Sharp/TreeDefinition.cs +++ b/LibGit2Sharp/TreeDefinition.cs @@ -310,7 +310,12 @@ internal Tree Build(Repository repository) builtTreeEntryDefinitions.ForEach(t => entries[t.Item1] = t.Item2); ObjectId treeId = builder.Write(); - return repository.Lookup(treeId); + var result = repository.Lookup(treeId); + if (result == null) + { + throw new LibGit2SharpException("Unable to read created tree"); + } + return result; } }