fix(index): preserve selection on bulk stage operations

This commit is contained in:
2026-06-18 23:05:00 -05:00
parent a8bec3ed22
commit cdea4503c7

View File

@@ -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;
}
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;
return runGit(repository, {"reset", "HEAD", "--", "."}, "All changes unstaged", error);
}
bool GitManager::stageFile(RepositoryView &repository, const std::string &path, std::string &error)