Git: Hack around quoting problem with Short description on blame

Task-number: QTCREATORBUG-23208
Change-Id: Iaff99d7cd175d3d974ea295472cba2679da08372
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2020-02-14 16:45:12 +01:00
parent 4cbb24906f
commit b9739c0945

View File

@@ -1486,14 +1486,19 @@ bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
return true;
}
// Short SHA1, author, subject
static const char defaultShortLogFormatC[] = "%h (%an \"%s";
static const int maxShortLogLength = 120;
QString GitClient::synchronousShortDescription(const QString &workingDirectory, const QString &revision) const
{
// HACK: The hopefully rare "_-_" will be replaced by quotes in the output,
// leaving it in breaks command line quoting on Windows, see QTCREATORBUG-23208.
const QString quoteReplacement = "_-_";
// Short SHA1, author, subject
const QString defaultShortLogFormat = "%h (%an " + quoteReplacement + "%s";
const int maxShortLogLength = 120;
// Short SHA 1, author, subject
QString output = synchronousShortDescription(workingDirectory, revision, defaultShortLogFormatC);
QString output = synchronousShortDescription(workingDirectory, revision, defaultShortLogFormat);
output.replace(quoteReplacement, "\"");
if (output != revision) {
if (output.length() > maxShortLogLength) {
output.truncate(maxShortLogLength);