Commit d72b4851 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Avoid QByteArray -> QString -> QByteArray conversions for encoding



Change-Id: Ib2eb3000a08021336c9071d35d499371c9b88976
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent e6d0e687
...@@ -2401,7 +2401,9 @@ SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory) ...@@ -2401,7 +2401,9 @@ SubmoduleDataMap GitClient::submoduleList(const QString &workingDirectory)
if (cachedSubmoduleData.contains(workingDirectory)) if (cachedSubmoduleData.contains(workingDirectory))
return cachedSubmoduleData.value(workingDirectory); return cachedSubmoduleData.value(workingDirectory);
QStringList allConfigs = readConfig(workingDirectory, QLatin1String("-l")).split(QLatin1Char('\n')); QStringList allConfigs =
commandOutputFromLocal8Bit(readConfig(workingDirectory, QLatin1String("-l")))
.split(QLatin1Char('\n'));
const QString submoduleLineStart = QLatin1String("submodule."); const QString submoduleLineStart = QLatin1String("submodule.");
foreach (const QString &configLine, allConfigs) { foreach (const QString &configLine, allConfigs) {
if (!configLine.startsWith(submoduleLineStart)) if (!configLine.startsWith(submoduleLineStart))
...@@ -3017,8 +3019,7 @@ QString GitClient::gitBinaryPath(bool *ok, QString *errorMessage) const ...@@ -3017,8 +3019,7 @@ QString GitClient::gitBinaryPath(bool *ok, QString *errorMessage) const
QTextCodec *GitClient::encoding(const QString &workingDirectory, const QByteArray &configVar) const QTextCodec *GitClient::encoding(const QString &workingDirectory, const QByteArray &configVar) const
{ {
QByteArray codecName = readConfigValue(workingDirectory, QLatin1String(configVar)) QByteArray codecName = readConfig(workingDirectory, QLatin1String(configVar)).trimmed();
.toLocal8Bit();
// Set default commit encoding to 'UTF-8', when it's not set, // Set default commit encoding to 'UTF-8', when it's not set,
// to solve displaying error of commit log with non-latin characters. // to solve displaying error of commit log with non-latin characters.
if (codecName.isEmpty()) if (codecName.isEmpty())
...@@ -3742,7 +3743,7 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, ...@@ -3742,7 +3743,7 @@ bool GitClient::synchronousStashList(const QString &workingDirectory,
return true; return true;
} }
QString GitClient::readConfig(const QString &workingDirectory, const QString &configVar) const QByteArray GitClient::readConfig(const QString &workingDirectory, const QString &configVar) const
{ {
QStringList arguments; QStringList arguments;
arguments << QLatin1String("config") << configVar; arguments << QLatin1String("config") << configVar;
...@@ -3751,16 +3752,16 @@ QString GitClient::readConfig(const QString &workingDirectory, const QString &co ...@@ -3751,16 +3752,16 @@ QString GitClient::readConfig(const QString &workingDirectory, const QString &co
QByteArray errorText; QByteArray errorText;
if (!fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, if (!fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
VcsBasePlugin::SuppressCommandLogging)) VcsBasePlugin::SuppressCommandLogging))
return QString(); return QByteArray();
if (Utils::HostOsInfo::isWindowsHost()) if (Utils::HostOsInfo::isWindowsHost())
return Utils::SynchronousProcess::normalizeNewlines(QString::fromUtf8(outputText)); outputText.replace("\r\n", "\n");
return commandOutputFromLocal8Bit(outputText); return outputText;
} }
// Read a single-line config value, return trimmed // Read a single-line config value, return trimmed
QString GitClient::readConfigValue(const QString &workingDirectory, const QString &configVar) const QString GitClient::readConfigValue(const QString &workingDirectory, const QString &configVar) const
{ {
return readConfig(workingDirectory, configVar).remove(QLatin1Char('\n')); return commandOutputFromLocal8Bit(readConfig(workingDirectory, configVar).trimmed());
} }
bool GitClient::cloneRepository(const QString &directory,const QByteArray &url) bool GitClient::cloneRepository(const QString &directory,const QByteArray &url)
......
...@@ -281,7 +281,7 @@ public: ...@@ -281,7 +281,7 @@ public:
const QString &messge, QString *name, const QString &messge, QString *name,
QString *errorMessage = 0); QString *errorMessage = 0);
QString readConfig(const QString &workingDirectory, const QString &configVar) const; QByteArray readConfig(const QString &workingDirectory, const QString &configVar) const;
QString readConfigValue(const QString &workingDirectory, const QString &configVar) const; QString readConfigValue(const QString &workingDirectory, const QString &configVar) 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