Commit 9b7274a0 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Remove comment lines from the git commit message (as git commit -F does not do that)


Reviewed-by: default avatardt <qtc-committer@nokia.com>
 enter the commit message for your changes. Lines starting
parent de6166fc
......@@ -35,6 +35,7 @@
#include <vcsbase/submitfilemodel.h>
#include <QtCore/QDebug>
#include <QtCore/QStringList>
namespace Git {
namespace Internal {
......@@ -121,6 +122,25 @@ void GitSubmitEditor::slotDiffSelected(const QStringList &files)
emit diff(unstagedFiles, stagedFiles);
}
QString GitSubmitEditor::fileContents() const
{
// We need to manually purge out comment lines starting with
// hash '#' since git does not do that when using -F.
const QChar newLine = QLatin1Char('\n');
const QChar hash = QLatin1Char('#');
QString message = VCSBase::VCSBaseSubmitEditor::fileContents();
for (int pos = 0; pos < message.size(); ) {
const int newLinePos = message.indexOf(newLine, pos);
const int startOfNextLine = newLinePos == -1 ? message.size() : newLinePos + 1;
if (message.at(pos) == hash) {
message.remove(pos, startOfNextLine - pos);
} else {
pos = startOfNextLine;
}
}
return message;
}
GitSubmitEditorPanelData GitSubmitEditor::panelData() const
{
return const_cast<GitSubmitEditor*>(this)->submitEditorWidget()->panelData();
......
......@@ -54,6 +54,8 @@ public:
void setCommitData(const CommitData &);
GitSubmitEditorPanelData panelData() const;
virtual QString fileContents() const;
signals:
void diff(const QStringList &unstagedFiles, const QStringList &stagedFiles);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment