Commit 8ef7ad0b authored by dt's avatar dt

Fix not beeing able to commit file deletions with creators git plugin

Reviewed-By: mauricek
parent 97aa7898
......@@ -783,7 +783,8 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
const GitSubmitEditorPanelData &data,
const QString &messageFile,
const QStringList &checkedFiles,
const QStringList &origCommitFiles)
const QStringList &origCommitFiles,
const QStringList &origDeletedFiles)
{
if (Git::Constants::debug)
qDebug() << "GitClient::addAndCommit:" << repositoryDirectory << checkedFiles << origCommitFiles;
......@@ -795,9 +796,12 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
if (!synchronousReset(repositoryDirectory, resetFiles.toList()))
return false;
// Re-add all to make sure we have the latest changes
if (!synchronousAdd(repositoryDirectory, checkedFiles))
return false;
// Re-add all to make sure we have the latest changes, but only add those that aren't marked
// for deletion
QStringList addFiles = checkedFiles.toSet().subtract(origDeletedFiles.toSet()).toList();
if (!addFiles.isEmpty())
if (!synchronousAdd(repositoryDirectory, addFiles))
return false;
// Do the final commit
QStringList args;
......
......@@ -123,7 +123,8 @@ public:
const GitSubmitEditorPanelData &data,
const QString &messageFile,
const QStringList &checkedFiles,
const QStringList &origCommitFiles);
const QStringList &origCommitFiles,
const QStringList &origDeletedFiles);
enum StatusResult { StatusChanged, StatusUnchanged, StatusFailed };
StatusResult gitStatus(const QString &workingDirectory,
......
......@@ -614,6 +614,7 @@ void GitPlugin::startCommit()
// files to be able to unstage files the user unchecks
m_submitRepository = data.panelInfo.repository;
m_submitOrigCommitFiles = data.stagedFileNames();
m_submitOrigDeleteFiles = data.stagedFileNames("deleted");
if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << data << commitTemplate;
......@@ -709,7 +710,8 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
editor->panelData(),
m_changeTmpFile->fileName(),
fileList,
m_submitOrigCommitFiles);
m_submitOrigCommitFiles,
m_submitOrigDeleteFiles);
}
if (closeEditor)
cleanChangeTmpFile();
......
......@@ -173,6 +173,7 @@ private:
Core::IVersionControl *m_versionControl;
QString m_submitRepository;
QStringList m_submitOrigCommitFiles;
QStringList m_submitOrigDeleteFiles;
QTemporaryFile *m_changeTmpFile;
bool m_submitActionTriggered;
};
......
......@@ -63,11 +63,10 @@ GitSubmitEditorWidget *GitSubmitEditor::submitEditorWidget()
// Utility to add a list of state/file pairs to the model
// setting a file type.
static void addStateFileListToModel(const QList<CommitData::StateFilePair> &l,
static void addStateFileListToModel(const QList<CommitData::StateFilePair> &l,
bool checked, FileType ft,
VCSBase::SubmitFileModel *model)
{
typedef QList<CommitData::StateFilePair>::const_iterator ConstIterator;
if (!l.empty()) {
const ConstIterator cend = l.constEnd();
......
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