forked from qt-creator/qt-creator
Git: Prevent or close fixup editor if no local commits are found
Change-Id: I546241fb3531cbc542b97d6d0f53382c9225dcf4 Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
5a4cdc11cb
commit
bcd8c02aea
@@ -2521,6 +2521,16 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
|
||||
// Run status. Note that it has exitcode 1 if there are no added files.
|
||||
QString output;
|
||||
if (commitData.commitType == FixupCommit) {
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("HEAD") << QLatin1String("--not")
|
||||
<< QLatin1String("--remotes") << QLatin1String("-n1");
|
||||
synchronousLog(repoDirectory, arguments, &output, errorMessage);
|
||||
if (output.isEmpty()) {
|
||||
*errorMessage = msgNoCommits(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const StatusResult status = gitStatus(repoDirectory, ShowAll, &output, errorMessage);
|
||||
switch (status) {
|
||||
case StatusChanged:
|
||||
@@ -3066,6 +3076,11 @@ QString GitClient::msgNoChangedFiles()
|
||||
return tr("There are no modified files.");
|
||||
}
|
||||
|
||||
QString GitClient::msgNoCommits(bool includeRemote)
|
||||
{
|
||||
return includeRemote ? tr("No commits were found") : tr("No local commits were found");
|
||||
}
|
||||
|
||||
void GitClient::stashPop(const QString &workingDirectory, const QString &stash)
|
||||
{
|
||||
QStringList arguments(QLatin1String("stash"));
|
||||
|
||||
@@ -316,6 +316,7 @@ public:
|
||||
void handleMergeConflicts(const QString &workingDir, const QString &commit, const QString &abortCommand);
|
||||
|
||||
static QString msgNoChangedFiles();
|
||||
static QString msgNoCommits(bool includeRemote);
|
||||
|
||||
static const char *noColorOption;
|
||||
static const char *decorateOption;
|
||||
|
||||
@@ -73,8 +73,7 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, boo
|
||||
return false;
|
||||
if (!m_model->rowCount()) {
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendError(
|
||||
includeRemote ? tr("No commits were found")
|
||||
: tr("No local commits were found"));
|
||||
GitPlugin::instance()->gitClient()->msgNoCommits(includeRemote));
|
||||
return false;
|
||||
}
|
||||
selectionModel()->select(m_model->index(0, 0),
|
||||
|
||||
Reference in New Issue
Block a user