From 7c36f472770f69376dc0217429eeb7edefa384cb Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Fri, 29 Oct 2010 14:18:08 +0200
Subject: [PATCH] Git: Fix stash names

Fix detection of stash names.

Task-number: QTCREATORBUG-2934
---
 src/plugins/git/gitutils.cpp | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/plugins/git/gitutils.cpp b/src/plugins/git/gitutils.cpp
index 94418a0c60f..a6d2f23381a 100644
--- a/src/plugins/git/gitutils.cpp
+++ b/src/plugins/git/gitutils.cpp
@@ -67,20 +67,14 @@ bool Stash::parseStashLine(const QString &l)
     const int messagePos = l.indexOf(colon, branchPos + 1);
     if (messagePos < 0)
         return false;
-    // Name
-    const QString newName = l.left(branchPos);
     // Branch spec
-    const QString branchSpec = l.mid(branchPos + 1, messagePos - branchPos - 1);
-    const bool emptyMessage = branchSpec.contains(QLatin1String("WIP")); // "Work in Progress or sth"
-    const int onIndex = branchSpec.indexOf(QLatin1String("on "), 0, Qt::CaseInsensitive);
-    if (onIndex == -1)
+    const int onIndex = l.indexOf(QLatin1String("on "), branchPos + 2, Qt::CaseInsensitive);
+    if (onIndex == -1 || onIndex >= messagePos)
         return false;
-    const QString newBranch = branchSpec.mid(onIndex + 3);
     // Happy!
-    name = newName;
-    branch = newBranch;
-    if (!emptyMessage)
-        message = l.mid(messagePos + 2); // skip blank
+    name = l.left(branchPos);
+    branch = l.mid(onIndex + 3, messagePos - onIndex - 3);
+    message = l.mid(messagePos + 2); // skip blank
     return true;
 }
 
-- 
GitLab