Commit a0e68de2 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Refactor GitWidget to use common method for get dot git path

Signed-off-by: Waqar Ahmed's avatarWaqar Ahmed <>
parent c7bd9acb
......@@ -255,35 +255,16 @@ GitWidget::~GitWidget()
void GitWidget::setDotGitPath()
/* This call is intentionally blocking because we need git path for everything else */
QProcess git;
git.setArguments({QStringLiteral("rev-parse"), QStringLiteral("--absolute-git-dir")});
if (git.waitForStarted() && git.waitForFinished(-1)) {
if (git.exitStatus() != QProcess::NormalExit || git.exitCode() != 0) {
const QString error = QString::fromUtf8(git.readAllStandardError());
* Do this on next even loop iteration because we may be in the constructor of pluginView
QTimer::singleShot(1, this, [this, error] {
sendMessage(i18n("Failed to find .git directory, things may not work correctly: %1", error), false);
m_gitPath = m_project->baseDir();
m_gitPath = QString::fromUtf8(git.readAllStandardOutput());
if (m_gitPath.endsWith(QLatin1String("\n"))) {
} else {
// set once, use everywhere
// This is per project
const auto dotGitPath = GitUtils::getDotGitPath(m_project->baseDir());
if (dotGitPath.has_value()) {
QTimer::singleShot(1, this, [this] {
sendMessage(i18n("Failed to find .git directory, things may not work correctly"), false);
m_gitPath = m_project->baseDir();
m_gitPath = dotGitPath.value();
void GitWidget::sendMessage(const QString &plainText, bool warn)
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