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

Git: Fix sha1 resolving when a branch is added from detached HEAD



Change-Id: I0d8ad988411256fc284b84f78be6f54362ab19ea
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 8fc7035b
...@@ -574,14 +574,19 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel ...@@ -574,14 +574,19 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
const QString trackedBranch = fullName(startPoint); const QString trackedBranch = fullName(startPoint);
const QString fullTrackedBranch = fullName(startPoint, true); const QString fullTrackedBranch = fullName(startPoint, true);
QString startSha;
QString output; QString output;
QString errorMessage; QString errorMessage;
QStringList args; QStringList args;
args << (track ? QLatin1String("--track") : QLatin1String("--no-track")); args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
args << name; args << name;
if (!fullTrackedBranch.isEmpty()) if (!fullTrackedBranch.isEmpty()) {
args << fullTrackedBranch; args << fullTrackedBranch;
startSha = sha(startPoint);
} else {
startSha = m_client->synchronousTopRevision(m_workingDirectory);
}
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) { if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage); VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
...@@ -606,7 +611,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel ...@@ -606,7 +611,7 @@ QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModel
local = child; local = child;
} }
int pos = positionForName(local, leafName); int pos = positionForName(local, leafName);
BranchNode *newNode = new BranchNode(leafName, sha(startPoint), track ? trackedBranch : QString()); BranchNode *newNode = new BranchNode(leafName, startSha, track ? trackedBranch : QString());
if (!added) if (!added)
beginInsertRows(nodeToIndex(local), pos, pos); beginInsertRows(nodeToIndex(local), pos, pos);
newNode->parent = local; newNode->parent = local;
......
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