forked from qt-creator/qt-creator
Git: Allow for pretty format selection in git show
Allow for pretty format selection in git show. Save selected value and default to "email". Task-number: QTCREATORBUG-3341
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QSignalMapper>
|
#include <QtCore/QSignalMapper>
|
||||||
|
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QMainWindow> // for msg box parent
|
#include <QtGui/QMainWindow> // for msg box parent
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
@@ -121,19 +122,42 @@ public:
|
|||||||
m_ignoreSpaces->setCheckable(true);
|
m_ignoreSpaces->setCheckable(true);
|
||||||
m_ignoreSpaces->setChecked(m_settings->ignoreSpaceChangesInDiff);
|
m_ignoreSpaces->setChecked(m_settings->ignoreSpaceChangesInDiff);
|
||||||
connect(m_ignoreSpaces, SIGNAL(toggled(bool)), this, SLOT(testForArgumentsChanged()));
|
connect(m_ignoreSpaces, SIGNAL(toggled(bool)), this, SLOT(testForArgumentsChanged()));
|
||||||
|
|
||||||
|
m_prettyFormat = new QComboBox;
|
||||||
|
m_prettyFormat->setToolTip(tr("Select the pretty printing format"));
|
||||||
|
m_prettyFormat->addItem(tr("oneline"), QLatin1String("oneline"));
|
||||||
|
m_prettyFormat->addItem(tr("short"), QLatin1String("short"));
|
||||||
|
m_prettyFormat->addItem(tr("medium"), QLatin1String("medium"));
|
||||||
|
m_prettyFormat->addItem(tr("full"), QLatin1String("full"));
|
||||||
|
m_prettyFormat->addItem(tr("fuller"), QLatin1String("fuller"));
|
||||||
|
m_prettyFormat->addItem(tr("email"), QLatin1String("email"));
|
||||||
|
m_prettyFormat->addItem(tr("raw"), QLatin1String("raw"));
|
||||||
|
layout->addWidget(m_prettyFormat);
|
||||||
|
m_prettyFormat->setCurrentIndex(m_settings->showPrettyFormat);
|
||||||
|
m_prettyFormat->setVisible(false);
|
||||||
|
connect(m_prettyFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(testForArgumentsChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList arguments() const
|
QStringList arguments() const
|
||||||
{
|
{
|
||||||
QStringList args = m_diffArgs;
|
QStringList args;
|
||||||
|
foreach (const QString &arg, m_diffArgs) {
|
||||||
|
if (arg == QLatin1String("--patience")
|
||||||
|
|| arg == QLatin1String("--ignore-space-change")
|
||||||
|
|| arg.startsWith(QLatin1String("--pretty="))
|
||||||
|
|| arg.startsWith(QLatin1String("--format=")))
|
||||||
|
continue;
|
||||||
|
args.append(arg);
|
||||||
|
}
|
||||||
|
|
||||||
args.removeAll(QLatin1String("--patience"));
|
if (m_patience->isChecked() && m_patience->isVisible())
|
||||||
args.removeAll(QLatin1String("--ignore-space-change"));
|
|
||||||
|
|
||||||
if (m_patience->isChecked())
|
|
||||||
args.prepend(QLatin1String("--patience"));
|
args.prepend(QLatin1String("--patience"));
|
||||||
if (m_ignoreSpaces->isChecked())
|
if (m_ignoreSpaces->isChecked() && m_ignoreSpaces->isVisible())
|
||||||
args.prepend(QLatin1String("--ignore-space-change"));
|
args.prepend(QLatin1String("--ignore-space-change"));
|
||||||
|
if (m_prettyFormat->isVisible()) {
|
||||||
|
args.prepend(QString::fromLatin1("--pretty=")
|
||||||
|
+ m_prettyFormat->itemData(m_prettyFormat->currentIndex()).toString());
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@@ -141,6 +165,7 @@ public:
|
|||||||
void testForArgumentsChanged() {
|
void testForArgumentsChanged() {
|
||||||
m_settings->diffPatience = m_patience->isChecked();
|
m_settings->diffPatience = m_patience->isChecked();
|
||||||
m_settings->ignoreSpaceChangesInDiff = m_ignoreSpaces->isChecked();
|
m_settings->ignoreSpaceChangesInDiff = m_ignoreSpaces->isChecked();
|
||||||
|
m_settings->showPrettyFormat = m_prettyFormat->currentIndex();
|
||||||
|
|
||||||
QStringList newArguments = arguments();
|
QStringList newArguments = arguments();
|
||||||
|
|
||||||
@@ -151,9 +176,10 @@ public:
|
|||||||
redoCommand();
|
redoCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QToolButton *m_patience;
|
QToolButton *m_patience;
|
||||||
QToolButton *m_ignoreSpaces;
|
QToolButton *m_ignoreSpaces;
|
||||||
|
QComboBox *m_prettyFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GitCommitDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
|
class GitCommitDiffArgumentsWidget : public BaseGitDiffArgumentsWidget
|
||||||
@@ -216,6 +242,30 @@ private:
|
|||||||
const QString m_branchName;
|
const QString m_branchName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GitShowArgumentsWidget : public BaseGitDiffArgumentsWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GitShowArgumentsWidget(Git::Internal::GitSettings *settings,
|
||||||
|
Git::Internal::GitClient *client, const QString &directory,
|
||||||
|
const QStringList &args, const QString &id) :
|
||||||
|
BaseGitDiffArgumentsWidget(settings, client, directory, args),
|
||||||
|
m_id(id)
|
||||||
|
{
|
||||||
|
m_patience->setVisible(false);
|
||||||
|
m_ignoreSpaces->setVisible(false);
|
||||||
|
m_prettyFormat->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void redoCommand()
|
||||||
|
{
|
||||||
|
m_client->show(m_workingDirectory, m_id, m_diffArgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QString m_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class GitBlameArgumentsWidget : public Git::Internal::BaseGitArgumentsWidget
|
class GitBlameArgumentsWidget : public Git::Internal::BaseGitArgumentsWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -631,7 +681,7 @@ static inline QString msgCannotShow(const QString &sha)
|
|||||||
return GitClient::tr("Cannot describe '%1'.").arg(sha);
|
return GitClient::tr("Cannot describe '%1'.").arg(sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::show(const QString &source, const QString &id)
|
void GitClient::show(const QString &source, const QString &id, const QStringList &args)
|
||||||
{
|
{
|
||||||
if (Git::Constants::debug)
|
if (Git::Constants::debug)
|
||||||
qDebug() << "show" << source << id;
|
qDebug() << "show" << source << id;
|
||||||
@@ -640,14 +690,22 @@ void GitClient::show(const QString &source, const QString &id)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList userArgs = args;
|
||||||
arguments << QLatin1String("show") << QLatin1String(noColorOption) << id;
|
|
||||||
|
|
||||||
const QString title = tr("Git Show %1").arg(id);
|
const QString title = tr("Git Show %1").arg(id);
|
||||||
const QString editorId = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_ID);
|
const QString editorId = QLatin1String(Git::Constants::GIT_DIFF_EDITOR_ID);
|
||||||
VCSBase::VCSBaseEditor *editor = findExistingVCSEditor("show", id);
|
VCSBase::VCSBaseEditor *editor = findExistingVCSEditor("show", id);
|
||||||
if (!editor)
|
if (!editor) {
|
||||||
editor = createVCSEditor(editorId, title, source, true, "show", id, 0);
|
GitShowArgumentsWidget *argWidget =
|
||||||
|
new GitShowArgumentsWidget(&m_settings, this, source,
|
||||||
|
QStringList(), id);
|
||||||
|
userArgs = argWidget->arguments();
|
||||||
|
editor = createVCSEditor(editorId, title, source, true, "show", id, argWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList arguments;
|
||||||
|
arguments << QLatin1String("show") << QLatin1String(noColorOption);
|
||||||
|
arguments.append(userArgs);
|
||||||
|
arguments << id;
|
||||||
|
|
||||||
const QFileInfo sourceFi(source);
|
const QFileInfo sourceFi(source);
|
||||||
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
|
const QString workDir = sourceFi.isDir() ? sourceFi.absoluteFilePath() : sourceFi.absolutePath();
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public:
|
|||||||
static const char *noColorOption;
|
static const char *noColorOption;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void show(const QString &source, const QString &id);
|
void show(const QString &source, const QString &id, const QStringList &args = QStringList());
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
|
void slotBlameRevisionRequested(const QString &source, QString change, int lineNumber);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static const char ignoreSpaceChangesDiffKeyC[] = "SpaceIgnorantDiff";
|
|||||||
static const char diffPatienceKeyC[] = "DiffPatience";
|
static const char diffPatienceKeyC[] = "DiffPatience";
|
||||||
static const char winSetHomeEnvironmentKeyC[] = "WinSetHomeEnvironment";
|
static const char winSetHomeEnvironmentKeyC[] = "WinSetHomeEnvironment";
|
||||||
static const char gitkOptionsKeyC[] = "GitKOptions";
|
static const char gitkOptionsKeyC[] = "GitKOptions";
|
||||||
|
static const char showPrettyFormatC[] = "DiffPrettyFormat";
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
defaultPullRebase = 0,
|
defaultPullRebase = 0,
|
||||||
@@ -73,7 +74,8 @@ GitSettings::GitSettings() :
|
|||||||
ignoreSpaceChangesInDiff(false),
|
ignoreSpaceChangesInDiff(false),
|
||||||
ignoreSpaceChangesInBlame(true),
|
ignoreSpaceChangesInBlame(true),
|
||||||
diffPatience(true),
|
diffPatience(true),
|
||||||
winSetHomeEnvironment(false)
|
winSetHomeEnvironment(false),
|
||||||
|
showPrettyFormat(5)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +94,7 @@ void GitSettings::fromSettings(QSettings *settings)
|
|||||||
diffPatience = settings->value(QLatin1String(diffPatienceKeyC), true).toBool();
|
diffPatience = settings->value(QLatin1String(diffPatienceKeyC), true).toBool();
|
||||||
winSetHomeEnvironment = settings->value(QLatin1String(winSetHomeEnvironmentKeyC), false).toBool();
|
winSetHomeEnvironment = settings->value(QLatin1String(winSetHomeEnvironmentKeyC), false).toBool();
|
||||||
gitkOptions = settings->value(QLatin1String(gitkOptionsKeyC)).toString();
|
gitkOptions = settings->value(QLatin1String(gitkOptionsKeyC)).toString();
|
||||||
|
showPrettyFormat = settings->value(QLatin1String(showPrettyFormatC), 5).toInt();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +113,7 @@ void GitSettings::toSettings(QSettings *settings) const
|
|||||||
settings->setValue(QLatin1String(diffPatienceKeyC), diffPatience);
|
settings->setValue(QLatin1String(diffPatienceKeyC), diffPatience);
|
||||||
settings->setValue(QLatin1String(winSetHomeEnvironmentKeyC), winSetHomeEnvironment);
|
settings->setValue(QLatin1String(winSetHomeEnvironmentKeyC), winSetHomeEnvironment);
|
||||||
settings->setValue(QLatin1String(gitkOptionsKeyC), gitkOptions);
|
settings->setValue(QLatin1String(gitkOptionsKeyC), gitkOptions);
|
||||||
|
settings->setValue(QLatin1String(showPrettyFormatC), showPrettyFormat);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +126,7 @@ bool GitSettings::equals(const GitSettings &s) const
|
|||||||
&& ignoreSpaceChangesInBlame == s.ignoreSpaceChangesInBlame
|
&& ignoreSpaceChangesInBlame == s.ignoreSpaceChangesInBlame
|
||||||
&& ignoreSpaceChangesInDiff == s.ignoreSpaceChangesInDiff
|
&& ignoreSpaceChangesInDiff == s.ignoreSpaceChangesInDiff
|
||||||
&& diffPatience == s.diffPatience && winSetHomeEnvironment == s.winSetHomeEnvironment
|
&& diffPatience == s.diffPatience && winSetHomeEnvironment == s.winSetHomeEnvironment
|
||||||
&& gitkOptions == s.gitkOptions;
|
&& gitkOptions == s.gitkOptions && showPrettyFormat == s.showPrettyFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ struct GitSettings
|
|||||||
bool ignoreSpaceChangesInBlame;
|
bool ignoreSpaceChangesInBlame;
|
||||||
bool diffPatience;
|
bool diffPatience;
|
||||||
bool winSetHomeEnvironment;
|
bool winSetHomeEnvironment;
|
||||||
|
int showPrettyFormat;
|
||||||
QString gitkOptions;
|
QString gitkOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user