Commit bcd8c02a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Prevent or close fixup editor if no local commits are found



Change-Id: I546241fb3531cbc542b97d6d0f53382c9225dcf4
Reviewed-by: default avatarPetar Perisin <petar.perisin@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 5a4cdc11
......@@ -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),
......
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