public ActionResult Index(string cat, string subcat, string project, string tree, string path) { try { model.WebBrowsingSettings = this.GetWebBrowsingSettings(); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = model.WebBrowsingSettings.CultureObject; model.Title = project; model.PathSegments = path.SplitSlashes_OrEmpty().ToArray(); model.Project = repositories.CombineRepositoryName(cat, subcat, project); model.Repository = repositories.GetBackendRepository(cat, subcat, project); if (model.Repository.Branches.Count == 0) { return(View("EmptyRepository", model)); } if (string.IsNullOrWhiteSpace(tree)) { tree = model.Repository.CurrentBranch.Name; } Branch loBranch; Commit loCommit; if (!model.Repository.Branches.TryGetValue(tree, out loBranch)) { Tag loTag; if (!model.Repository.Tags.TryGetValue(tree, out loTag)) { loCommit = model.Repository.Get <Commit>(tree); if (loCommit == null) { throw new Exception(string.Format("tree {0} not found", tree)); } } else { loCommit = loTag.Target as Commit; } } else { loCommit = loBranch.CurrentCommit; } model.Branches = model.Repository.Branches .Where(a => a.Value.CurrentCommit.Hash == loCommit.Hash || a.Value.CurrentCommit.Ancestors.Any(b => b.Hash == loCommit.Hash)) .Select(a => a.Value); model.Tags = model.Repository.Tags.Where(a => a.Value.Target.Hash == loCommit.Hash).Select(a => a.Value); model.Commit = loCommit; model.RootTree = loCommit.Tree; model.TreeName = tree; model.Title = model.PathSegments.Length == 0 ? string.Format("{0} at {1}", project, tree) : string.Format("{2} at {1} from {0}", project, tree, string.Join("/", model.PathSegments)); Browse(); return(View(model)); } finally { GC.Collect(); } }