From 1cf1159f41f12860ced8f0bbce0da38f9960c3cf Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 11 Oct 2013 16:10:08 +0300 Subject: [PATCH] VCS: Prevent soft assertion for non-existent directories Blame in a renamed directory then blaming some revision with the previous name triggers an assertion Change-Id: If89a268a776df1c6e0061fd5828492b0200237b4 Reviewed-by: Tobias Hunger --- src/plugins/coreplugin/vcsmanager.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp index 1345aca4eaa..d58a678d468 100644 --- a/src/plugins/coreplugin/vcsmanager.cpp +++ b/src/plugins/coreplugin/vcsmanager.cpp @@ -271,14 +271,18 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input // Register Vcs(s) with the cache QString tmpDir = QFileInfo(directory).canonicalFilePath(); - const QChar slash = QLatin1Char('/'); - const StringVersionControlPairs::const_iterator cend = allThatCanManage.constEnd(); - for (StringVersionControlPairs::const_iterator i = allThatCanManage.constBegin(); i != cend; ++i) { - d->cache(i->second, i->first, tmpDir); - tmpDir = i->first; - const int slashPos = tmpDir.lastIndexOf(slash); - if (slashPos >= 0) - tmpDir.truncate(slashPos); + // directory might refer to a historical directory which doesn't exist. + // In this case, don't cache it. + if (!tmpDir.isEmpty()) { + const QChar slash = QLatin1Char('/'); + const StringVersionControlPairs::const_iterator cend = allThatCanManage.constEnd(); + for (StringVersionControlPairs::const_iterator i = allThatCanManage.constBegin(); i != cend; ++i) { + d->cache(i->second, i->first, tmpDir); + tmpDir = i->first; + const int slashPos = tmpDir.lastIndexOf(slash); + if (slashPos >= 0) + tmpDir.truncate(slashPos); + } } // return result