Git: Fix inline nested branch rename

We can't just change the node name. A branch named foo/bar can be
renamed to baz/yyy. We have to refresh the model after rename.

Change-Id: Id9dfaa15b9e0384668223ae746376025267f89a3
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2017-03-26 16:45:25 +03:00
committed by Orgad Shaneh
parent 5736ef2c54
commit b30b4f8a11

View File

@@ -272,7 +272,7 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const
return res;
}
case Qt::EditRole:
return index.column() == 0 ? node->name : QVariant();
return index.column() == 0 ? node->fullName().join('/') : QVariant();
case Qt::ToolTipRole:
if (!node->isLeaf())
return QVariant();
@@ -307,24 +307,11 @@ bool BranchModel::setData(const QModelIndex &index, const QVariant &value, int r
if (newName.isEmpty())
return false;
if (node->name == newName)
return true;
QStringList oldFullName = node->fullName();
node->name = newName;
QStringList newFullName = node->fullName();
QString output;
QString errorMessage;
if (!m_client->synchronousBranchCmd(m_workingDirectory,
{"-m", oldFullName.last(), newFullName.last()},
&output, &errorMessage)) {
node->name = oldFullName.last();
VcsOutputWindow::appendError(errorMessage);
const QString oldName = node->fullName().join('/');
if (oldName == newName)
return false;
}
emit dataChanged(index, index);
renameBranch(oldName, newName);
return true;
}