Teach qgit about remote branches and show them with an orange background in tag mark indicator. Signed-off-by: Marco Costalba <mcostalba@xxxxxxxxx> --- src/git.cpp | 12 ++++++++++++ src/git.h | 12 +++++++----- src/git_startup.cpp | 5 +++++ src/listview.cpp | 3 +++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/git.cpp b/src/git.cpp index 33834d5..08b3309 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -182,6 +182,9 @@ const QStringList Git::getRefName(SCRef sha, RefType type, QString* curBranch) c else if (type == BRANCH) return rf.branches; + else if (type == RMT_BRANCH) + return rf.remoteBranches; + else if (type == REF) return rf.refs; @@ -214,6 +217,9 @@ const QString Git::getRefSha(SCRef refName, RefType type, bool askGit) { else if ((any || type == BRANCH) && rf.branches.contains(refName)) return it.key(); + else if ((any || type == RMT_BRANCH) && rf.remoteBranches.contains(refName)) + return it.key(); + else if ((any || type == REF) && rf.refs.contains(refName)) return it.key(); @@ -257,6 +263,9 @@ const QStringList Git::getAllRefNames(uint mask, bool onlyLoaded) { if (mask & BRANCH) appendNamesWithId(names, it.key(), (*it).branches, onlyLoaded); + if (mask & RMT_BRANCH) + appendNamesWithId(names, it.key(), (*it).remoteBranches, onlyLoaded); + if (mask & REF) appendNamesWithId(names, it.key(), (*it).refs, onlyLoaded); @@ -283,6 +292,9 @@ const QString Git::getRevInfo(SCRef sha) { const QString cap(type & CUR_BRANCH ? "Head: " : "Branch: "); refsInfo = cap + getRefName(sha, BRANCH).join(" "); } + if (type & RMT_BRANCH) + refsInfo.append(" Remote branch: " + getRefName(sha, RMT_BRANCH).join(" ")); + if (type & TAG) refsInfo.append(" Tag: " + getRefName(sha, TAG).join(" ")); diff --git a/src/git.h b/src/git.h index 48f4e06..5b174ab 100644 --- a/src/git.h +++ b/src/git.h @@ -51,11 +51,12 @@ public: enum RefType { TAG = 1, BRANCH = 2, - CUR_BRANCH = 4, - REF = 8, - APPLIED = 16, - UN_APPLIED = 32, - ANY_REF = 63 + RMT_BRANCH = 4, + CUR_BRANCH = 8, + REF = 16, + APPLIED = 32, + UN_APPLIED = 64, + ANY_REF = 127 }; void checkEnvironment(); @@ -155,6 +156,7 @@ private: Reference() : type(0) {} uint type; QStringList branches; + QStringList remoteBranches; QString currentBranch; QStringList tags; QStringList refs; diff --git a/src/git_startup.cpp b/src/git_startup.cpp index 6b34460..84e62a5 100644 --- a/src/git_startup.cpp +++ b/src/git_startup.cpp @@ -172,6 +172,11 @@ bool Git::getRefs() { cur->type |= CUR_BRANCH; cur->currentBranch = curBranchName; } + } else if (refName.startsWith("refs/remotes/") && !refName.endsWith("HEAD")) { + + cur->remoteBranches.append(refName.mid(13)); + cur->type |= RMT_BRANCH; + } else if (!refName.endsWith("HEAD")) { cur->refs.append(refName); diff --git a/src/listview.cpp b/src/listview.cpp index bfc2a7d..80043e9 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -635,6 +635,9 @@ void ListViewItem::paintTagMarks(int col) { if (rt & Git::BRANCH) addBranchPixmap(&newPm); + if (rt & Git::RMT_BRANCH) + addRefPixmap(&newPm, git->getRefName(_sha, Git::RMT_BRANCH), ORANGE); + if (rt & Git::TAG) addRefPixmap(&newPm, git->getRefName(_sha, Git::TAG), Qt::yellow); -- 1.5.0-rc3.GIT - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html