Commit ceedde87 authored by jkobus's avatar jkobus Committed by Jarek Kobus

Try to show some meaningful diff when in merging state.

Instead of showing 3-way diff, show simple diff
of conflicted file compared to the head of current branch.

Task-number: QTCREATORBUG-10099
Change-Id: I9419236f0249fd2752f89ea80a2a644fb80af095
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent 0b1a49a6
......@@ -136,6 +136,7 @@ private:
void addJob(VcsBase::Command *command,
const QString &gitCommand,
const QStringList &arguments);
QStringList addHeadWhenCommandInProgress() const;
int timeout() const;
QProcessEnvironment processEnvironment() const;
QString gitPath() const;
......@@ -159,7 +160,9 @@ GitDiffHandler::GitDiffHandler(DiffEditor::DiffEditorController *controller,
void GitDiffHandler::diffFile(const QString &fileName)
{
postCollectTextualDiffOutputUsingDiffCommand(QStringList() << QLatin1String("--") << fileName);
postCollectTextualDiffOutputUsingDiffCommand(addHeadWhenCommandInProgress()
<< QLatin1String("--")
<< fileName);
}
void GitDiffHandler::diffFiles(const QStringList &stagedFileNames,
......@@ -174,7 +177,7 @@ void GitDiffHandler::diffFiles(const QStringList &stagedFileNames,
arguments << stagedArguments;
if (!unstagedFileNames.isEmpty()) {
QStringList unstagedArguments;
QStringList unstagedArguments = addHeadWhenCommandInProgress();
unstagedArguments << QLatin1String("--");
unstagedArguments << unstagedFileNames;
arguments << unstagedArguments;
......@@ -185,17 +188,20 @@ void GitDiffHandler::diffFiles(const QStringList &stagedFileNames,
void GitDiffHandler::diffProjects(const QStringList &projectPaths)
{
postCollectTextualDiffOutputUsingDiffCommand(QStringList() << QLatin1String("--") << projectPaths);
postCollectTextualDiffOutputUsingDiffCommand(addHeadWhenCommandInProgress()
<< QLatin1String("--")
<< projectPaths);
}
void GitDiffHandler::diffRepository()
{
postCollectTextualDiffOutputUsingDiffCommand(QStringList());
postCollectTextualDiffOutputUsingDiffCommand(addHeadWhenCommandInProgress());
}
void GitDiffHandler::diffBranch(const QString &branchName)
{
postCollectTextualDiffOutputUsingDiffCommand(QStringList() << branchName);
postCollectTextualDiffOutputUsingDiffCommand(addHeadWhenCommandInProgress()
<< branchName);
}
void GitDiffHandler::show(const QString &id)
......@@ -265,6 +271,18 @@ void GitDiffHandler::addJob(VcsBase::Command *command,
command->addJob(args, timeout());
}
QStringList GitDiffHandler::addHeadWhenCommandInProgress() const
{
QStringList args;
// 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
// instead of showing unsupported combined diff format.
GitClient::CommandInProgress commandInProgress = m_gitClient->checkCommandInProgress(m_workingDirectory);
if (commandInProgress != GitClient::NoCommand)
args << QLatin1String(HEAD);
return args;
}
void GitDiffHandler::postCollectTextualDiffOutputUsingDiffCommand(const QStringList &arguments)
{
postCollectTextualDiffOutputUsingDiffCommand(QList<QStringList>() << arguments);
......
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