# HG changeset patch # User Chris Cannam # Date 1300277456 0 # Node ID 076c2b3de51be3f470b4bb8dfad55a2fbe4cd120 # Parent 987a094047c97f2ad2d004424a6df8fa00688133 Reject only non-empty directories as clone targets: we're happy if the directory exists but is empty diff -r 987a094047c9 -r 076c2b3de51b mainwindow.cpp --- a/mainwindow.cpp Wed Mar 16 10:46:10 2011 +0000 +++ b/mainwindow.cpp Wed Mar 16 12:10:56 2011 +0000 @@ -1243,14 +1243,25 @@ QString MainWindow::complainAboutCloneToExistingFolder(QString arg, QString remote) { - // If the directory "arg" exists but "arg" plus the last path - // component of "remote" does not, then offer the latter as an - // alternative path + // If the directory "arg" exists but is empty, then we accept it. + + // If the directory "arg" exists and is non-empty, but "arg" plus + // the last path component of "remote" does not exist, then offer + // the latter as an alternative path. QString offer; QDir d(arg); + if (d.exists()) { + + if (d.entryList(QDir::Dirs | QDir::Files | + QDir::NoDotAndDotDot | + QDir::Hidden | QDir::System).empty()) { + // directory is empty; accept it + return arg; + } + if (QRegExp("^\\w+://").indexIn(remote) >= 0) { QString rpath = QUrl(remote).path(); if (rpath != "") {