forked from qt-creator/qt-creator
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 <orgads@gmail.com>
This commit is contained in:
@@ -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<Stash> 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);
|
||||
}
|
||||
|
||||
|
@@ -279,9 +279,6 @@ public:
|
||||
void revertFiles(const QStringList &files, bool revertStaging);
|
||||
bool synchronousStashList(const Utils::FilePath &workingDirectory, QList<Stash> *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;
|
||||
|
Reference in New Issue
Block a user