Commit 3eacb444 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Prevent another crash on checkout

Crash happens if the repository has a submodule with local
changes that requires updating (commit changed between current
branch and new branch)

Since we already refresh for every repo change, just add "expect"
for checkout and remove the code accessing the deleted index.

Change-Id: Ic464129a2f001e017244fdf719b282dcbd9dffa4
Reviewed-by: default avatarTobias Hunger <>
parent 372fc608
......@@ -490,22 +490,7 @@ void BranchModel::checkoutBranch(const QModelIndex &idx)
// No StashGuard since this function for now is only used with clean working dir.
// If it is ever used from another place, please add StashGuard here
QString errorMessage;
if (m_client->synchronousCheckout(m_workingDirectory, branch, &errorMessage)) {
if (errorMessage.isEmpty()) {
QModelIndex currentIdx = currentBranch();
if (currentIdx.isValid()) {
m_currentBranch = 0;
emit dataChanged(currentIdx, currentIdx);
m_currentBranch = indexToNode(idx);
emit dataChanged(idx, idx);
} else {
refresh(m_workingDirectory, &errorMessage); // not sure all went well... better refresh!
if (!errorMessage.isEmpty())
m_client->synchronousCheckout(m_workingDirectory, branch);
bool BranchModel::branchIsMerged(const QModelIndex &idx)
......@@ -1271,7 +1271,8 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
QByteArray errorText;
QStringList arguments;
arguments << QLatin1String("checkout") << ref;
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText);
const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
const QString output = commandOutputFromLocal8Bit(outputText);
if (!rc) {
Supports Markdown
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