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,28 +156,36 @@ bool CommitData::parseFilesFromStatus(const QString &output) ...@@ -156,28 +156,36 @@ 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)) { if (line.startsWith(commitIndicator)) {
s = CommitFiles; s = CommitFiles;
} else { continue;
}
if (line.startsWith(notUpdatedIndicator)) { if (line.startsWith(notUpdatedIndicator)) {
s = NotUpdatedFiles; s = NotUpdatedFiles;
} else { continue;
}
if (line.startsWith(untrackedIndicator)) { if (line.startsWith(untrackedIndicator)) {
// Now match untracked: "#<tab>foo.cpp" // Now match untracked: "#<tab>foo.cpp"
s = UntrackedFiles; s = UntrackedFiles;
filesPattern = QRegExp(QLatin1String("#\\t.+")); filesPattern = QRegExp(QLatin1String("#\\t.+"));
QTC_ASSERT(filesPattern.isValid(), return false); QTC_ASSERT(filesPattern.isValid(), return false);
} else { continue;
}
if (filesPattern.exactMatch(line)) { if (filesPattern.exactMatch(line)) {
switch (s) { switch (s) {
case CommitFiles: case CommitFiles:
addStateFileSpecification(line, &stagedFiles); addStateFileSpecification(line, &stagedFiles);
break; break;
case NotUpdatedFiles: case NotUpdatedFiles:
// skip submodules:
if (line.endsWith(QLatin1String(" (modified content)"))
|| line.endsWith(" (new commits)"))
line = line.left(line.lastIndexOf(QLatin1Char('(')) - 1);
addStateFileSpecification(line, &unstagedFiles); addStateFileSpecification(line, &unstagedFiles);
break; break;
case UntrackedFiles: case UntrackedFiles:
...@@ -188,10 +196,6 @@ bool CommitData::parseFilesFromStatus(const QString &output) ...@@ -188,10 +196,6 @@ bool CommitData::parseFilesFromStatus(const QString &output)
} }
} }
} }
}
}
}
}
return true; return true;
} }
......
...@@ -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