From cdea4503c7777f0eeeb04eb63d4329122aca4cc9 Mon Sep 17 00:00:00 2001 From: GigabiteStudios Date: Thu, 18 Jun 2026 23:05:00 -0500 Subject: [PATCH] fix(index): preserve selection on bulk stage operations --- src/managers/git_manager.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/managers/git_manager.cpp b/src/managers/git_manager.cpp index 166b59a..6647bff 100644 --- a/src/managers/git_manager.cpp +++ b/src/managers/git_manager.cpp @@ -912,17 +912,31 @@ bool GitManager::redoCommit(RepositoryView &repository, std::string &error) bool GitManager::stageAll(RepositoryView &repository, std::string &error) { - return runGit(repository, {"add", "--all"}, "All changes staged", error); + if (!runGit(repository, {"add", "--all"}, "All changes staged", error, false)) + return false; + loadWorkingTree(repository); + return true; } bool GitManager::unstageAll(RepositoryView &repository, std::string &error) { if (git_repository_head_unborn(repository.repo) == 1) - return runGit(repository, {"rm", "--cached", "-r", "--ignore-unmatch", "--", "."}, - "All changes unstaged", error); - if (runGit(repository, {"restore", "--staged", "--", "."}, "All changes unstaged", error)) + { + if (!runGit(repository, {"rm", "--cached", "-r", "--ignore-unmatch", "--", "."}, + "All changes unstaged", error, false)) + return false; + loadWorkingTree(repository); return true; - return runGit(repository, {"reset", "HEAD", "--", "."}, "All changes unstaged", error); + } + if (runGit(repository, {"restore", "--staged", "--", "."}, "All changes unstaged", error, false)) + { + loadWorkingTree(repository); + return true; + } + if (!runGit(repository, {"reset", "HEAD", "--", "."}, "All changes unstaged", error, false)) + return false; + loadWorkingTree(repository); + return true; } bool GitManager::stageFile(RepositoryView &repository, const std::string &path, std::string &error)