diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2011-08-18 08:29:43 +0000 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2011-08-18 10:58:56 +0200 |
commit | 5396124dd71399270163fb1b10116bf24b470238 (patch) | |
tree | ebed77a0cf6085a8af431fd85465cdfa7bcc44d5 /src | |
parent | 4e1d92fddc4c03fe87415421fd70e59db23a9c29 (diff) | |
download | qt-creator-5396124dd71399270163fb1b10116bf24b470238.tar.gz |
Git: Fixed Omit Date
Issue: QTCREATORBUG-5429
Reviewed-by: pending
Change-Id: Id2bb7fa756b7d5f49e8d7a250431f8042d514fd2
Merge-request: 366
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Reviewed-on: http://codereview.qt.nokia.com/3151
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/git/giteditor.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index 1f06e7a13c..74fbd0b97b 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -157,35 +157,42 @@ static QByteArray removeAnnotationDate(const QByteArray &b) return QByteArray(b); int datePos = parenPos; - // Go back from paren for 5 spaces: That is where the date starts. + int i = parenPos; + while (i >= 0 && b.at(i) != ' ') + --i; + while (i >= 0 && b.at(i) == ' ') + --i; int spaceCount = 0; - for (int i = parenPos; i >= 0; --i) { + // i is now on timezone. Go back 3 spaces: That is where the date starts. + while (i >= 0) { if (b.at(i) == ' ') ++spaceCount; - if (spaceCount == 5) { - datePos = i + 1; + if (spaceCount == 3) { + datePos = i; break; } + --i; } if (datePos == 0) return QByteArray(b); // Copy over the parts that have not changed into a new byte array Q_ASSERT(b.size() >= parenPos); - QByteArray result(b.constData(), datePos); + QByteArray result; int prevPos = 0; - int pos = parenPos; + int pos = b.indexOf('\n', 0) + 1; forever { Q_ASSERT(prevPos < pos); - if (prevPos != 0) - result.append(b.constData() + prevPos, pos - prevPos); + int afterParen = prevPos + parenPos; + result.append(b.constData() + prevPos, datePos); + result.append(b.constData() + afterParen, pos - afterParen); prevPos = pos; Q_ASSERT(prevPos != 0); if (pos == b.size()) break; - pos = b.indexOf('\n', pos + 1); - if (pos == -1) + pos = b.indexOf('\n', pos) + 1; + if (pos == 0) // indexOf returned -1 pos = b.size(); } return result; |