CPatch::CPatch(void)\r
{\r
m_nStrip = 0;\r
+ m_IsGitPatch = false;\r
}\r
\r
CPatch::~CPatch(void)\r
//now we got all the lines of the patch file\r
//in our array - parsing can start...\r
\r
+ for(nIndex=0;PatchLines.GetCount();nIndex++)\r
+ {\r
+ sLine = PatchLines.GetAt(nIndex);\r
+ if(sLine.Left(10).Compare(_T("diff --git")) == 0)\r
+ {\r
+ this->m_IsGitPatch=true;\r
+ break;\r
+ }\r
+ }\r
+\r
//first, skip possible garbage at the beginning\r
//garbage is finished when a line starts with "Index: "\r
//and the next line consists of only "=" characters\r
- for (; nIndex<PatchLines.GetCount(); nIndex++)\r
+ for (nIndex=0; nIndex<PatchLines.GetCount(); nIndex++)\r
{\r
sLine = PatchLines.GetAt(nIndex);\r
if (sLine.Left(4).Compare(_T("--- "))==0)\r
if ((nIndex+1)<PatchLines.GetCount())\r
{\r
sLine = PatchLines.GetAt(nIndex+1);\r
+\r
+ if(sLine.IsEmpty()&&m_IsGitPatch)\r
+ continue;\r
+\r
sLine.Replace(_T("="), _T(""));\r
if (sLine.IsEmpty())\r
break;\r
ending = EOL_AUTOLINE;\r
if (state == 0)\r
{\r
- if ((sLine.Left(4).Compare(_T("--- "))==0)&&(sLine.Find('\t') >= 0))\r
+ if ((sLine.Left(4).Compare(_T("--- "))==0)&&((sLine.Find('\t') >= 0)||this->m_IsGitPatch))\r
{\r
state = 2;\r
if (chunks)\r
m_arFileDiffs.Add(chunks);\r
}\r
chunks = new Chunks();\r
+ \r
int nTab = sLine.Find('\t');\r
+\r
+ int filestart = 4;\r
+ if(m_IsGitPatch)\r
+ {\r
+ nTab=sLine.GetLength();\r
+ filestart = 6;\r
+ }\r
+\r
if (nTab >= 0)\r
{\r
- chunks->sFilePath = sLine.Mid(4, nTab-4).Trim();\r
+ chunks->sFilePath = sLine.Mid(filestart, nTab-filestart).Trim();\r
}\r
}\r
}\r