From 2ec4de7ae7f9f6bd5f79ddd400be9169bbb8f359 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Tue, 26 Jul 2011 13:13:04 +0000
Subject: [PATCH] Git: Fix thinko when trying to find merged branches
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix thinko when trying to find out whether a branch was merged or not.

Change-Id: I6c4d600508af8a68fe0bac7e61f0b912c43cec32
Reviewed-on: http://codereview.qt.nokia.com/2200
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
---
 src/plugins/git/branchmodel.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index 428ddf3e6a9..5d1712aeee6 100644
--- a/src/plugins/git/branchmodel.cpp
+++ b/src/plugins/git/branchmodel.cpp
@@ -470,15 +470,18 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
     QString output;
     QStringList args;
 
-    args << QLatin1String("--contains") << sha(idx);
+    args << QLatin1String("-a") << QLatin1String("--contains") << sha(idx);
     if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
         VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
         return false;
     }
 
-    QStringList lines = output.split(QLatin1Char('/'), QString::SkipEmptyParts);
+    QStringList lines = output.split(QLatin1Char('\n'), QString::SkipEmptyParts);
     foreach (const QString &l, lines) {
-        if (l.startsWith(QLatin1String("  ")) && l.count() >= 3)
+        QString currentBranch = l.mid(2); // remove first letters (those are either
+                                          // "  " or "* " depending on whether it is
+                                          // the currently checked out branch or not)
+        if (currentBranch != branch)
             return true;
     }
     return false;
-- 
GitLab