Commit 4e60001f authored by Hugues Delorme's avatar Hugues Delorme Committed by Tobias Hunger

Vcs: fix potential issue in VcsBaseEditor::getTitleId()

In case the input list of filenames contains only empty item(s) then getTitleId()
fails to return a valid result.
It should return the workingDir or the revision.

Change-Id: I697826446037e4b1e9f94c4c0c558336f8d44237
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent bd87b090
......@@ -1318,16 +1318,22 @@ QString VcsBaseEditor::getTitleId(const QString &workingDirectory,
const QStringList &fileNames,
const QString &revision)
{
QStringList nonEmptyFileNames;
foreach (const QString& fileName, fileNames) {
if (!fileName.trimmed().isEmpty())
nonEmptyFileNames.append(fileName);
}
QString rc;
switch (fileNames.size()) {
switch (nonEmptyFileNames.size()) {
case 0:
rc = workingDirectory;
break;
case 1:
rc = fileNames.front();
rc = nonEmptyFileNames.front();
break;
default:
rc = fileNames.join(QLatin1String(", "));
rc = nonEmptyFileNames.join(QLatin1String(", "));
break;
}
if (!revision.isEmpty()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment