| 617 | } |
| 618 | |
| 619 | VcsJob* GitPlugin::remove(const QList<QUrl>& files) |
| 620 | { |
| 621 | if (files.isEmpty()) |
| 622 | return makeVcsErrorJob(i18n("No files to remove"), this); |
| 623 | QDir dotGitDir = dotGitDirectory(files.front()); |
| 624 | |
| 625 | |
| 626 | QList<QUrl> files_(files); |
| 627 | |
| 628 | QMutableListIterator<QUrl> i(files_); |
| 629 | while (i.hasNext()) { |
| 630 | QUrl file = i.next(); |
| 631 | QFileInfo fileInfo(file.toLocalFile()); |
| 632 | |
| 633 | const QStringList otherStr = getLsFiles(dotGitDir, QStringList{QStringLiteral("--others"), QStringLiteral("--"), file.toLocalFile()}, KDevelop::OutputJob::Silent); |
| 634 | if(!otherStr.isEmpty()) { |
| 635 | //remove files not under version control |
| 636 | QList<QUrl> otherFiles; |
| 637 | otherFiles.reserve(otherStr.size()); |
| 638 | for (const QString& f : otherStr) { |
| 639 | otherFiles << QUrl::fromLocalFile(dotGitDir.path() + QLatin1Char('/') + f); |
| 640 | } |
| 641 | if (fileInfo.isFile()) { |
| 642 | //if it's an unversioned file we are done, don't use git rm on it |
| 643 | i.remove(); |
| 644 | } |
| 645 | |
| 646 | auto deleteJob = KIO::del(otherFiles); |
| 647 | deleteJob->exec(); |
| 648 | qCDebug(PLUGIN_GIT) << "other files" << otherFiles; |
| 649 | } |
| 650 | |
| 651 | if (fileInfo.isDir()) { |
| 652 | if (isEmptyDirStructure(QDir(file.toLocalFile()))) { |
| 653 | //remove empty folders, git doesn't do that |
| 654 | auto deleteJob = KIO::del(file); |
| 655 | deleteJob->exec(); |
| 656 | qCDebug(PLUGIN_GIT) << "empty folder, removing" << file; |
| 657 | //we already deleted it, don't use git rm on it |
| 658 | i.remove(); |
| 659 | } |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | if (files_.isEmpty()) return nullptr; |
| 664 | |
| 665 | DVcsJob* job = new GitJob(dotGitDir, this); |
| 666 | job->setType(VcsJob::Remove); |
| 667 | // git refuses to delete files with local modifications |
| 668 | // use --force to overcome this |
| 669 | *job << "git" << "rm" << "-r" << "--force"; |
| 670 | *job << "--" << files_; |
| 671 | return job; |
| 672 | } |
| 673 | |
| 674 | VcsJob* GitPlugin::log(const QUrl& localLocation, |
| 675 | const KDevelop::VcsRevision& src, const KDevelop::VcsRevision& dst) |