GitClient: Change synchronousStashList() signature

Get rid of unused errorMessage arg.
Return the stash list directly.

Change-Id: I9bf156c5ecda476a5def3c3490d6cb13d011a3cd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2024-01-20 16:59:51 +01:00
parent ee09a28e83
commit cbec5438b4
4 changed files with 16 additions and 24 deletions

View File

@@ -399,9 +399,8 @@ bool BranchView::checkout()
if (gitClient().gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged)
branchCheckoutDialog.foundNoLocalChanges();
QList<Stash> stashes;
gitClient().synchronousStashList(m_repository, &stashes);
for (const Stash &stash : std::as_const(stashes)) {
const QList<Stash> stashes = gitClient().synchronousStashList(m_repository);
for (const Stash &stash : stashes) {
if (stash.message.startsWith(popMessageStart)) {
branchCheckoutDialog.foundStashForNextBranch();
break;
@@ -433,10 +432,9 @@ bool BranchView::checkout()
if (moveChanges) {
gitClient().endStashScope(m_repository);
} else if (popStash) {
QList<Stash> stashes;
QString stashName;
gitClient().synchronousStashList(m_repository, &stashes);
for (const Stash &stash : std::as_const(stashes)) {
const QList<Stash> stashes = gitClient().synchronousStashList(m_repository);
for (const Stash &stash : stashes) {
if (stash.message.startsWith(popMessageStart)) {
stashName = stash.name;
break;

View File

@@ -1837,12 +1837,10 @@ static QString stashNameFromMessage(const FilePath &workingDirectory, const QStr
if (message.startsWith(stashNamePrefix))
return message;
// Retrieve list and find via message
QList<Stash> stashes;
if (!gitClient().synchronousStashList(workingDirectory, &stashes))
return {};
for (const Stash &s : std::as_const(stashes)) {
if (s.message == message)
return s.name;
const QList<Stash> stashes = gitClient().synchronousStashList(workingDirectory);
for (const Stash &stash : stashes) {
if (stash.message == message)
return stash.name;
}
//: Look-up of a stash via its descriptive message failed.
msgCannotRun(Tr::tr("Cannot resolve stash message \"%1\" in \"%2\".")
@@ -3376,25 +3374,23 @@ static std::optional<Stash> parseStashLine(const QString &l)
l.mid(messagePos + 2)}; // skip blank
}
bool GitClient::synchronousStashList(const FilePath &workingDirectory, QList<Stash> *stashes,
QString *errorMessage) const
QList<Stash> GitClient::synchronousStashList(const FilePath &workingDirectory) const
{
stashes->clear();
const QStringList arguments = {"stash", "list", noColorOption};
const CommandResult result = vcsSynchronousExec(workingDirectory, arguments,
RunFlags::ForceCLocale);
if (result.result() != ProcessResult::FinishedWithSuccess) {
msgCannotRun(arguments, workingDirectory, result.cleanedStdErr(), errorMessage);
return false;
msgCannotRun(arguments, workingDirectory, result.cleanedStdErr(), nullptr);
return {};
}
const QStringList lines = splitLines(result.cleanedStdOut());
QList<Stash> stashes;
for (const QString &line : lines) {
const auto stash = parseStashLine(line);
if (stash)
stashes->push_back(*stash);
stashes.push_back(*stash);
}
return true;
return stashes;
}
// Read a single-line config value, return trimmed

View File

@@ -277,8 +277,7 @@ public:
void stashPop(const Utils::FilePath &workingDirectory, const QString &stash = {});
void revertFiles(const QStringList &files, bool revertStaging);
bool synchronousStashList(const Utils::FilePath &workingDirectory, QList<Stash> *stashes,
QString *errorMessage = nullptr) const;
QList<Stash> synchronousStashList(const Utils::FilePath &workingDirectory) const;
QString readGitVar(const Utils::FilePath &workingDirectory, const QString &configVar) const;
QString readConfigValue(const Utils::FilePath &workingDirectory, const QString &configVar) const;

View File

@@ -169,8 +169,7 @@ void StashDialog::refresh(const FilePath &repository, bool force)
if (m_repository.isEmpty()) {
m_model->setStashes({});
} else {
QList<Stash> stashes;
gitClient().synchronousStashList(m_repository, &stashes);
const QList<Stash> stashes = gitClient().synchronousStashList(m_repository);
m_model->setStashes(stashes);
if (!stashes.isEmpty()) {
for (int c = 0; c < ColumnCount; c++)