Commit 8aa1c9bc authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

VCS: Remove removeColorCodes



status output can be uncolorized using the git config value
color.status=false (works for short status since git 1.7.0)

Change-Id: I0887ab9a02f4c98fe54a94a53ffcd4f91fef8699
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 54b71469
......@@ -777,6 +777,12 @@ static inline QString currentDocumentPath()
return QString();
}
static inline QStringList statusArguments()
{
return QStringList() << QLatin1String("-c") << QLatin1String("color.status=false")
<< QLatin1String("status");
}
// ---------------- GitClient
const char *GitClient::stashNamePrefix = "stash@{";
......@@ -1089,8 +1095,7 @@ void GitClient::merge(const QString &workingDirectory, const QStringList &unmerg
void GitClient::status(const QString &workingDirectory)
{
// @TODO: Use "--no-color" once it is supported
QStringList statusArgs(QLatin1String("status"));
QStringList statusArgs = statusArguments();
statusArgs << QLatin1String("-u");
VcsBase::VcsBaseOutputWindow *outwin = outputWindow();
outwin->setRepository(workingDirectory);
......@@ -2368,7 +2373,7 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St
QByteArray outputText;
QByteArray errorText;
QStringList statusArgs(QLatin1String("status"));
QStringList statusArgs = statusArguments();
if (mode & NoUntracked)
statusArgs << QLatin1String("--untracked-files=no");
else
......
......@@ -284,9 +284,6 @@ void Command::run()
}
}
if (ok && d->m_jobs.front().arguments.at(0) == QLatin1String("status"))
removeColorCodes(&stdOut);
d->m_lastExecSuccess = ok;
d->m_lastExecExitCode = exitCode;
......@@ -307,29 +304,6 @@ void Command::run()
this->deleteLater();
}
// Clean output from carriage return and ANSI color codes.
// @TODO: Remove once all relevant commands support "--no-color",
//("status" is missing it as of git 1.6.2)
void Command::removeColorCodes(QByteArray *data)
{
// Remove ansi color codes that look like "ESC[<stuff>m"
const QByteArray ansiColorEscape("\033[");
int escapePos = 0;
while (true) {
const int nextEscapePos = data->indexOf(ansiColorEscape, escapePos);
if (nextEscapePos == -1)
break;
const int endEscapePos = data->indexOf('m', nextEscapePos + ansiColorEscape.size());
if (endEscapePos != -1) {
data->remove(nextEscapePos, endEscapePos - nextEscapePos + 1);
escapePos = nextEscapePos;
} else {
escapePos = nextEscapePos + ansiColorEscape.size();
}
}
}
const QVariant &Command::cookie() const
{
return d->m_cookie;
......
......@@ -66,10 +66,6 @@ public:
bool lastExecutionSuccess() const;
int lastExecutionExitCode() const;
// Clean output from carriage return and ANSI color codes
// Workaround until all relevant commands support "--no-color"
static void removeColorCodes(QByteArray *data);
const QString &binaryPath() const;
const QString &workingDirectory() const;
const QProcessEnvironment &processEnvironment() const;
......
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