/// <summary> /// Ensures that the Git folder is loaded. /// The <see cref="ProtoGitFolder"/> must have been created first. /// </summary> /// <param name="folderPath"> /// The folder path is a sub path of <see cref="Root"/> and contains the .git sub folder. /// </param> /// <returns>The <see cref="GitFolder"/> or null on error.</returns> public GitFolder EnsureGitFolder(IActivityMonitor m, ProtoGitFolder proto) { if (proto == null) { throw new ArgumentNullException(nameof(proto)); } if (proto.FileSystem != this) { throw new ArgumentException("FileSystem mismatch.", nameof(proto)); } GitFolder g = GitFolders.FirstOrDefault(f => f.ProtoGitFolder == proto); if (g == null) { g = proto.CreateGitFolder(m); // TODO: this SHOULD be done in ProtoGitFolder.EnsureWorkingFolder! if (g != null) { g.EnsureBranch(m, proto.World.DevelopBranchName); _gits.Add(g); } } return(g); }