Fixed issue #3261: Review/Apply single patch does not work anymore if patch does...
[TortoiseGit.git] / test / UnitTests / resources / patches / git-diff.patch
blob9d0b94544a7dcc36759cda3c94b3a7709800b8d6
1 appveyor.yml | 30 ------------------------------
2 src/Git/GitPatch.cpp | 4 ++--
3 src/TortoiseMerge/Patch.cpp | 16 +++++++++++-----
4 test/UnitTests/UnitTests.vcxproj | 3 +++
5 test/UnitTests/UnitTests.vcxproj.filters | 9 +++++++++
6 wusel dusel.txt | 5 +++++
7 6 files changed, 30 insertions(+), 37 deletions(-)
9 diff --git a/appveyor.yml b/appveyor.yml
10 deleted file mode 100644
11 index e6b688767..000000000
12 --- a/appveyor.yml
13 +++ /dev/null
14 @@ -1,30 +0,0 @@
15 -version: '{branch}.{build}'
16 -skip_tags: true
17 -image: Visual Studio 2017
18 -init:
19 -- git version
20 -build_script:
21 -- git submodule update --init -- ext/googletest ext/libgit2 ext/simpleini ext/tgit ext/zlib
22 -- cd ext\libgit2
23 -- git config --global user.email "dummy@example.com"
24 -- git config --global user.name "Dummy Name"
25 -- for %%G in (..\libgit2-*.patch) do ( type %%G | git am )
26 -- git config --unset --global user.email
27 -- git config --unset --global user.name
28 -- cd ..\..
29 -- msbuild "src\TortoiseGit.sln" /t:"test\UnitTests" /m /verbosity:minimal /p:Configuration=Debug /p:PlatformToolset=v141 /p:Platform=x64 /maxcpucount /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
30 -- msbuild "src\TortoiseGit.sln" /t:"test\UnitTests" /m /verbosity:minimal /p:Configuration=Debug /p:PlatformToolset=v141 /p:Platform=Win32 /maxcpucount /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
31 -test_script:
32 -- bin\Debug\bin\tests.exe
33 -- bin\Debug64\bin\tests.exe
34 -- reg add HKCU\Software\TortoiseGit /v CygwinHack /t REG_DWORD /f /d 1
35 -- reg add HKCU\Software\TortoiseGit /v MSysGit /t REG_SZ /f /d "c:\cygwin\bin"
36 -- set HOME=%USERPROFILE%
37 -- c:\cygwin\bin\git version
38 -- bin\Debug\bin\tests.exe
39 -- bin\Debug64\bin\tests.exe
40 -- reg delete HKCU\Software\TortoiseGit /v CygwinHack /f
41 -- reg delete HKCU\Software\TortoiseGit /v MSysGit /f
42 -- msbuild "src\TortoiseGit.sln" /t:"GitWCRev" /t:"GitWCRevCom" /t:"TortoiseGitSetup\CustomActions" /t:"TortoiseGitSetup\RestartExplorer" /t:"ext\Crash-Server\CrashServerSDK\CrashHandler" /t:"ext\Crash-Server\CrashServerSDK\SendRpt" /m /verbosity:minimal /p:Configuration=Release /p:Platform=x64 /maxcpucount /p:PlatformToolset=v141 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
43 -- git submodule update --init -- ext/apr ext/apr-util ext/editorconfig ext/pcre
44 -- msbuild "src\TortoiseGit.sln" /t:"TGitCache" /t:"TortoiseGitBlame" /t:"TortoiseGitIDiff" /t:"TortoiseGitMerge" /t:"TortoiseGitPlink" /t:"TortoiseGitProc" /t:"TortoiseGitStub" /t:"TortoiseGitUDiff" /t:"TortoiseShell" /t:"SshAskPass" /t:"tgittouch" /t:"GitWCRev" /t:"GitWCRevCom" /m /verbosity:minimal /p:Configuration=Debug /p:Platform=x64 /maxcpucount /p:PlatformToolset=v141 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
45 diff --git a/src/Git/GitPatch.cpp b/src/Git/GitPatch.cpp
46 index c85b034cd..9f99b1cc4 100644
47 --- a/src/Git/GitPatch.cpp
48 +++ b/src/Git/GitPatch.cpp
49 @@ -1,4 +1,4 @@
50 -// TortoiseGitMerge - a Diff/Patch program
51 +// TortoiseGitMerge - a Diff/Patch program
53 // Copyright (C) 2012-2013, 2015-2018 - TortoiseGit
54 // Copyright (C) 2010-2012 - TortoiseSVN
55 @@ -155,7 +155,7 @@ bool GitPatch::PatchFile(int nIndex, CString &datapath)
56 CString sVersion = m_patch.GetRevision(nIndex);
58 CString sBaseFile;
59 - if (sVersion == L"0000000" || sFilePath == L"NUL")
60 + if ((sVersion.GetLength() >= 7 && wcsncmp(sVersion, GIT_REV_ZERO, sVersion.GetLength()) == 0) || sFilePath == L"NUL")
61 sBaseFile = CTempFiles::Instance().GetTempFilePathString();
62 else
64 diff --git a/src/TortoiseMerge/Patch.cpp b/src/TortoiseMerge/Patch.cpp
65 index a4cd5787e..af90b981e 100644
66 --- a/src/TortoiseMerge/Patch.cpp
67 +++ b/src/TortoiseMerge/Patch.cpp
68 @@ -104,13 +104,15 @@ BOOL CPatch::ParsePatchFile(CFileTextLines &PatchLines)
69 case 1:
71 //index
72 - if (CStringUtils::StartsWith(sLine, L"index"))
73 + if (CStringUtils::StartsWith(sLine, L"index "))
75 - int dotstart = sLine.Find(L"..");
76 - if(dotstart>=0 && chunks)
77 + int dotstart = sLine.Find(L"..", (int)wcslen(L"index "));
78 + if (dotstart > 0 && chunks)
80 - chunks->sRevision = sLine.Mid(dotstart-7,7);
81 - chunks->sRevision2 = sLine.Mid(dotstart+2,7);
82 + chunks->sRevision = sLine.Mid((int)wcslen(L"index "), dotstart - (int)wcslen(L"index "));
83 + int end = sLine.Find(L' ', dotstart + 2);
84 + if (end > 0)
85 + chunks->sRevision2 = sLine.Mid(dotstart + 2, end - (dotstart + 2));
87 break;
89 @@ -400,7 +402,9 @@ errorcleanup:
91 BOOL CPatch::OpenUnifiedDiffFile(const CString& filename)
93 +#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
94 CCrashReport::Instance().AddFile2(filename, nullptr, L"unified diff file", CR_AF_MAKE_FILE_COPY);
95 +#endif
97 CFileTextLines PatchLines;
98 if (!PatchLines.Load(filename))
99 @@ -488,10 +492,12 @@ int CPatch::PatchFile(const int strip, int nIndex, const CString& sPatchPath, co
101 CString sLine;
102 CString sPatchFile = sBaseFile.IsEmpty() ? sPath : sBaseFile;
103 +#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
104 if (PathFileExists(sPatchFile))
106 CCrashReport::Instance().AddFile2(sPatchFile, nullptr, L"File to patch", CR_AF_MAKE_FILE_COPY);
108 +#endif
109 CFileTextLines PatchLines;
110 CFileTextLines PatchLinesResult;
111 PatchLines.Load(sPatchFile);
112 diff --git a/test/UnitTests/UnitTests.vcxproj b/test/UnitTests/UnitTests.vcxproj
113 index 864f9caa7..3bb663bfb 100644
114 --- a/test/UnitTests/UnitTests.vcxproj
115 +++ b/test/UnitTests/UnitTests.vcxproj
116 @@ -76,6 +76,7 @@
117 <ClInclude Include="..\..\src\Git\MassiveGitTaskBase.h" />
118 <ClInclude Include="..\..\src\Git\TGitPath.h" />
119 <ClInclude Include="..\..\src\TortoiseMerge\FileTextLines.h" />
120 + <ClInclude Include="..\..\src\TortoiseMerge\Patch.h" />
121 <ClInclude Include="..\..\src\TortoiseProc\gitlogcache.h" />
122 <ClInclude Include="..\..\src\TortoiseProc\lanes.h" />
123 <ClInclude Include="..\..\src\TortoiseProc\LogDlgHelper.h" />
124 @@ -124,6 +125,7 @@
125 <ClCompile Include="..\..\src\Git\MassiveGitTaskBase.cpp" />
126 <ClCompile Include="..\..\src\Git\TGitPath.cpp" />
127 <ClCompile Include="..\..\src\TortoiseMerge\FileTextLines.cpp" />
128 + <ClCompile Include="..\..\src\TortoiseMerge\Patch.cpp" />
129 <ClCompile Include="..\..\src\TortoiseProc\GitLogCache.cpp" />
130 <ClCompile Include="..\..\src\TortoiseProc\lanes.cpp" />
131 <ClCompile Include="..\..\src\TortoiseProc\LogDataVector.cpp" />
132 @@ -163,6 +165,7 @@
133 <ClCompile Include="libgitTest.cpp" />
134 <ClCompile Include="LogDataVectorTest.cpp" />
135 <ClCompile Include="LruCacheTest.cpp" />
136 + <ClCompile Include="PatchTest.cpp" />
137 <ClCompile Include="PathUtilsTest.cpp" />
138 <ClCompile Include="PersonalDictionaryTest.cpp" />
139 <ClCompile Include="ProjectPropertiesTest.cpp" />
140 diff --git a/test/UnitTests/UnitTests.vcxproj.filters b/test/UnitTests/UnitTests.vcxproj.filters
141 index 7644bea3b..fd436f9bb 100644
142 --- a/test/UnitTests/UnitTests.vcxproj.filters
143 +++ b/test/UnitTests/UnitTests.vcxproj.filters
144 @@ -170,6 +170,9 @@
145 <ClInclude Include="..\..\src\GitWCRev\status.h">
146 <Filter>GitWCRev</Filter>
147 </ClInclude>
148 + <ClInclude Include="..\..\src\TortoiseMerge\Patch.h">
149 + <Filter>TortoiseGitMerge</Filter>
150 + </ClInclude>
151 </ItemGroup>
152 <ItemGroup>
153 <ClCompile Include="stdafx.cpp">
154 @@ -358,5 +361,11 @@
155 <ClCompile Include="GitWCRevStatusTest.cpp">
156 <Filter>Source Files</Filter>
157 </ClCompile>
158 + <ClCompile Include="..\..\src\TortoiseMerge\Patch.cpp">
159 + <Filter>TortoiseGitMerge</Filter>
160 + </ClCompile>
161 + <ClCompile Include="PatchTest.cpp">
162 + <Filter>Source Files</Filter>
163 + </ClCompile>
164 </ItemGroup>
165 </Project>
166 \ No newline at end of file
167 diff --git a/wusel dusel.txt b/wusel dusel.txt
168 new file mode 100644
169 index 000000000..b936c8026
170 --- /dev/null
171 +++ b/wusel dusel.txt
172 @@ -0,0 +1,5 @@
173 +new file
174 +dfkdsf#dsf
177 +dsf
178 \ No newline at end of file