forked from qt-creator/qt-creator
Git: Always warn on hard reset when there are modified files
A warning is currently only displayed for reset via context-menu. Change-Id: If01c6c58dfe8ad0d066f4c6fe02ea3d7bb2c8a55 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
e0671c0d78
commit
a4890d838d
@@ -1043,8 +1043,18 @@ void GitClient::reset(const QString &workingDirectory, const QString &argument,
|
|||||||
arguments << commit;
|
arguments << commit;
|
||||||
|
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
if (argument == QLatin1String("--hard"))
|
if (argument == QLatin1String("--hard")) {
|
||||||
|
if (gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules)) != StatusUnchanged) {
|
||||||
|
if (QMessageBox::question(
|
||||||
|
Core::ICore::mainWindow(), tr("Reset"),
|
||||||
|
tr("All changes in working directory will be discarded. Are you sure?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No,
|
||||||
|
QMessageBox::No) == QMessageBox::No) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
flags |= VcsCommand::ExpectRepoChanges;
|
flags |= VcsCommand::ExpectRepoChanges;
|
||||||
|
}
|
||||||
vcsExec(workingDirectory, arguments, 0, true, flags);
|
vcsExec(workingDirectory, arguments, 0, true, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,21 +205,8 @@ void GitEditorWidget::checkoutChange()
|
|||||||
|
|
||||||
void GitEditorWidget::resetChange(const QByteArray &resetType)
|
void GitEditorWidget::resetChange(const QByteArray &resetType)
|
||||||
{
|
{
|
||||||
const QString workingDir = sourceWorkingDirectory();
|
GitPlugin::instance()->client()->reset(
|
||||||
|
sourceWorkingDirectory(), QLatin1String("--" + resetType), m_currentChange);
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
if (resetType == "hard"
|
|
||||||
&& client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
|
|
||||||
!= GitClient::StatusUnchanged) {
|
|
||||||
if (QMessageBox::question(
|
|
||||||
Core::ICore::mainWindow(), tr("Reset"),
|
|
||||||
tr("All changes in working directory will be discarded. Are you sure?"),
|
|
||||||
QMessageBox::Yes | QMessageBox::No,
|
|
||||||
QMessageBox::No) == QMessageBox::No) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client->reset(workingDir, QLatin1String("--" + resetType), m_currentChange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::cherryPickChange()
|
void GitEditorWidget::cherryPickChange()
|
||||||
|
|||||||
Reference in New Issue
Block a user