CString sDirName = path;\r
if (!bDir)\r
{\r
- sDirName = path.Left(path.ReverseFind('\\'));\r
+ sDirName = path.Left(path.ReverseFind(_T('\\')));\r
}\r
\r
// a .git dir or anything inside it should be left out, only interested in working copy files -- Myagi\r
}\r
}\r
\r
- do\r
+ for (;;)\r
{\r
if(PathFileExists(sDirName + _T("\\.git")))\r
{\r
{\r
*ProjectTopDir=sDirName;\r
// Make sure to add the trailing slash to root paths such as 'C:'\r
- if (sDirName.GetLength() == 2 && sDirName[1] == ':')\r
+ if (sDirName.GetLength() == 2 && sDirName[1] == _T(':'))\r
(*ProjectTopDir) += _T("\\");\r
}\r
return true;\r
}\r
- sDirName = sDirName.Left(sDirName.ReverseFind('\\'));\r
\r
- }while(sDirName.ReverseFind('\\')>0);\r
+ int x = sDirName.ReverseFind(_T('\\'));\r
+ if (x < 2)\r
+ break;\r
+\r
+ sDirName = sDirName.Left(x);\r
+ }\r
\r
return false;\r
\r
CString s = filepath.GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
+ if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
+ else\r
sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
}\r
\r
CString s = filepath.GetDirectory().GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
lpszSubPath = sSubPath;\r
+ // skip initial slash if necessary\r
+ if (*lpszSubPath == _T('\\'))\r
+ lpszSubPath++;\r
}\r
\r
//if (lpszSubPath) MessageBoxA(NULL, lpszSubPath, "BuildCache", MB_OK);\r
CString s = path.GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = CStringA(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
+ if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
+ else\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
}\r
\r
err = g_IndexFileMap.GetFileStatus(sProjectRoot,sSubPath,&statuskind);\r
CString s = path.GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
lpszSubPath = sSubPath;\r
+ // skip initial slash if necessary\r
+ if (*lpszSubPath == _T('\\'))\r
+ lpszSubPath++;\r
}\r
\r
#if 1\r
CString s = path.GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = CString(s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/));\r
+ if (sProjectRoot.GetLength() == 3 && sProjectRoot[1] == _T(':'))\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
+ else\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
}\r
\r
m_status.prop_status = m_status.text_status = git_wc_status_none;\r
CString s = path.GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
lpszSubPath = sSubPath;\r
+ // skip initial slash if necessary\r
+ if (*lpszSubPath == _T('\\'))\r
+ lpszSubPath++;\r
}\r
\r
// when recursion enabled, let wingit determine the recursive status for folders instead of enumerating all files here\r
CString s = m_directoryPath.GetDirectory().GetWinPathString();\r
if (s.GetLength() > sProjectRoot.GetLength())\r
{\r
- sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength() - 1/*otherwise it gets initial slash*/);\r
+ sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength());\r
lpszSubPath = sSubPath;\r
+ // skip initial slash if necessary\r
+ if (*lpszSubPath == _T('\\'))\r
+ lpszSubPath++;\r
}\r
//MessageBoxA(NULL, CStringA(sProjectRoot), sSubPath, MB_OK);\r
//OutputDebugStringA("###");OutputDebugStringW(sProjectRoot);OutputDebugStringA(" - ");OutputDebugStringA(sSubPath);OutputDebugStringA("\r\n");\r