Commit de780067 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Fix git checkout, fix stash error reporting

parent 3080d4a3
......@@ -172,6 +172,13 @@ BranchesDialog::BranchesDialog(QWidget *window, KateProjectPluginView *pluginVie
connect(&m_checkoutWatcher, &QFutureWatcher<GitUtils::CheckoutResult>::finished, this, &BranchesDialog::onCheckoutDone);
}
BranchesDialog::~BranchesDialog()
{
if (m_checkoutWatcher.isRunning()) {
onCheckoutDone();
}
}
void BranchesDialog::resetValues()
{
m_checkoutBranchName.clear();
......@@ -203,9 +210,7 @@ void BranchesDialog::onCheckoutDone()
QString msgStr = i18n("Branch %1 checked out", res.branch);
if (res.returnCode > 0) {
msgType = KTextEditor::Message::Warning;
msgStr = i18n("Failed to checkout branch: %1", res.branch);
} else {
msgStr = i18n("Checked out to branch: %1", res.branch);
msgStr = i18n("Failed to checkout to branch %1, Error: %2", res.branch, res.error);
}
sendMessage(msgStr, msgType == KTextEditor::Message::Warning);
......
......@@ -27,9 +27,8 @@ class BranchesDialog : public QuickDialog
Q_OBJECT
public:
BranchesDialog(QWidget *window, KateProjectPluginView *pluginView, QString projectPath);
~BranchesDialog();
void openDialog();
// removed, otherwise we can trigger multiple project reloads on branch change
// Q_SIGNAL void branchChanged(const QString &branch);
private Q_SLOTS:
void slotReturnPressed() override;
......
......@@ -698,7 +698,7 @@ void GitWidget::treeViewContextMenuEvent(QContextMenuEvent *e)
auto launchDifftoolAct = untracked ? nullptr : menu.addAction(i18n("Show in external git diff tool"));
auto openAtHead = untracked ? nullptr : menu.addAction(i18n("Open at HEAD"));
auto stageAct = staged ? menu.addAction(i18n("Unstage file")) : menu.addAction(i18n("Stage file"));
auto discardAct = untracked ? menu.addAction(i18n("Remove")) : menu.addAction(i18n("Discard"));
auto discardAct = staged ? nullptr : untracked ? menu.addAction(i18n("Remove")) : menu.addAction(i18n("Discard"));
auto act = menu.exec(m_treeView->viewport()->mapToGlobal(e->pos()));
const QString file = m_gitPath + idx.data(GitStatusModel::FileNameRole).toString();
......
......@@ -251,10 +251,10 @@ void StashDialog::stash(bool keepIndex, bool includeUntracked)
disconnect(git, &QProcess::finished, nullptr, nullptr);
connect(git, &QProcess::finished, m_gitwidget, [gitWidget](int exitCode, QProcess::ExitStatus es) {
disconnect(gitWidget->gitprocess(), &QProcess::finished, nullptr, nullptr);
gitWidget->getStatus();
if (es != QProcess::NormalExit || exitCode != 0) {
gitWidget->sendMessage(i18n("Failed to stash changes"), true);
} else {
gitWidget->getStatus();
gitWidget->sendMessage(i18n("Changes stashed successfully."), false);
}
});
......@@ -277,7 +277,7 @@ void StashDialog::getStashList()
if (git->exitStatus() == QProcess::NormalExit && git->exitCode() == 0) {
stashList = git->readAllStandardOutput().split('\n');
} else {
m_gitwidget->sendMessage(i18n("Failed to get stash list. Error:\n %1", QString::fromUtf8(git->readAllStandardError())), true);
m_gitwidget->sendMessage(i18n("Failed to get stash list. Error: ") + QString::fromUtf8(git->readAll()), true);
}
}
......@@ -316,17 +316,17 @@ void StashDialog::popStash(const QByteArray &index, const QString &command)
connect(git, &QProcess::finished, gitWidget, [gitWidget, command](int exitCode, QProcess::ExitStatus es) {
disconnect(gitWidget->gitprocess(), &QProcess::finished, nullptr, nullptr);
gitWidget->getStatus();
if (es != QProcess::NormalExit || exitCode != 0) {
auto git = gitWidget->gitprocess();
if (command == QLatin1String("apply")) {
gitWidget->sendMessage(i18n("Failed to apply stash. Error:\n%1", QString::fromUtf8(git->readAllStandardError())), true);
gitWidget->sendMessage(i18n("Failed to apply stash. Error: ") + QString::fromUtf8(git->readAll()), true);
} else if (command == QLatin1String("drop")) {
gitWidget->sendMessage(i18n("Failed to drop stash. Error:\n%1", QString::fromUtf8(git->readAllStandardError())), true);
gitWidget->sendMessage(i18n("Failed to drop stash. Error: ") + QString::fromUtf8(git->readAll()), true);
} else {
gitWidget->sendMessage(i18n("Failed to pop stash. Error:\n%1", QString::fromUtf8(git->readAllStandardError())), true);
gitWidget->sendMessage(i18n("Failed to pop stash. Error: ") + QString::fromUtf8(git->readAll()), true);
}
} else {
gitWidget->getStatus();
if (command == QLatin1String("apply")) {
gitWidget->sendMessage(i18n("Stash applied successfully."), false);
} else if (command == QLatin1String("drop")) {
......@@ -368,7 +368,8 @@ void StashDialog::showStash(const QByteArray &index)
connect(git, &QProcess::finished, gitWidget, [gitWidget](int exitCode, QProcess::ExitStatus es) {
disconnect(gitWidget->gitprocess(), &QProcess::finished, nullptr, nullptr);
if (es != QProcess::NormalExit || exitCode != 0) {
gitWidget->sendMessage(i18n("Show stash failed. Error:\n%1", QString::fromUtf8(gitWidget->gitprocess()->readAllStandardError())), true);
gitWidget->sendMessage(i18n("Show stash failed. Error: ") + QString::fromUtf8(gitWidget->gitprocess()->readAll()), true);
gitWidget->getStatus();
} else {
gitWidget->openTempFile(QString(), QStringLiteral("XXXXXX.diff"), gitWidget->gitprocess()->readAllStandardOutput());
}
......
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