Git: Do not read working directory before it is set

This amends commit c17767c78e.

Change-Id: Ide6f9de2420dd1262b27aed83351b76404cdba30
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-06-07 09:22:00 +03:00
committed by Orgad Shaneh
parent e19f8899f5
commit bfcd1149eb
2 changed files with 16 additions and 9 deletions

View File

@@ -276,12 +276,14 @@ protected:
const QString &leftCommit, const QString &leftCommit,
const QString &rightCommit); const QString &rightCommit);
protected:
void runCommand(const QList<QStringList> &args, QTextCodec *codec = nullptr); void runCommand(const QList<QStringList> &args, QTextCodec *codec = nullptr);
QStringList addConfigurationArguments(const QStringList &args) const; QStringList addConfigurationArguments(const QStringList &args) const;
QStringList baseArguments() const; QStringList baseArguments() const;
public:
void initialize();
private: private:
void updateBranchList(); void updateBranchList();
@@ -318,7 +320,11 @@ GitBaseDiffEditorController::GitBaseDiffEditorController(IDocument *document,
connect(&m_decorator, &DescriptionWidgetDecorator::branchListRequested, connect(&m_decorator, &DescriptionWidgetDecorator::branchListRequested,
this, &GitBaseDiffEditorController::updateBranchList); this, &GitBaseDiffEditorController::updateBranchList);
setDisplayName("Git Diff"); setDisplayName("Git Diff");
if (rightCommit.isEmpty()) { }
void GitBaseDiffEditorController::initialize()
{
if (m_rightCommit.isEmpty()) {
// This is workaround for lack of support for merge commits and resolving conflicts, // This is workaround for lack of support for merge commits and resolving conflicts,
// we compare the current state of working tree to the HEAD of current branch // we compare the current state of working tree to the HEAD of current branch
// instead of showing unsupported combined diff format. // instead of showing unsupported combined diff format.
@@ -941,19 +947,20 @@ void GitClient::stage(DiffEditor::DiffEditorController *diffController,
void GitClient::requestReload(const QString &documentId, const QString &source, void GitClient::requestReload(const QString &documentId, const QString &source,
const QString &title, const QString &workingDirectory, const QString &title, const QString &workingDirectory,
std::function<VcsBaseDiffEditorController *(IDocument *)> factory) const std::function<GitBaseDiffEditorController *(IDocument *)> factory) const
{ {
// Creating document might change the referenced source. Store a copy and use it. // Creating document might change the referenced source. Store a copy and use it.
const QString sourceCopy = source; const QString sourceCopy = source;
IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title);
QTC_ASSERT(document, return); QTC_ASSERT(document, return);
VcsBaseDiffEditorController *controller = factory(document); GitBaseDiffEditorController *controller = factory(document);
QTC_ASSERT(controller, return); QTC_ASSERT(controller, return);
controller->setVcsBinary(settings().binaryPath()); controller->setVcsBinary(settings().binaryPath());
controller->setVcsTimeoutS(settings().vcsTimeoutS()); controller->setVcsTimeoutS(settings().vcsTimeoutS());
controller->setProcessEnvironment(processEnvironment()); controller->setProcessEnvironment(processEnvironment());
controller->setWorkingDirectory(workingDirectory); controller->setWorkingDirectory(workingDirectory);
controller->initialize();
connect(controller, &DiffEditorController::chunkActionsRequested, connect(controller, &DiffEditorController::chunkActionsRequested,
this, &GitClient::chunkActionsRequested, Qt::DirectConnection); this, &GitClient::chunkActionsRequested, Qt::DirectConnection);

View File

@@ -48,10 +48,9 @@ QT_END_NAMESPACE
namespace Core { class ICore; } namespace Core { class ICore; }
namespace VcsBase { namespace VcsBase {
class VcsCommand; class VcsCommand;
class SubmitFileModel; class SubmitFileModel;
class VcsBaseDiffEditorController; class VcsBaseEditorWidget;
class VcsBaseEditorWidget;
} }
namespace DiffEditor { namespace DiffEditor {
@@ -63,6 +62,7 @@ namespace Git {
namespace Internal { namespace Internal {
class CommitData; class CommitData;
class GitBaseDiffEditorController;
class GitSubmitEditorPanelData; class GitSubmitEditorPanelData;
class Stash; class Stash;
@@ -377,7 +377,7 @@ private:
QTextCodec *codecFor(CodecType codecType, const QString &source = QString()) const; QTextCodec *codecFor(CodecType codecType, const QString &source = QString()) const;
void requestReload(const QString &documentId, const QString &source, const QString &title, const QString &workingDirectory, void requestReload(const QString &documentId, const QString &source, const QString &title, const QString &workingDirectory,
std::function<VcsBase::VcsBaseDiffEditorController *(Core::IDocument *)> factory) const; std::function<GitBaseDiffEditorController *(Core::IDocument *)> factory) const;
// determine version as '(major << 16) + (minor << 8) + patch' or 0. // determine version as '(major << 16) + (minor << 8) + patch' or 0.
unsigned synchronousGitVersion(QString *errorMessage = nullptr) const; unsigned synchronousGitVersion(QString *errorMessage = nullptr) const;