summaryrefslogtreecommitdiff
path: root/src/plugins/diffeditor/diffutils.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2022-02-06 08:11:09 +0200
committerOrgad Shaneh <orgads@gmail.com>2022-02-07 12:56:40 +0000
commitbe1f89c93c00121c071b1ad01a7e1c9971c2f7b5 (patch)
treec1cdaea823b2b3ccf35d31fdb84e2ffe29e6c574 /src/plugins/diffeditor/diffutils.cpp
parent9f7c822197ba2c9f52cfe71dd175c7fea4b1740b (diff)
downloadqt-creator-be1f89c93c00121c071b1ad01a7e1c9971c2f7b5.tar.gz
DiffEditor: Fix git diff parsing for rename + mode change
Sample output: diff --git a/projects/cosign/build.sh b/projects/argo/build.sh old mode 100755 new mode 100644 similarity index 88% rename from projects/cosign/build.sh rename to projects/argo/build.sh index 87d865d2..14b8885c --- a/projects/cosign/build.sh +++ b/projects/argo/build.sh @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ################################################################################ +$SRC/cncf-fuzzing/projects/argo/build.sh + -compile_go_fuzzer github.com/sigstore/cosign/test FuzzGetPassword fuzz_getPassword gofuzz Change-Id: Ifa66dfdb80b309d72f524f15c681823ab7e133ba Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/diffeditor/diffutils.cpp')
-rw-r--r--src/plugins/diffeditor/diffutils.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/plugins/diffeditor/diffutils.cpp b/src/plugins/diffeditor/diffutils.cpp
index 9db8a09bc4..27ee1d3b48 100644
--- a/src/plugins/diffeditor/diffutils.cpp
+++ b/src/plugins/diffeditor/diffutils.cpp
@@ -997,12 +997,15 @@ static QList<FileData> readDiffPatch(StringView patch, bool *ok, QFutureInterfac
// The git diff patch format (CopyFile, RenameFile)
// 0. [some text lines to skip, e.g. show description]\n
// 1. diff --git a/[leftFileName] b/[rightFileName]\n
-// 2. [dis]similarity index [0-100]%\n
+// 2a. old mode [oldFileModeNumber]\n
+// new mode [newFileModeNumber]\n
+// 2b. <Nothing, only in case when no ChangeMode>
+// 3. [dis]similarity index [0-100]%\n
// [copy / rename] from [leftFileName]\n
// [copy / rename] to [rightFileName]
-// 3a. <Nothing more, only when similarity index was 100%>
-// 3b. index [leftIndexSha]..[rightIndexSha] <optionally: octalNumber>
-// 4. --- [leftFileNameOrDevNull]\n
+// 4a. <Nothing more, only when similarity index was 100%>
+// 4b. index [leftIndexSha]..[rightIndexSha] <optionally: octalNumber>
+// 5. --- [leftFileNameOrDevNull]\n
// +++ [rightFileNameOrDevNull]\n
// <Chunks>
@@ -1164,10 +1167,21 @@ static bool detectFileData(StringView patch, FileData *fileData, StringView *rem
} else {
// copy / rename
-
+ StringView afterModeOrSimilarity;
StringView afterSimilarity;
- // (dis)similarity index [0-100]%
- readLine(afterDiffGit, &afterSimilarity, &hasNewLine);
+ const StringView secondLine = readLine(afterDiffGit, &afterModeOrSimilarity, &hasNewLine);
+ if (secondLine.startsWith(QLatin1String("old mode "))) {
+ if (!hasNewLine)
+ return false;
+ readLine(afterModeOrSimilarity, &afterModeOrSimilarity, &hasNewLine); // new mode
+ if (!hasNewLine)
+ return false;
+ // (dis)similarity index [0-100]%
+ readLine(afterModeOrSimilarity, &afterSimilarity, &hasNewLine);
+ } else {
+ afterSimilarity = afterModeOrSimilarity;
+ }
+
if (!hasNewLine)
return false; // we need to have at least one more line