summaryrefslogtreecommitdiff
path: root/src/plugins/git
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2013-06-19 06:12:08 +0300
committerOrgad Shaneh <orgads@gmail.com>2013-06-19 22:07:06 +0200
commit57a6f04ce6f72737e39c7504d01ff61249cbfc6e (patch)
tree98b3aed20b6683f47ac27173d00a524cb8d8edc1 /src/plugins/git
parent11e7c706beb312c598cb6c4aa730c5480f40fe81 (diff)
downloadqt-creator-57a6f04ce6f72737e39c7504d01ff61249cbfc6e.tar.gz
Git: Prevent tracking tags
Change-Id: Iea935aa226b70de936653b7637b4b9bb5e9c64cf Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/branchadddialog.cpp8
-rw-r--r--src/plugins/git/branchdialog.cpp3
-rw-r--r--src/plugins/git/branchmodel.cpp19
-rw-r--r--src/plugins/git/branchmodel.h1
4 files changed, 27 insertions, 4 deletions
diff --git a/src/plugins/git/branchadddialog.cpp b/src/plugins/git/branchadddialog.cpp
index 96679be675..61b8fb2f18 100644
--- a/src/plugins/git/branchadddialog.cpp
+++ b/src/plugins/git/branchadddialog.cpp
@@ -124,12 +124,14 @@ QString BranchAddDialog::branchName() const
void BranchAddDialog::setTrackedBranchName(const QString &name, bool remote)
{
m_ui->trackingCheckBox->setVisible(true);
- if (!name.isEmpty())
+ if (!name.isEmpty()) {
m_ui->trackingCheckBox->setText(remote ? tr("Track remote branch \'%1\'").arg(name) :
tr("Track local branch \'%1\'").arg(name));
- else
+ m_ui->trackingCheckBox->setChecked(remote);
+ } else {
m_ui->trackingCheckBox->setVisible(false);
- m_ui->trackingCheckBox->setChecked(remote);
+ m_ui->trackingCheckBox->setChecked(false);
+ }
}
bool BranchAddDialog::track()
diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp
index d4b68d74d5..0e9c8c33f1 100644
--- a/src/plugins/git/branchdialog.cpp
+++ b/src/plugins/git/branchdialog.cpp
@@ -128,6 +128,7 @@ void BranchDialog::add()
trackedBranch = m_model->branchName(trackedIndex);
}
const bool isLocal = m_model->isLocal(trackedIndex);
+ const bool isTag = m_model->isTag(trackedIndex);
QStringList localNames = m_model->localBranchNames();
@@ -141,7 +142,7 @@ void BranchDialog::add()
BranchAddDialog branchAddDialog(true, this);
branchAddDialog.setBranchName(suggestedName);
- branchAddDialog.setTrackedBranchName(trackedBranch, !isLocal);
+ branchAddDialog.setTrackedBranchName(isTag ? QString() : trackedBranch, !isLocal);
if (branchAddDialog.exec() == QDialog::Accepted && m_model) {
QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedIndex);
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index 82dc25da39..69e4ee5466 100644
--- a/src/plugins/git/branchmodel.cpp
+++ b/src/plugins/git/branchmodel.cpp
@@ -77,6 +77,18 @@ public:
return children.isEmpty();
}
+ bool isTag() const
+ {
+ if (!parent)
+ return false;
+ for (const BranchNode *p = this; p->parent; p = p->parent) {
+ // find root child with name "tags"
+ if (!p->parent->parent && p->name == QLatin1String("tags"))
+ return true;
+ }
+ return false;
+ }
+
bool childOf(BranchNode *node) const
{
if (this == node)
@@ -435,6 +447,13 @@ bool BranchModel::isLeaf(const QModelIndex &idx) const
return node->isLeaf();
}
+bool BranchModel::isTag(const QModelIndex &idx) const
+{
+ if (!idx.isValid())
+ return false;
+ return indexToNode(idx)->isTag();
+}
+
void BranchModel::removeBranch(const QModelIndex &idx)
{
QString branch = branchName(idx);
diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h
index a8f13ffba8..1be003dab2 100644
--- a/src/plugins/git/branchmodel.h
+++ b/src/plugins/git/branchmodel.h
@@ -74,6 +74,7 @@ public:
QString sha(const QModelIndex &idx) const;
bool isLocal(const QModelIndex &idx) const;
bool isLeaf(const QModelIndex &idx) const;
+ bool isTag(const QModelIndex &idx) const;
void removeBranch(const QModelIndex &idx);
void checkoutBranch(const QModelIndex &idx);