forked from qt-creator/qt-creator
Git: Do not use file name when retrieving parent commit
Right-clicking a commit on blame shows the parent commit relevant for this file. In case the file was renamed, fetching the parent can fail (since the file with this name did not exist before the requested commit). Using the direct parent is good enough, and should work for all cases. What the user is really interested in is "how did the file look before this commit", and the exact "previous" commit is not really interesting. Change-Id: I7d74efce5f2b065f62e978ba5f14d3010a5f2c7f Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
bd858d9753
commit
1fd8760789
@@ -1283,7 +1283,6 @@ bool GitClient::synchronousRevListCmd(const QString &workingDirectory, const QSt
|
|||||||
// Find out the immediate parent revisions of a revision of the repository.
|
// Find out the immediate parent revisions of a revision of the repository.
|
||||||
// Might be several in case of merges.
|
// Might be several in case of merges.
|
||||||
bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
|
bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
|
||||||
const QStringList &files /* = QStringList() */,
|
|
||||||
const QString &revision,
|
const QString &revision,
|
||||||
QStringList *parents,
|
QStringList *parents,
|
||||||
QString *errorMessage) const
|
QString *errorMessage) const
|
||||||
@@ -1296,10 +1295,6 @@ bool GitClient::synchronousParentRevisions(const QString &workingDirectory,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
arguments << QLatin1String("--parents") << QLatin1String("--max-count=1") << revision;
|
arguments << QLatin1String("--parents") << QLatin1String("--max-count=1") << revision;
|
||||||
if (!files.isEmpty()) {
|
|
||||||
arguments.append(QLatin1String("--"));
|
|
||||||
arguments.append(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!synchronousRevListCmd(workingDirectory, arguments, &outputText, &errorText)) {
|
if (!synchronousRevListCmd(workingDirectory, arguments, &outputText, &errorText)) {
|
||||||
*errorMessage = msgParentRevisionFailed(workingDirectory, revision, errorText);
|
*errorMessage = msgParentRevisionFailed(workingDirectory, revision, errorText);
|
||||||
@@ -1475,7 +1470,7 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
|
|||||||
|
|
||||||
QStringList parents;
|
QStringList parents;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
synchronousParentRevisions(workingDirectory, QStringList(), revision, &parents, &errorMessage);
|
synchronousParentRevisions(workingDirectory, revision, &parents, &errorMessage);
|
||||||
foreach (const QString &p, parents) {
|
foreach (const QString &p, parents) {
|
||||||
QByteArray pf;
|
QByteArray pf;
|
||||||
arguments.clear();
|
arguments.clear();
|
||||||
|
@@ -237,7 +237,6 @@ public:
|
|||||||
QString *output, QString *errorMessage = 0) const;
|
QString *output, QString *errorMessage = 0) const;
|
||||||
|
|
||||||
bool synchronousParentRevisions(const QString &workingDirectory,
|
bool synchronousParentRevisions(const QString &workingDirectory,
|
||||||
const QStringList &files /* = QStringList() */,
|
|
||||||
const QString &revision,
|
const QString &revision,
|
||||||
QStringList *parents,
|
QStringList *parents,
|
||||||
QString *errorMessage) const;
|
QString *errorMessage) const;
|
||||||
|
@@ -309,8 +309,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
|
|||||||
const QFileInfo fi(source());
|
const QFileInfo fi(source());
|
||||||
const QString workingDirectory = fi.absolutePath();
|
const QString workingDirectory = fi.absolutePath();
|
||||||
// Get the SHA1's of the file.
|
// Get the SHA1's of the file.
|
||||||
if (!client->synchronousParentRevisions(workingDirectory, QStringList(fi.fileName()),
|
if (!client->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) {
|
||||||
revision, &revisions, &errorMessage)) {
|
|
||||||
VcsOutputWindow::appendSilently(errorMessage);
|
VcsOutputWindow::appendSilently(errorMessage);
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user