perf(startup): defer repository loading
This commit is contained in:
@@ -10,6 +10,7 @@ public:
|
||||
GitManager();
|
||||
~GitManager();
|
||||
|
||||
bool openRepositoryHandle(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool openRepositoryHandle(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool openRepository(RepositoryView &repository, const std::string &path, std::string &error);
|
||||
bool initializeRepository(RepositoryView &repository, const std::string &path,
|
||||
|
||||
@@ -376,12 +376,13 @@ GitAsyncResult execute_git_async_request(const GitAsyncRequest& request) {
|
||||
|
||||
GitManager manager;
|
||||
RepositoryView repository;
|
||||
if (!manager.openRepository(repository, request.repo_path, result.notice)) return result;
|
||||
if (!manager.openRepositoryHandle(repository, request.repo_path, result.notice)) return result;
|
||||
|
||||
bool action_ok = true;
|
||||
switch (request.operation) {
|
||||
case GitAsyncOperation::reload:
|
||||
break;
|
||||
action_ok = manager.reload(repository, result.notice);
|
||||
case GitAsyncOperation::capture: {
|
||||
std::string output;
|
||||
action_ok = manager.captureGit(repository, request.arguments, output, result.notice) &&
|
||||
@@ -4042,8 +4043,8 @@ int runGitree(int argc, char** argv) {
|
||||
} else if (!user_data.openRepositories().empty()) {
|
||||
for (const std::string& path : user_data.openRepositories()) {
|
||||
g_tabs.push_back(std::make_unique<RepositoryView>());
|
||||
if (!path.empty() && git_manager.openRepository(*g_tabs.back(), path, g_notice))
|
||||
mark_repository_refreshed(*g_tabs.back());
|
||||
if (!path.empty() && git_manager.openRepositoryHandle(*g_tabs.back(), path, g_notice))
|
||||
g_tabs.back()->pending_background_refresh = true;
|
||||
}
|
||||
g_active_tab = std::min(user_data.activeRepository(), g_tabs.size() - 1);
|
||||
g_tab_to_select = g_tabs[g_active_tab].get();
|
||||
|
||||
Reference in New Issue
Block a user