{\r
SetFromUnknown(sUnknownPath);\r
m_Action=0;\r
+ m_Stage=0;\r
}\r
\r
-int CTGitPath::ParserAction(CString action)\r
+int CTGitPath::ParserAction(BYTE action)\r
{\r
- action=action.TrimLeft();\r
- TCHAR c=action.GetAt(0);\r
- if(c == _T('M'))\r
+ //action=action.TrimLeft();\r
+ //TCHAR c=action.GetAt(0);\r
+ if(action == 'M')\r
m_Action|= LOGACTIONS_MODIFIED;\r
- if(c == _T('R'))\r
+ if(action == 'R')\r
m_Action|= LOGACTIONS_REPLACED;\r
- if(c == _T('A'))\r
+ if(action == 'A')\r
m_Action|= LOGACTIONS_ADDED;\r
- if(c == _T('D'))\r
+ if(action == 'D')\r
m_Action|= LOGACTIONS_DELETED;\r
-\r
+ if(action == 'U')\r
+ m_Action|= LOGACTIONS_UNMERGED;\r
+ if(action == 'K')\r
+ m_Action|= LOGACTIONS_DELETED;\r
+ if(action == 'H')\r
+ m_Action|= LOGACTIONS_CACHE;\r
return m_Action;\r
}\r
void CTGitPath::SetFromGit(const char* pPath)\r
return m_bHasAdminDir;\r
\r
EnsureBackslashPathSet();\r
- m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory());\r
+ m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);\r
m_bHasAdminDirKnown = true;\r
return m_bHasAdminDir;\r
}\r
\r
+bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const\r
+{\r
+ if (m_bHasAdminDirKnown)\r
+ {\r
+ if (ProjectTopDir)\r
+ *ProjectTopDir = m_sProjectRoot;\r
+ return m_bHasAdminDir;\r
+ }\r
+\r
+ EnsureBackslashPathSet();\r
+ m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);\r
+ m_bHasAdminDirKnown = true;\r
+ if (ProjectTopDir)\r
+ *ProjectTopDir = m_sProjectRoot;\r
+ return m_bHasAdminDir;\r
+}\r
+\r
bool CTGitPath::IsAdminDir() const\r
{\r
if (m_bIsAdminDirKnown)\r
{\r
AddPath(firstEntry);\r
}\r
+int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool staged)\r
+{\r
+ int pos=0;\r
+ CString one;\r
+ CTGitPath path;\r
+ CString part;\r
+ while(pos>=0 && pos<out.size())\r
+ {\r
+ one.Empty();\r
+ path.Reset();\r
+\r
+ g_Git.StringAppend(&one,&out[pos],CP_OEMCP);\r
+ int tabstart=0;\r
+ path.m_Action=path.ParserAction(out[pos]);\r
+ one.Tokenize(_T("\t"),tabstart); \r
+\r
+ if(tabstart>=0)\r
+ path.SetFromGit(one.Right(one.GetLength()-tabstart));\r
+\r
+ tabstart=0;\r
+\r
+ part=one.Tokenize(_T(" "),tabstart); //Tag\r
+\r
+ part=one.Tokenize(_T(" "),tabstart); //Mode\r
+ \r
+ part=one.Tokenize(_T(" "),tabstart); //Hash\r
+\r
+ part=one.Tokenize(_T("\t"),tabstart); //Stage\r
+\r
+ path.m_Stage=_ttol(part);\r
+\r
+ this->AddPath(path);\r
+\r
+ pos=out.findNextString(pos);\r
+ }\r
+ return pos;\r
+}\r
int CTGitPathList::FillUnRev(int action,CTGitPathList *list)\r
{\r
int pos=0;\r
\r
if(list==NULL)\r
{\r
- cmd=_T("git.exe ls-files --exclude-standard --full-name --others");\r
+ cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");\r
cmd+=ignored;\r
\r
}\r
else\r
- { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others %s-- \"%s\""),\r
+ { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z %s-- \"%s\""),\r
ignored,\r
(*list)[i].GetWinPathString());\r
}\r
- \r
- CString out;\r
- g_Git.Run(cmd,&out);\r
\r
+ BYTE_VECTOR out;\r
+ out.clear();\r
+ g_Git.Run(cmd,&out);\r
+ \r
+ pos=0;\r
CString one;\r
- while( pos>=0 )\r
+ while( pos>=0 && pos<out.size())\r
{\r
- one=out.Tokenize(_T("\n"),pos);\r
+ one.Empty();\r
+ g_Git.StringAppend(&one,&out[pos],CP_OEMCP);\r
if(!one.IsEmpty())\r
{\r
//SetFromGit will clear all status\r
path.m_Action=action;\r
AddPath(path);\r
}\r
+ pos=out.findNextString(pos);\r
}\r
+\r
}\r
return 0;\r
}\r
-int CTGitPathList::ParserFromLog(CString &log)\r
+int CTGitPathList::ParserFromLog(BYTE_VECTOR &log)\r
{\r
this->Clear();\r
int pos=0;\r
- CString one;\r
+ //BYTE *p=&log[0];\r
+ //CString one;\r
CTGitPath path;\r
m_Action=0;\r
- while( pos>=0 )\r
+ while( pos>=0 && pos<log.size())\r
{\r
- one=log.Tokenize(_T("\n"),pos);\r
+ //one=log.Tokenize(_T("\n"),pos);\r
path.Reset();\r
- if(one[0]==_T(':'))\r
+ if(log[pos]=='\n')\r
+ pos++;\r
+\r
+ if(log[pos]==':')\r
{\r
- int tabstart=0;\r
- int actionstart=0;\r
- CString pathname;\r
- CString action;\r
- one.Tokenize(_T("\t"),tabstart);\r
- if(tabstart >0)\r
+ int end=log.find(0,pos);\r
+ int actionstart=-1;\r
+ int numfile=1;\r
+ int file1=-1,file2=-1;\r
+ if( end>0 )\r
{\r
- action=one.Left(tabstart);\r
- actionstart=action.ReverseFind(_T(' '));\r
- if(actionstart>0)\r
+ actionstart=log.find(' ',end-6);\r
+ pos=actionstart;\r
+ }\r
+ if( actionstart>0 )\r
+ {\r
+ actionstart++;\r
+\r
+ file1 = log.find(0,actionstart);\r
+ if( file1>=0 )\r
{\r
- action=action.Right(action.GetLength()-actionstart);\r
+ file1++;\r
+ pos=file1;\r
}\r
- pathname=one.Right(one.GetLength()-tabstart);\r
- \r
- CTGitPath *GitPath=LookForGitPath(pathname);\r
- \r
- if(GitPath)\r
+ if( log[actionstart] == 'C' || log[actionstart] == 'R' )\r
{\r
- this->m_Action|=GitPath->ParserAction(action); \r
- \r
- }else\r
- { \r
- int ac=path.ParserAction(action);\r
- if(ac & CTGitPath::LOGACTIONS_REPLACED)\r
+ file2=file1;\r
+ numfile=2;\r
+ file1 = log.find(0,file1);\r
+ if(file1>=0 )\r
{\r
- CString oldname;\r
- int oldnametab=pathname.Find(_T("\t"));\r
- if(oldnametab>0)\r
- path.SetFromGit(pathname.Right(pathname.GetLength()-oldnametab-1),&pathname.Left(oldnametab));\r
- else\r
- {\r
- ASSERT(FALSE);\r
- path.SetFromGit(pathname);\r
- }\r
- }else\r
- path.SetFromGit(pathname);\r
- path.m_Action=ac;\r
- //action must be set after setfromgit. SetFromGit will clear all status. \r
- this->m_Action|=ac;\r
- AddPath(path);\r
+ file1++;\r
+ pos=file1;\r
+ }\r
+\r
}\r
}\r
- \r
- }else\r
- {\r
+ \r
+ CString pathname1;\r
+ CString pathname2;\r
+\r
+ if( file1>=0 )\r
+ g_Git.StringAppend(&pathname1,&log[file1],CP_OEMCP);\r
+ if( file2>=0 )\r
+ g_Git.StringAppend(&pathname2,&log[file2],CP_OEMCP);\r
\r
+ CTGitPath *GitPath=LookForGitPath(pathname1);\r
+\r
+ if(GitPath)\r
+ {\r
+ this->m_Action|=GitPath->ParserAction( log[actionstart] ); \r
+ \r
+ }else\r
+ { \r
+ int ac=path.ParserAction(log[actionstart] );\r
+\r
+ path.SetFromGit(pathname1,&pathname2);\r
+ path.m_Action=ac;\r
+ //action must be set after setfromgit. SetFromGit will clear all status. \r
+ this->m_Action|=ac;\r
+ AddPath(path);\r
+ \r
+ }\r
+ \r
+ }else\r
+ { \r
int tabstart=0;\r
path.Reset();\r
- CString StatAdd=(one.Tokenize(_T("\t"),tabstart));\r
- if( tabstart< 0)\r
- break;\r
- CString StatDel=(one.Tokenize(_T("\t"),tabstart));\r
- //SetFromGit will reset all context of GitRev\r
- one=one.Right(one.GetLength()-tabstart);\r
- int rename=one.Find(_T(" => "));\r
- if(rename>0)\r
+ CString StatAdd;\r
+ CString StatDel;\r
+ CString file1;\r
+ CString file2;\r
+\r
+ tabstart=log.find('\t',pos);\r
+ if(tabstart >=0)\r
+ {\r
+ log[tabstart]=0;\r
+ g_Git.StringAppend(&StatAdd,&log[pos],CP_UTF8);\r
+ pos=tabstart+1;\r
+ }\r
+\r
+ tabstart=log.find('\t',pos);\r
+ if(tabstart >=0)\r
+ {\r
+ log[tabstart]=0;\r
+ \r
+ g_Git.StringAppend(&StatDel,&log[pos],CP_UTF8);\r
+ pos=tabstart+1;\r
+ }\r
+ \r
+ if(log[pos] == 0) //rename\r
{\r
- CString basepath;\r
- int include_left=one.Find(_T("{"));\r
- int include_right=one.Find(_T("}"),rename);\r
- if(include_left>0 && include_right>0 )\r
+ pos++;\r
+ g_Git.StringAppend(&file2,&log[pos],CP_OEMCP);\r
+ int sec=log.find(0,pos);\r
+ if(sec>=0)\r
{\r
- basepath=one.Left(include_left);\r
- CString newname=basepath+one.Mid(rename+4,include_right-rename-4)+one.Right(one.GetLength()-include_right-1);\r
- CString oldname=basepath+one.Mid(include_left+2,rename-include_left-2)+one.Right(one.GetLength()-include_right-1);\r
- path.SetFromGit(newname,&oldname );\r
- }else\r
- path.SetFromGit(one.Right(one.GetLength()-rename-4),&one.Left(rename));\r
+ sec++;\r
+ g_Git.StringAppend(&file1,&log[sec],CP_OEMCP);\r
+ }\r
+\r
}else\r
- path.SetFromGit(one);\r
- \r
+ {\r
+ g_Git.StringAppend(&file1,&log[pos],CP_OEMCP);\r
+ }\r
+ path.SetFromGit(file1,&file2);\r
+ \r
CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());\r
if(GitPath)\r
{\r
path.m_StatDel=StatDel;\r
AddPath(path);\r
}\r
- }\r
\r
+ }\r
+ pos=log.findNextString(pos);\r
}\r
return pos;\r
}\r
return _T("Added");\r
if(m_Action & CTGitPath::LOGACTIONS_DELETED)\r
return _T("Deleted");\r
+ if(m_Action & CTGitPath::LOGACTIONS_UNMERGED)\r
+ return _T("Conflict");\r
if(m_Action & CTGitPath::LOGACTIONS_MODIFIED)\r
return _T("Modified");\r
if(m_Action & CTGitPath::LOGACTIONS_REPLACED)\r