diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2017-11-26 10:24:32 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2017-11-27 11:40:31 +0000 |
commit | 63861c44c1e4f9d4cf6a7a48fe9534b4f73d0ad7 (patch) | |
tree | ffec6214cebb2bb8d15632fc03420bbb62d7052f /src/plugins/diffeditor/diffutils.cpp | |
parent | 8bc3ac9177e6f8f05c2c64a400d244a5cc82aa0a (diff) | |
download | qt-creator-63861c44c1e4f9d4cf6a7a48fe9534b4f73d0ad7.tar.gz |
DiffEditor: Fix parsing of mode-only change in patch
If one of the files has mode-only change, the entire patch
fails as a git patch, and is parsed as a text patch.
Because of that, the prefixes (a/, b/) are not stripped and
jumping to a change by double-clicking does not work.
Change-Id: Ib54ce4fa7aad02cb956af1f7de73d3c732ac5a89
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/diffeditor/diffutils.cpp')
-rw-r--r-- | src/plugins/diffeditor/diffutils.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/plugins/diffeditor/diffutils.cpp b/src/plugins/diffeditor/diffutils.cpp index a9d9b11ae2..69ddbb9ba9 100644 --- a/src/plugins/diffeditor/diffutils.cpp +++ b/src/plugins/diffeditor/diffutils.cpp @@ -1025,10 +1025,16 @@ static bool detectIndexAndBinary(QStringRef patch, bool hasNewLine; *remainingPatch = patch; - if (remainingPatch->isEmpty() && (fileData->fileOperation == FileData::CopyFile - || fileData->fileOperation == FileData::RenameFile)) { - // in case of 100% similarity we don't have more lines in the patch - return true; + if (remainingPatch->isEmpty()) { + switch (fileData->fileOperation) { + case FileData::CopyFile: + case FileData::RenameFile: + case FileData::ChangeMode: + // in case of 100% similarity we don't have more lines in the patch + return true; + default: + break; + } } QStringRef afterNextLine; @@ -1151,8 +1157,6 @@ static bool detectFileData(QStringRef patch, QStringRef afterSecondLine; const QStringRef secondLine = readLine(afterDiffGit, &afterSecondLine, &hasNewLine); - if (!hasNewLine) - return false; // we need to have at least one more line if (secondLine.startsWith(QStringLiteral("new file mode "))) { fileData->fileOperation = FileData::NewFile; @@ -1165,7 +1169,7 @@ static bool detectFileData(QStringRef patch, // new mode readLine(afterSecondLine, &afterThirdLine, &hasNewLine); if (!hasNewLine) - return false; // we need to have at least one more line + fileData->fileOperation = FileData::ChangeMode; // TODO: validate new mode line *remainingPatch = afterThirdLine; |