From ee09a28e8354aecbeae23f73c2e11d1f321e1287 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Sat, 20 Jan 2024 16:20:34 +0100 Subject: [PATCH] GitClient: Make stashNameFromMessage() a static local function Get rid of unused errorMessage arg. Return the stash name directly. Change-Id: I11e7b0ef4dcaa38293cbf5d20b7213cc06850257 Reviewed-by: Orgad Shaneh --- src/plugins/git/gitclient.cpp | 28 +++++++++++----------------- src/plugins/git/gitclient.h | 3 --- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 505ffb24fe5..6bf6685ec1a 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -1831,29 +1831,23 @@ bool GitClient::executeSynchronousStash(const FilePath &workingDirectory, } // Resolve a stash name from message -bool GitClient::stashNameFromMessage(const FilePath &workingDirectory, - const QString &message, QString *name, - QString *errorMessage) const +static QString stashNameFromMessage(const FilePath &workingDirectory, const QString &message) { // All happy - if (message.startsWith(stashNamePrefix)) { - *name = message; - return true; - } + if (message.startsWith(stashNamePrefix)) + return message; // Retrieve list and find via message QList stashes; - if (!synchronousStashList(workingDirectory, &stashes, errorMessage)) - return false; + if (!gitClient().synchronousStashList(workingDirectory, &stashes)) + return {}; for (const Stash &s : std::as_const(stashes)) { - if (s.message == message) { - *name = s.name; - return true; - } + if (s.message == message) + return s.name; } //: Look-up of a stash via its descriptive message failed. msgCannotRun(Tr::tr("Cannot resolve stash message \"%1\" in \"%2\".") - .arg(message, workingDirectory.toUserOutput()), errorMessage); - return false; + .arg(message, workingDirectory.toUserOutput()), nullptr); + return {}; } bool GitClient::synchronousBranchCmd(const FilePath &workingDirectory, QStringList branchArgs, @@ -3601,8 +3595,8 @@ bool GitClient::StashInfo::stashingFailed() const void GitClient::StashInfo::end() { if (m_stashResult == Stashed) { - QString stashName; - if (gitClient().stashNameFromMessage(m_workingDir, m_message, &stashName)) + const QString stashName = stashNameFromMessage(m_workingDir, m_message); + if (!stashName.isEmpty()) gitClient().stashPop(m_workingDir, stashName); } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 0e9ab3e8e68..3e098cd7168 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -279,9 +279,6 @@ public: void revertFiles(const QStringList &files, bool revertStaging); bool synchronousStashList(const Utils::FilePath &workingDirectory, QList *stashes, QString *errorMessage = nullptr) const; - // Resolve a stash name from message (for IVersionControl's names). - bool stashNameFromMessage(const Utils::FilePath &workingDirectory, const QString &messge, QString *name, - QString *errorMessage = nullptr) const; QString readGitVar(const Utils::FilePath &workingDirectory, const QString &configVar) const; QString readConfigValue(const Utils::FilePath &workingDirectory, const QString &configVar) const;