Commit 11e21e16 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: Improve handling of git submodules

Task-number: QTCREATORBUG-3390
parent 94fc750a
...@@ -156,39 +156,43 @@ bool CommitData::parseFilesFromStatus(const QString &output) ...@@ -156,39 +156,43 @@ bool CommitData::parseFilesFromStatus(const QString &output)
const QStringList::const_iterator cend = lines.constEnd(); const QStringList::const_iterator cend = lines.constEnd();
for (QStringList::const_iterator it = lines.constBegin(); it != cend; ++it) { for (QStringList::const_iterator it = lines.constBegin(); it != cend; ++it) {
const QString line = *it; QString line = *it;
if (line.startsWith(branchIndicator)) { if (line.startsWith(branchIndicator)) {
panelInfo.branch = line.mid(branchIndicator.size() + 1); panelInfo.branch = line.mid(branchIndicator.size() + 1);
} else { continue;
if (line.startsWith(commitIndicator)) { }
s = CommitFiles; if (line.startsWith(commitIndicator)) {
} else { s = CommitFiles;
if (line.startsWith(notUpdatedIndicator)) { continue;
s = NotUpdatedFiles; }
} else { if (line.startsWith(notUpdatedIndicator)) {
if (line.startsWith(untrackedIndicator)) { s = NotUpdatedFiles;
// Now match untracked: "#<tab>foo.cpp" continue;
s = UntrackedFiles; }
filesPattern = QRegExp(QLatin1String("#\\t.+")); if (line.startsWith(untrackedIndicator)) {
QTC_ASSERT(filesPattern.isValid(), return false); // Now match untracked: "#<tab>foo.cpp"
} else { s = UntrackedFiles;
if (filesPattern.exactMatch(line)) { filesPattern = QRegExp(QLatin1String("#\\t.+"));
switch (s) { QTC_ASSERT(filesPattern.isValid(), return false);
case CommitFiles: continue;
addStateFileSpecification(line, &stagedFiles); }
break; if (filesPattern.exactMatch(line)) {
case NotUpdatedFiles: switch (s) {
addStateFileSpecification(line, &unstagedFiles); case CommitFiles:
break; addStateFileSpecification(line, &stagedFiles);
case UntrackedFiles: break;
untrackedFiles.push_back(line.mid(2).trimmed()); case NotUpdatedFiles:
break; // skip submodules:
case None: if (line.endsWith(QLatin1String(" (modified content)"))
break; || line.endsWith(" (new commits)"))
} line = line.left(line.lastIndexOf(QLatin1Char('(')) - 1);
} addStateFileSpecification(line, &unstagedFiles);
} break;
} case UntrackedFiles:
untrackedFiles.push_back(line.mid(2).trimmed());
break;
case None:
break;
} }
} }
} }
......
...@@ -1801,6 +1801,8 @@ bool GitClient::getCommitData(const QString &workingDirectory, ...@@ -1801,6 +1801,8 @@ bool GitClient::getCommitData(const QString &workingDirectory,
// # (use "git add <file>..." to update what will be committed) // # (use "git add <file>..." to update what will be committed)
// # // #
// # modified: someother.cpp // # modified: someother.cpp
// # modified: submodule (modified content)
// # modified: submodule2 (new commit)
// # // #
// # Untracked files: // # Untracked files:
// # (use "git add <file>..." to include in what will be committed) // # (use "git add <file>..." to include in what will be committed)
......
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