forked from qt-creator/qt-creator
Git: Keep author information on amend
Change-Id: I15982b746656536ae79a612ee563f69b58a4baa7 Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
47a79e2225
commit
59417df92a
@@ -1746,17 +1746,14 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commitData->panelData.author = readConfigValue(workingDirectory, QLatin1String("user.name"));
|
|
||||||
commitData->panelData.email = readConfigValue(workingDirectory, QLatin1String("user.email"));
|
|
||||||
commitData->commitEncoding = readConfigValue(workingDirectory, QLatin1String("i18n.commitEncoding"));
|
commitData->commitEncoding = readConfigValue(workingDirectory, QLatin1String("i18n.commitEncoding"));
|
||||||
|
|
||||||
// Get the commit template or the last commit message
|
// Get the commit template or the last commit message
|
||||||
if (amend) {
|
if (amend) {
|
||||||
// Amend: get last commit data as "SHA1@message".
|
// Amend: get last commit data as "SHA1<tab>author<tab>email<tab>message".
|
||||||
QStringList args(QLatin1String("log"));
|
QStringList args(QLatin1String("log"));
|
||||||
const QString format = gitVersion(true) > 0x010701 ?
|
const QString msgFormat = QLatin1String((gitVersion(true) > 0x010701) ? "%B" : "%s%n%n%b");
|
||||||
QLatin1String("%h@%B") :
|
const QString format = QLatin1String("%h\t%an\t%ae\t") + msgFormat;
|
||||||
QLatin1String("%h@%s%n%n%b");
|
|
||||||
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:") + format;
|
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:") + format;
|
||||||
QTextCodec *codec = QTextCodec::codecForName(commitData->commitEncoding.toLocal8Bit());
|
QTextCodec *codec = QTextCodec::codecForName(commitData->commitEncoding.toLocal8Bit());
|
||||||
const Utils::SynchronousProcessResponse sp = synchronousGit(repoDirectory, args, 0, codec);
|
const Utils::SynchronousProcessResponse sp = synchronousGit(repoDirectory, args, 0, codec);
|
||||||
@@ -1764,11 +1761,15 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
*errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".").arg(repoDirectory);
|
*errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".").arg(repoDirectory);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const int separatorPos = sp.stdOut.indexOf(QLatin1Char('@'));
|
QStringList values = sp.stdOut.split(QLatin1Char('\t'));
|
||||||
QTC_ASSERT(separatorPos != -1, return false);
|
QTC_ASSERT(values.size() >= 4, return false);
|
||||||
commitData->amendSHA1= sp.stdOut.left(separatorPos);
|
commitData->amendSHA1 = values.takeFirst();
|
||||||
*commitTemplate = sp.stdOut.mid(separatorPos + 1);
|
commitData->panelData.author = values.takeFirst();
|
||||||
|
commitData->panelData.email = values.takeFirst();
|
||||||
|
*commitTemplate = values.join(QLatin1String("\t"));
|
||||||
} else {
|
} else {
|
||||||
|
commitData->panelData.author = readConfigValue(workingDirectory, QLatin1String("user.name"));
|
||||||
|
commitData->panelData.email = readConfigValue(workingDirectory, QLatin1String("user.email"));
|
||||||
// Commit: Get the commit template
|
// Commit: Get the commit template
|
||||||
QString templateFilename = gitDir.absoluteFilePath(QLatin1String("MERGE_MSG"));
|
QString templateFilename = gitDir.absoluteFilePath(QLatin1String("MERGE_MSG"));
|
||||||
if (!QFileInfo(templateFilename).isFile())
|
if (!QFileInfo(templateFilename).isFile())
|
||||||
|
Reference in New Issue
Block a user