CTGitPath: remove files in correct order
[TortoiseGit.git] / src / Git / TGitPath.cpp
blobcc868bf42bde0e283d42f60ebec4a061b0df8fa3
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2010-2012 Sven Strickroth <email@cs-ware.de>
5 // Copyright (C) 2003-2008 - TortoiseSVN
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "StdAfx.h"
22 #include "TGitPath.h"
23 #include "UnicodeUtils.h"
24 #include "GitAdminDir.h"
25 #include "PathUtils.h"
26 #include <regex>
27 #include "git.h"
28 #include "Globals.h"
29 #include "../Resources/LoglistCommonResource.h"
31 #if defined(_MFC_VER)
32 //#include "MessageBox.h"
33 //#include "AppUtils.h"
34 #endif
36 #ifndef ASSERT
37 #define ASSERT()
38 #endif
39 using namespace std;
40 extern CGit g_Git;
42 CTGitPath::CTGitPath(void)
43 : m_bDirectoryKnown(false)
44 , m_bIsDirectory(false)
45 , m_bIsURL(false)
46 , m_bURLKnown(false)
47 , m_bHasAdminDirKnown(false)
48 , m_bHasAdminDir(false)
49 , m_bIsValidOnWindowsKnown(false)
50 , m_bIsValidOnWindows(false)
51 , m_bIsReadOnly(false)
52 , m_bIsAdminDirKnown(false)
53 , m_bIsAdminDir(false)
54 , m_bExists(false)
55 , m_bExistsKnown(false)
56 , m_bLastWriteTimeKnown(0)
57 , m_lastWriteTime(0)
58 , m_customData(NULL)
59 , m_bIsSpecialDirectoryKnown(false)
60 , m_bIsSpecialDirectory(false)
61 , m_bIsWCRootKnown(false)
62 , m_bIsWCRoot(false)
64 m_Action=0;
65 m_ParentNo=0;
68 CTGitPath::~CTGitPath(void)
71 // Create a TGitPath object from an unknown path type (same as using SetFromUnknown)
72 CTGitPath::CTGitPath(const CString& sUnknownPath) :
73 m_bDirectoryKnown(false)
74 , m_bIsDirectory(false)
75 , m_bIsURL(false)
76 , m_bURLKnown(false)
77 , m_bHasAdminDirKnown(false)
78 , m_bHasAdminDir(false)
79 , m_bIsValidOnWindowsKnown(false)
80 , m_bIsValidOnWindows(false)
81 , m_bIsReadOnly(false)
82 , m_bIsAdminDirKnown(false)
83 , m_bIsAdminDir(false)
84 , m_bExists(false)
85 , m_bExistsKnown(false)
86 , m_bLastWriteTimeKnown(0)
87 , m_lastWriteTime(0)
88 , m_customData(NULL)
89 , m_bIsSpecialDirectoryKnown(false)
90 , m_bIsSpecialDirectory(false)
91 , m_bIsWCRootKnown(false)
92 , m_bIsWCRoot(false)
94 SetFromUnknown(sUnknownPath);
95 m_Action=0;
96 m_Stage=0;
97 m_ParentNo=0;
100 int CTGitPath::ParserAction(BYTE action)
102 //action=action.TrimLeft();
103 //TCHAR c=action.GetAt(0);
104 if(action == 'M')
105 m_Action|= LOGACTIONS_MODIFIED;
106 if(action == 'R')
107 m_Action|= LOGACTIONS_REPLACED;
108 if(action == 'A')
109 m_Action|= LOGACTIONS_ADDED;
110 if(action == 'D')
111 m_Action|= LOGACTIONS_DELETED;
112 if(action == 'U')
113 m_Action|= LOGACTIONS_UNMERGED;
114 if(action == 'K')
115 m_Action|= LOGACTIONS_DELETED;
116 if(action == 'H')
117 m_Action|= LOGACTIONS_CACHE;
118 if(action == 'C' )
119 m_Action|= LOGACTIONS_COPY;
121 return m_Action;
123 void CTGitPath::SetFromGit(const char* pPath)
125 Reset();
126 if (pPath == NULL)
127 return;
128 int len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, NULL, 0);
129 if (len)
131 len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, m_sFwdslashPath.GetBuffer(len+1), len+1);
132 m_sFwdslashPath.ReleaseBuffer(len-1);
134 SanitizeRootPath(m_sFwdslashPath, true);
137 void CTGitPath::SetFromGit(const char* pPath, bool bIsDirectory)
139 SetFromGit(pPath);
140 m_bDirectoryKnown = true;
141 m_bIsDirectory = bIsDirectory;
144 void CTGitPath::SetFromGit(const TCHAR* pPath, bool bIsDirectory)
146 Reset();
147 if (pPath)
149 m_sFwdslashPath = pPath;
150 SanitizeRootPath(m_sFwdslashPath, true);
152 m_bDirectoryKnown = true;
153 m_bIsDirectory = bIsDirectory;
156 void CTGitPath::SetFromGit(const CString& sPath,CString *oldpath)
158 Reset();
159 m_sFwdslashPath = sPath;
160 SanitizeRootPath(m_sFwdslashPath, true);
161 if(oldpath)
162 m_sOldFwdslashPath = *oldpath;
165 void CTGitPath::SetFromWin(LPCTSTR pPath)
167 Reset();
168 m_sBackslashPath = pPath;
169 SanitizeRootPath(m_sBackslashPath, false);
170 ATLASSERT(m_sBackslashPath.Find('/')<0);
172 void CTGitPath::SetFromWin(const CString& sPath)
174 Reset();
175 m_sBackslashPath = sPath;
176 SanitizeRootPath(m_sBackslashPath, false);
178 void CTGitPath::SetFromWin(const CString& sPath, bool bIsDirectory)
180 Reset();
181 m_sBackslashPath = sPath;
182 m_bIsDirectory = bIsDirectory;
183 m_bDirectoryKnown = true;
184 SanitizeRootPath(m_sBackslashPath, false);
186 void CTGitPath::SetFromUnknown(const CString& sPath)
188 Reset();
189 // Just set whichever path we think is most likely to be used
190 // GitAdminDir admin;
191 // CString p;
192 // if(admin.HasAdminDir(sPath,&p))
193 // SetFwdslashPath(sPath.Right(sPath.GetLength()-p.GetLength()));
194 // else
195 SetFwdslashPath(sPath);
198 LPCTSTR CTGitPath::GetWinPath() const
200 if(IsEmpty())
202 return _T("");
204 if(m_sBackslashPath.IsEmpty())
206 SetBackslashPath(m_sFwdslashPath);
208 return m_sBackslashPath;
210 // This is a temporary function, to be used during the migration to
211 // the path class. Ultimately, functions consuming paths should take a CTGitPath&, not a CString
212 const CString& CTGitPath::GetWinPathString() const
214 if(m_sBackslashPath.IsEmpty())
216 SetBackslashPath(m_sFwdslashPath);
218 return m_sBackslashPath;
221 const CString& CTGitPath::GetGitPathString() const
223 if(m_sFwdslashPath.IsEmpty())
225 SetFwdslashPath(m_sBackslashPath);
227 return m_sFwdslashPath;
230 const CString &CTGitPath::GetGitOldPathString() const
232 return m_sOldFwdslashPath;
234 #if 0
235 const char* CTGitPath::GetGitApiPath(apr_pool_t *pool) const
237 // This funny-looking 'if' is to avoid a subtle problem with empty paths, whereby
238 // each call to GetGitApiPath returns a different pointer value.
239 // If you made multiple calls to GetGitApiPath on the same string, only the last
240 // one would give you a valid pointer to an empty string, because each
241 // call would invalidate the previous call's return.
242 if(IsEmpty())
244 return "";
246 if(m_sFwdslashPath.IsEmpty())
248 SetFwdslashPath(m_sBackslashPath);
250 if(m_sUTF8FwdslashPath.IsEmpty())
252 SetUTF8FwdslashPath(m_sFwdslashPath);
254 if (svn_path_is_url(m_sUTF8FwdslashPath))
256 m_sUTF8FwdslashPathEscaped = CPathUtils::PathEscape(m_sUTF8FwdslashPath);
257 m_sUTF8FwdslashPathEscaped.Replace("file:////", "file:///\\");
258 m_sUTF8FwdslashPathEscaped = svn_path_canonicalize(m_sUTF8FwdslashPathEscaped, pool);
259 return m_sUTF8FwdslashPathEscaped;
261 m_sUTF8FwdslashPath = svn_path_canonicalize(m_sUTF8FwdslashPath, pool);
263 return m_sUTF8FwdslashPath;
265 #endif
267 const CString& CTGitPath::GetUIPathString() const
269 if (m_sUIPath.IsEmpty())
271 #if defined(_MFC_VER)
272 //BUGBUG HORRIBLE!!! - CPathUtils::IsEscaped doesn't need to be MFC-only
273 if (IsUrl())
275 m_sUIPath = CPathUtils::PathUnescape(GetGitPathString());
276 m_sUIPath.Replace(_T("file:////"), _T("file:///\\"));
279 else
280 #endif
282 m_sUIPath = GetWinPathString();
285 return m_sUIPath;
288 void CTGitPath::SetFwdslashPath(const CString& sPath) const
290 m_sFwdslashPath = sPath;
291 m_sFwdslashPath.Replace('\\', '/');
293 // We don't leave a trailing /
294 m_sFwdslashPath.TrimRight('/');
296 SanitizeRootPath(m_sFwdslashPath, true);
298 m_sFwdslashPath.Replace(_T("file:////"), _T("file:///\\"));
300 m_sUTF8FwdslashPath.Empty();
303 void CTGitPath::SetBackslashPath(const CString& sPath) const
305 m_sBackslashPath = sPath;
306 m_sBackslashPath.Replace('/', '\\');
307 m_sBackslashPath.TrimRight('\\');
308 SanitizeRootPath(m_sBackslashPath, false);
311 void CTGitPath::SetUTF8FwdslashPath(const CString& sPath) const
313 m_sUTF8FwdslashPath = CUnicodeUtils::GetUTF8(sPath);
316 void CTGitPath::SanitizeRootPath(CString& sPath, bool bIsForwardPath) const
318 // Make sure to add the trailing slash to root paths such as 'C:'
319 if (sPath.GetLength() == 2 && sPath[1] == ':')
321 sPath += (bIsForwardPath) ? _T("/") : _T("\\");
325 bool CTGitPath::IsUrl() const
327 #if 0
328 if (!m_bURLKnown)
330 EnsureFwdslashPathSet();
331 if(m_sUTF8FwdslashPath.IsEmpty())
333 SetUTF8FwdslashPath(m_sFwdslashPath);
335 m_bIsURL = !!svn_path_is_url(m_sUTF8FwdslashPath);
336 m_bURLKnown = true;
338 return m_bIsURL;
339 #endif
340 return false;
343 bool CTGitPath::IsDirectory() const
345 if(!m_bDirectoryKnown)
347 UpdateAttributes();
349 return m_bIsDirectory;
352 bool CTGitPath::Exists() const
354 if (!m_bExistsKnown)
356 UpdateAttributes();
358 return m_bExists;
361 bool CTGitPath::Delete(bool bTrash) const
363 EnsureBackslashPathSet();
364 ::SetFileAttributes(m_sBackslashPath, FILE_ATTRIBUTE_NORMAL);
365 bool bRet = false;
366 if (Exists())
368 if ((bTrash)||(IsDirectory()))
370 TCHAR * buf = new TCHAR[m_sBackslashPath.GetLength()+2];
371 _tcscpy_s(buf, m_sBackslashPath.GetLength()+2, m_sBackslashPath);
372 buf[m_sBackslashPath.GetLength()] = 0;
373 buf[m_sBackslashPath.GetLength()+1] = 0;
374 SHFILEOPSTRUCT shop = {0};
375 shop.wFunc = FO_DELETE;
376 shop.pFrom = buf;
377 shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT;
378 if (bTrash)
379 shop.fFlags |= FOF_ALLOWUNDO;
380 bRet = (SHFileOperation(&shop) == 0);
381 delete [] buf;
383 else
385 bRet = !!::DeleteFile(m_sBackslashPath);
388 m_bExists = false;
389 m_bExistsKnown = true;
390 return bRet;
393 __int64 CTGitPath::GetLastWriteTime() const
395 if(!m_bLastWriteTimeKnown)
397 UpdateAttributes();
399 return m_lastWriteTime;
402 bool CTGitPath::IsReadOnly() const
404 if(!m_bLastWriteTimeKnown)
406 UpdateAttributes();
408 return m_bIsReadOnly;
411 void CTGitPath::UpdateAttributes() const
413 EnsureBackslashPathSet();
414 WIN32_FILE_ATTRIBUTE_DATA attribs;
415 if(GetFileAttributesEx(m_sBackslashPath, GetFileExInfoStandard, &attribs))
417 m_bIsDirectory = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
418 m_lastWriteTime = *(__int64*)&attribs.ftLastWriteTime;
419 m_bIsReadOnly = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_READONLY);
420 m_bExists = true;
422 else
424 DWORD err = GetLastError();
425 if ((err == ERROR_FILE_NOT_FOUND)||(err == ERROR_PATH_NOT_FOUND)||(err == ERROR_INVALID_NAME))
427 m_bIsDirectory = false;
428 m_lastWriteTime = 0;
429 m_bExists = false;
431 else
433 m_bIsDirectory = false;
434 m_lastWriteTime = 0;
435 m_bExists = true;
436 return;
439 m_bDirectoryKnown = true;
440 m_bLastWriteTimeKnown = true;
441 m_bExistsKnown = true;
444 CTGitPath CTGitPath::GetSubPath(const CTGitPath &root)
446 CTGitPath path;
448 if(GetWinPathString().Left(root.GetWinPathString().GetLength()) == root.GetWinPathString())
450 CString str=GetWinPathString();
451 path.SetFromWin(str.Right(str.GetLength()-root.GetWinPathString().GetLength()-1));
453 return path;
456 void CTGitPath::EnsureBackslashPathSet() const
458 if(m_sBackslashPath.IsEmpty())
460 SetBackslashPath(m_sFwdslashPath);
461 ATLASSERT(IsEmpty() || !m_sBackslashPath.IsEmpty());
464 void CTGitPath::EnsureFwdslashPathSet() const
466 if(m_sFwdslashPath.IsEmpty())
468 SetFwdslashPath(m_sBackslashPath);
469 ATLASSERT(IsEmpty() || !m_sFwdslashPath.IsEmpty());
474 // Reset all the caches
475 void CTGitPath::Reset()
477 m_bDirectoryKnown = false;
478 m_bURLKnown = false;
479 m_bLastWriteTimeKnown = false;
480 m_bHasAdminDirKnown = false;
481 m_bIsValidOnWindowsKnown = false;
482 m_bIsAdminDirKnown = false;
483 m_bExistsKnown = false;
484 m_bIsSpecialDirectoryKnown = false;
485 m_bIsSpecialDirectory = false;
487 m_sBackslashPath.Empty();
488 m_sFwdslashPath.Empty();
489 m_sUTF8FwdslashPath.Empty();
490 this->m_Action=0;
491 this->m_StatAdd=_T("");
492 this->m_StatDel=_T("");
493 m_ParentNo=0;
494 ATLASSERT(IsEmpty());
497 CTGitPath CTGitPath::GetDirectory() const
499 if ((IsDirectory())||(!Exists()))
501 return *this;
503 return GetContainingDirectory();
506 CTGitPath CTGitPath::GetContainingDirectory() const
508 EnsureBackslashPathSet();
510 CString sDirName = m_sBackslashPath.Left(m_sBackslashPath.ReverseFind('\\'));
511 if(sDirName.GetLength() == 2 && sDirName[1] == ':')
513 // This is a root directory, which needs a trailing slash
514 sDirName += '\\';
515 if(sDirName == m_sBackslashPath)
517 // We were clearly provided with a root path to start with - we should return nothing now
518 sDirName.Empty();
521 if(sDirName.GetLength() == 1 && sDirName[0] == '\\')
523 // We have an UNC path and we already are the root
524 sDirName.Empty();
526 CTGitPath retVal;
527 retVal.SetFromWin(sDirName);
528 return retVal;
531 CString CTGitPath::GetRootPathString() const
533 EnsureBackslashPathSet();
534 CString workingPath = m_sBackslashPath;
535 LPTSTR pPath = workingPath.GetBuffer(MAX_PATH); // MAX_PATH ok here.
536 ATLVERIFY(::PathStripToRoot(pPath));
537 workingPath.ReleaseBuffer();
538 return workingPath;
542 CString CTGitPath::GetFilename() const
544 //ATLASSERT(!IsDirectory());
545 return GetFileOrDirectoryName();
548 CString CTGitPath::GetFileOrDirectoryName() const
550 EnsureBackslashPathSet();
551 return m_sBackslashPath.Mid(m_sBackslashPath.ReverseFind('\\')+1);
554 CString CTGitPath::GetUIFileOrDirectoryName() const
556 GetUIPathString();
557 return m_sUIPath.Mid(m_sUIPath.ReverseFind('\\')+1);
560 CString CTGitPath::GetFileExtension() const
562 if(!IsDirectory())
564 EnsureBackslashPathSet();
565 int dotPos = m_sBackslashPath.ReverseFind('.');
566 int slashPos = m_sBackslashPath.ReverseFind('\\');
567 if (dotPos > slashPos)
568 return m_sBackslashPath.Mid(dotPos);
570 return CString();
572 CString CTGitPath::GetBaseFilename() const
574 int dot;
575 CString filename=GetFilename();
576 dot = filename.ReverseFind(_T('.'));
577 if(dot>0)
578 return filename.Left(dot);
579 else
580 return filename;
583 bool CTGitPath::ArePathStringsEqual(const CString& sP1, const CString& sP2)
585 int length = sP1.GetLength();
586 if(length != sP2.GetLength())
588 // Different lengths
589 return false;
591 // We work from the end of the strings, because path differences
592 // are more likely to occur at the far end of a string
593 LPCTSTR pP1Start = sP1;
594 LPCTSTR pP1 = pP1Start+(length-1);
595 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
596 while(length-- > 0)
598 if(_totlower(*pP1--) != _totlower(*pP2--))
600 return false;
603 return true;
606 bool CTGitPath::ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2)
608 int length = sP1.GetLength();
609 if(length != sP2.GetLength())
611 // Different lengths
612 return false;
614 // We work from the end of the strings, because path differences
615 // are more likely to occur at the far end of a string
616 LPCTSTR pP1Start = sP1;
617 LPCTSTR pP1 = pP1Start+(length-1);
618 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
619 while(length-- > 0)
621 if((*pP1--) != (*pP2--))
623 return false;
626 return true;
629 bool CTGitPath::IsEmpty() const
631 // Check the backward slash path first, since the chance that this
632 // one is set is higher. In case of a 'false' return value it's a little
633 // bit faster.
634 return m_sBackslashPath.IsEmpty() && m_sFwdslashPath.IsEmpty();
637 // Test if both paths refer to the same item
638 // Ignores case and slash direction
639 bool CTGitPath::IsEquivalentTo(const CTGitPath& rhs) const
641 // Try and find a slash direction which avoids having to convert
642 // both filenames
643 if(!m_sBackslashPath.IsEmpty())
645 // *We've* got a \ path - make sure that the RHS also has a \ path
646 rhs.EnsureBackslashPathSet();
647 return ArePathStringsEqualWithCase(m_sBackslashPath, rhs.m_sBackslashPath);
649 else
651 // Assume we've got a fwdslash path and make sure that the RHS has one
652 rhs.EnsureFwdslashPathSet();
653 return ArePathStringsEqualWithCase(m_sFwdslashPath, rhs.m_sFwdslashPath);
657 bool CTGitPath::IsEquivalentToWithoutCase(const CTGitPath& rhs) const
659 // Try and find a slash direction which avoids having to convert
660 // both filenames
661 if(!m_sBackslashPath.IsEmpty())
663 // *We've* got a \ path - make sure that the RHS also has a \ path
664 rhs.EnsureBackslashPathSet();
665 return ArePathStringsEqual(m_sBackslashPath, rhs.m_sBackslashPath);
667 else
669 // Assume we've got a fwdslash path and make sure that the RHS has one
670 rhs.EnsureFwdslashPathSet();
671 return ArePathStringsEqual(m_sFwdslashPath, rhs.m_sFwdslashPath);
675 bool CTGitPath::IsAncestorOf(const CTGitPath& possibleDescendant) const
677 possibleDescendant.EnsureBackslashPathSet();
678 EnsureBackslashPathSet();
680 bool bPathStringsEqual = ArePathStringsEqual(m_sBackslashPath, possibleDescendant.m_sBackslashPath.Left(m_sBackslashPath.GetLength()));
681 if (m_sBackslashPath.GetLength() >= possibleDescendant.GetWinPathString().GetLength())
683 return bPathStringsEqual;
686 return (bPathStringsEqual &&
687 ((possibleDescendant.m_sBackslashPath[m_sBackslashPath.GetLength()] == '\\')||
688 (m_sBackslashPath.GetLength()==3 && m_sBackslashPath[1]==':')));
691 // Get a string representing the file path, optionally with a base
692 // section stripped off the front.
693 CString CTGitPath::GetDisplayString(const CTGitPath* pOptionalBasePath /* = NULL*/) const
695 EnsureFwdslashPathSet();
696 if(pOptionalBasePath != NULL)
698 // Find the length of the base-path without having to do an 'ensure' on it
699 int baseLength = max(pOptionalBasePath->m_sBackslashPath.GetLength(), pOptionalBasePath->m_sFwdslashPath.GetLength());
701 // Now, chop that baseLength of the front of the path
702 return m_sFwdslashPath.Mid(baseLength).TrimLeft('/');
704 return m_sFwdslashPath;
707 int CTGitPath::Compare(const CTGitPath& left, const CTGitPath& right)
709 left.EnsureBackslashPathSet();
710 right.EnsureBackslashPathSet();
711 return left.m_sBackslashPath.CompareNoCase(right.m_sBackslashPath);
714 bool operator<(const CTGitPath& left, const CTGitPath& right)
716 return CTGitPath::Compare(left, right) < 0;
719 bool CTGitPath::PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right)
721 return left.IsEquivalentTo(right);
724 bool CTGitPath::PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right)
726 if (left.IsAdminDir() && right.IsAdminDir())
728 CTGitPath l = left;
729 CTGitPath r = right;
732 l = l.GetContainingDirectory();
733 } while(l.HasAdminDir());
736 r = r.GetContainingDirectory();
737 } while(r.HasAdminDir());
738 return l.GetContainingDirectory().IsEquivalentTo(r.GetContainingDirectory());
740 return left.GetDirectory().IsEquivalentTo(right.GetDirectory());
743 bool CTGitPath::CheckChild(const CTGitPath &parent, const CTGitPath& child)
745 return parent.IsAncestorOf(child);
748 void CTGitPath::AppendRawString(const CString& sAppend)
750 EnsureFwdslashPathSet();
751 CString strCopy = m_sFwdslashPath += sAppend;
752 SetFromUnknown(strCopy);
755 void CTGitPath::AppendPathString(const CString& sAppend)
757 EnsureBackslashPathSet();
758 CString cleanAppend(sAppend);
759 cleanAppend.Replace('/', '\\');
760 cleanAppend.TrimLeft('\\');
761 m_sBackslashPath.TrimRight('\\');
762 CString strCopy = m_sBackslashPath + _T("\\") + cleanAppend;
763 SetFromWin(strCopy);
766 bool CTGitPath::IsWCRoot() const
768 if (m_bIsWCRootKnown)
769 return m_bIsWCRoot;
771 m_bIsWCRootKnown = true;
772 m_bIsWCRoot = false;
774 CString topDirectory;
775 if (!IsDirectory() || !HasAdminDir(&topDirectory))
777 return m_bIsWCRoot;
780 if (IsEquivalentToWithoutCase(topDirectory))
782 m_bIsWCRoot = true;
785 return m_bIsWCRoot;
788 bool CTGitPath::HasAdminDir() const
790 if (m_bHasAdminDirKnown)
791 return m_bHasAdminDir;
793 EnsureBackslashPathSet();
794 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
795 m_bHasAdminDirKnown = true;
796 return m_bHasAdminDir;
799 bool CTGitPath::HasSubmodules() const
801 if (HasAdminDir())
803 CString path = m_sProjectRoot;
804 path += _T("\\.gitmodules");
805 if( PathFileExists(path) )
806 return true;
808 return false;
811 int CTGitPath::GetAdminDirMask() const
813 int status = 0;
814 CString topdir;
815 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
817 return status;
820 // ITEMIS_INGIT will be revoked if necessary in TortoiseShell/ContextMenu.cpp
821 status |= ITEMIS_INGIT|ITEMIS_INVERSIONEDFOLDER;
823 if (IsDirectory())
825 status |= ITEMIS_FOLDERINGIT;
826 if (IsWCRoot())
827 status |= ITEMIS_WCROOT;
830 CString dotGitPath;
831 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
833 if (PathFileExists(dotGitPath + _T("BISECT_START")))
834 status |= ITEMIS_BISECT;
836 if (PathFileExists(dotGitPath + _T("refs\\stash")))
837 status |= ITEMIS_STASH;
839 if (PathFileExists(dotGitPath + _T("svn")))
840 status |= ITEMIS_GITSVN;
842 if (PathFileExists(topdir + _T("\\.gitmodules")))
843 status |= ITEMIS_SUBMODULECONTAINER;
845 return status;
848 bool CTGitPath::HasStashDir() const
850 CString topdir;
851 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
853 return false;
856 CString dotGitPath;
857 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
859 return !!PathFileExists(dotGitPath + _T("\\refs\\stash"));
861 bool CTGitPath::HasGitSVNDir() const
863 CString topdir;
864 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
866 return false;
869 CString dotGitPath;
870 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
872 return !!PathFileExists(dotGitPath + _T("svn"));
874 bool CTGitPath::IsBisectActive() const
876 CString topdir;
877 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
879 return false;
882 CString dotGitPath;
883 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
885 return !!PathFileExists(dotGitPath + _T("BISECT_START"));
887 bool CTGitPath::IsMergeActive() const
889 CString topdir;
890 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
892 return false;
895 CString dotGitPath;
896 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
898 return !!PathFileExists(dotGitPath + _T("MERGE_HEAD"));
900 bool CTGitPath::HasRebaseApply() const
902 CString topdir;
903 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
905 return false;
908 CString dotGitPath;
909 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
911 return !!PathFileExists(dotGitPath + _T("rebase-apply"));
914 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const
916 if (m_bHasAdminDirKnown)
918 if (ProjectTopDir)
919 *ProjectTopDir = m_sProjectRoot;
920 return m_bHasAdminDir;
923 EnsureBackslashPathSet();
924 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
925 m_bHasAdminDirKnown = true;
926 if (ProjectTopDir)
927 *ProjectTopDir = m_sProjectRoot;
928 return m_bHasAdminDir;
931 bool CTGitPath::IsAdminDir() const
933 if (m_bIsAdminDirKnown)
934 return m_bIsAdminDir;
936 EnsureBackslashPathSet();
937 m_bIsAdminDir = g_GitAdminDir.IsAdminDirPath(m_sBackslashPath);
938 m_bIsAdminDirKnown = true;
939 return m_bIsAdminDir;
942 bool CTGitPath::IsValidOnWindows() const
944 if (m_bIsValidOnWindowsKnown)
945 return m_bIsValidOnWindows;
947 m_bIsValidOnWindows = false;
948 EnsureBackslashPathSet();
949 CString sMatch = m_sBackslashPath + _T("\r\n");
950 wstring sPattern;
951 // the 'file://' URL is just a normal windows path:
952 if (sMatch.Left(7).CompareNoCase(_T("file:\\\\"))==0)
954 sMatch = sMatch.Mid(7);
955 sMatch.TrimLeft(_T("\\"));
956 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
958 else if (IsUrl())
960 sPattern = _T("^((http|https|svn|svn\\+ssh|file)\\:\\\\+([^\\\\@\\:]+\\:[^\\\\@\\:]+@)?\\\\[^\\\\]+(\\:\\d+)?)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
962 else
964 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
969 tr1::wregex rx(sPattern, tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
970 tr1::wsmatch match;
972 wstring rmatch = wstring((LPCTSTR)sMatch);
973 if (tr1::regex_match(rmatch, match, rx))
975 if (wstring(match[0]).compare(sMatch)==0)
976 m_bIsValidOnWindows = true;
978 if (m_bIsValidOnWindows)
980 // now check for illegal filenames
981 tr1::wregex rx2(_T("\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$)"), tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
982 rmatch = m_sBackslashPath;
983 if (tr1::regex_search(rmatch, rx2, tr1::regex_constants::match_default))
984 m_bIsValidOnWindows = false;
987 catch (exception) {}
989 m_bIsValidOnWindowsKnown = true;
990 return m_bIsValidOnWindows;
993 bool CTGitPath::IsSpecialDirectory() const
995 if (m_bIsSpecialDirectoryKnown)
996 return m_bIsSpecialDirectory;
998 static LPCTSTR specialDirectories[]
999 = { _T("trunk"), _T("tags"), _T("branches") };
1001 for (int i = 0; i < _countof(specialDirectories); ++i)
1003 CString name = GetFileOrDirectoryName();
1004 if (0 == name.CompareNoCase(specialDirectories[i]))
1006 m_bIsSpecialDirectory = true;
1007 break;
1011 m_bIsSpecialDirectoryKnown = true;
1013 return m_bIsSpecialDirectory;
1016 //////////////////////////////////////////////////////////////////////////
1018 CTGitPathList::CTGitPathList()
1023 // A constructor which allows a path list to be easily built which one initial entry in
1024 CTGitPathList::CTGitPathList(const CTGitPath& firstEntry)
1026 AddPath(firstEntry);
1028 int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool /*staged*/)
1030 unsigned int pos=0;
1031 CString one;
1032 CTGitPath path;
1033 CString part;
1034 this->Clear();
1036 while(pos>=0 && pos<out.size())
1038 one.Empty();
1039 path.Reset();
1041 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1042 int tabstart=0;
1043 path.m_Action=path.ParserAction(out[pos]);
1044 one.Tokenize(_T("\t"),tabstart);
1046 if(tabstart>=0)
1047 path.SetFromGit(one.Right(one.GetLength()-tabstart));
1049 tabstart=0;
1051 part=one.Tokenize(_T(" "),tabstart); //Tag
1053 part=one.Tokenize(_T(" "),tabstart); //Mode
1055 part=one.Tokenize(_T(" "),tabstart); //Hash
1057 part=one.Tokenize(_T("\t"),tabstart); //Stage
1059 path.m_Stage=_ttol(part);
1061 this->AddPath(path);
1063 pos=out.findNextString(pos);
1065 return pos;
1067 int CTGitPathList::FillUnRev(unsigned int action,CTGitPathList *list)
1069 int pos=0;
1070 this->Clear();
1071 CTGitPath path;
1073 int count;
1074 if(list==NULL)
1075 count=1;
1076 else
1077 count=list->GetCount();
1078 for(int i=0;i<count;i++)
1080 CString cmd;
1081 pos=0;
1083 CString ignored;
1084 if(action & CTGitPath::LOGACTIONS_IGNORE)
1085 ignored= _T(" -i");
1087 if(list==NULL)
1089 cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");
1090 cmd+=ignored;
1093 else
1094 { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z%s -- \"%s\""),
1095 ignored,
1096 (*list)[i].GetWinPathString());
1099 BYTE_VECTOR out;
1100 out.clear();
1101 g_Git.Run(cmd, &out);
1103 pos=0;
1104 CString one;
1105 while( pos>=0 && pos<out.size())
1107 one.Empty();
1108 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1109 if(!one.IsEmpty())
1111 //SetFromGit will clear all status
1112 path.SetFromGit(one);
1113 path.m_Action=action;
1114 AddPath(path);
1116 pos=out.findNextString(pos);
1120 return 0;
1122 int CTGitPathList::ParserFromLog(BYTE_VECTOR &log, bool parseDeletes /*false*/)
1124 this->Clear();
1125 int pos=0;
1126 //BYTE *p=&log[0];
1127 //CString one;
1128 CTGitPath path;
1129 m_Action=0;
1130 while( pos>=0 && pos<log.size())
1132 //one=log.Tokenize(_T("\n"),pos);
1133 path.Reset();
1134 if(log[pos]=='\n')
1135 pos++;
1137 if(log[pos]==':')
1139 bool merged=false;
1140 if(log[pos+1] ==':')
1142 merged=true;
1144 int end=log.find(0,pos);
1145 int actionstart=-1;
1146 int numfile=1;
1147 int file1=-1,file2=-1;
1148 if( end>0 )
1150 actionstart=log.find(' ',end-6);
1151 pos=actionstart;
1153 if( actionstart>0 )
1155 actionstart++;
1157 file1 = log.find(0,actionstart);
1158 if( file1>=0 )
1160 file1++;
1161 pos=file1;
1163 if( log[actionstart] == 'C' || log[actionstart] == 'R' )
1165 file2=file1;
1166 numfile=2;
1167 file1 = log.find(0,file1);
1168 if(file1>=0 )
1170 file1++;
1171 pos=file1;
1177 CString pathname1;
1178 CString pathname2;
1180 if( file1>=0 )
1181 g_Git.StringAppend(&pathname1, &log[file1], CP_UTF8);
1182 if( file2>=0 )
1183 g_Git.StringAppend(&pathname2, &log[file2], CP_UTF8);
1185 CTGitPath *GitPath=LookForGitPath(pathname1);
1187 if(GitPath)
1189 GitPath->ParserAction( log[actionstart] );
1191 if(merged)
1193 GitPath->m_Action |= CTGitPath::LOGACTIONS_MERGED;
1194 GitPath->m_Action &= ~CTGitPath::LOGACTIONS_FORWORD;
1196 m_Action |=GitPath->m_Action;
1199 else
1201 int ac=path.ParserAction(log[actionstart] );
1202 ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;
1204 path.SetFromGit(pathname1,&pathname2);
1205 path.m_Action=ac;
1206 //action must be set after setfromgit. SetFromGit will clear all status.
1207 this->m_Action|=ac;
1209 AddPath(path);
1214 else
1216 int tabstart=0;
1217 path.Reset();
1218 CString StatAdd;
1219 CString StatDel;
1220 CString file1;
1221 CString file2;
1223 tabstart=log.find('\t',pos);
1224 if(tabstart >=0)
1226 log[tabstart]=0;
1227 g_Git.StringAppend(&StatAdd,&log[pos],CP_UTF8);
1228 pos=tabstart+1;
1231 tabstart=log.find('\t',pos);
1232 if(tabstart >=0)
1234 log[tabstart]=0;
1236 g_Git.StringAppend(&StatDel,&log[pos],CP_UTF8);
1237 pos=tabstart+1;
1240 if(log[pos] == 0) //rename
1242 pos++;
1243 g_Git.StringAppend(&file2, &log[pos], CP_UTF8);
1244 int sec=log.find(0,pos);
1245 if(sec>=0)
1247 sec++;
1248 g_Git.StringAppend(&file1, &log[sec], CP_UTF8);
1250 pos=sec;
1253 else
1255 g_Git.StringAppend(&file1, &log[pos], CP_UTF8);
1257 path.SetFromGit(file1,&file2);
1259 CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());
1260 if(GitPath)
1262 GitPath->m_StatAdd=StatAdd;
1263 GitPath->m_StatDel=StatDel;
1265 else
1267 //path.SetFromGit(pathname);
1268 if (parseDeletes)
1270 path.m_StatAdd=_T("0");
1271 path.m_StatDel=_T("0");
1272 path.m_Action |= CTGitPath::LOGACTIONS_DELETED;
1274 else
1276 path.m_StatAdd=StatAdd;
1277 path.m_StatDel=StatDel;
1278 path.m_Action |= CTGitPath::LOGACTIONS_FORWORD;
1280 AddPath(path);
1284 pos=log.findNextString(pos);
1286 return pos;
1289 void CTGitPathList::AddPath(const CTGitPath& newPath)
1291 m_paths.push_back(newPath);
1292 m_commonBaseDirectory.Reset();
1294 int CTGitPathList::GetCount() const
1296 return (int)m_paths.size();
1298 void CTGitPathList::Clear()
1300 m_paths.clear();
1301 m_commonBaseDirectory.Reset();
1304 const CTGitPath& CTGitPathList::operator[](INT_PTR index) const
1306 ATLASSERT(index >= 0 && index < (INT_PTR)m_paths.size());
1307 return m_paths[index];
1310 bool CTGitPathList::AreAllPathsFiles() const
1312 // Look through the vector for any directories - if we find them, return false
1313 return std::find_if(m_paths.begin(), m_paths.end(), std::mem_fun_ref(&CTGitPath::IsDirectory)) == m_paths.end();
1317 #if defined(_MFC_VER)
1319 bool CTGitPathList::LoadFromFile(const CTGitPath& filename)
1321 Clear();
1324 CString strLine;
1325 CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);
1327 // for every selected file/folder
1328 CTGitPath path;
1329 while (file.ReadString(strLine))
1331 path.SetFromUnknown(strLine);
1332 AddPath(path);
1334 file.Close();
1336 catch (CFileException* pE)
1338 TRACE("CFileException loading target file list\n");
1339 TCHAR error[10000] = {0};
1340 pE->GetErrorMessage(error, 10000);
1341 // CMessageBox::Show(NULL, error, _T("TortoiseGit"), MB_ICONERROR);
1342 pE->Delete();
1343 return false;
1345 return true;
1348 bool CTGitPathList::WriteToFile(const CString& sFilename, bool bANSI /* = false */) const
1352 if (bANSI)
1354 CStdioFile file(sFilename, CFile::typeText | CFile::modeReadWrite | CFile::modeCreate);
1355 PathVector::const_iterator it;
1356 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1358 CStringA line = CStringA(it->GetGitPathString()) + '\n';
1359 file.Write(line, line.GetLength());
1361 file.Close();
1363 else
1365 CStdioFile file(sFilename, CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate);
1366 PathVector::const_iterator it;
1367 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1369 file.WriteString(it->GetGitPathString()+_T("\n"));
1371 file.Close();
1374 catch (CFileException* pE)
1376 TRACE("CFileException in writing temp file\n");
1377 pE->Delete();
1378 return false;
1380 return true;
1384 void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
1386 int pos = 0;
1387 CString temp;
1388 for(;;)
1390 temp = sPathString.Tokenize(_T("*"),pos);
1391 if(temp.IsEmpty())
1393 break;
1395 AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
1399 CString CTGitPathList::CreateAsteriskSeparatedString() const
1401 CString sRet;
1402 PathVector::const_iterator it;
1403 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1405 if (!sRet.IsEmpty())
1406 sRet += _T("*");
1407 sRet += it->GetWinPathString();
1409 return sRet;
1411 #endif // _MFC_VER
1413 bool
1414 CTGitPathList::AreAllPathsFilesInOneDirectory() const
1416 // Check if all the paths are files and in the same directory
1417 PathVector::const_iterator it;
1418 m_commonBaseDirectory.Reset();
1419 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1421 if(it->IsDirectory())
1423 return false;
1425 const CTGitPath& baseDirectory = it->GetDirectory();
1426 if(m_commonBaseDirectory.IsEmpty())
1428 m_commonBaseDirectory = baseDirectory;
1430 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1432 // Different path
1433 m_commonBaseDirectory.Reset();
1434 return false;
1437 return true;
1440 CTGitPath CTGitPathList::GetCommonDirectory() const
1442 if (m_commonBaseDirectory.IsEmpty())
1444 PathVector::const_iterator it;
1445 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1447 const CTGitPath& baseDirectory = it->GetDirectory();
1448 if(m_commonBaseDirectory.IsEmpty())
1450 m_commonBaseDirectory = baseDirectory;
1452 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1454 // Different path
1455 m_commonBaseDirectory.Reset();
1456 break;
1460 // since we only checked strings, not paths,
1461 // we have to make sure now that we really return a *path* here
1462 PathVector::const_iterator iter;
1463 for(iter = m_paths.begin(); iter != m_paths.end(); ++iter)
1465 if (!m_commonBaseDirectory.IsAncestorOf(*iter))
1467 m_commonBaseDirectory = m_commonBaseDirectory.GetContainingDirectory();
1468 break;
1471 return m_commonBaseDirectory;
1474 CTGitPath CTGitPathList::GetCommonRoot() const
1476 PathVector::const_iterator it;
1477 CString sRoot, sTempRoot;
1478 bool bEqual = true;
1480 if (GetCount() == 1)
1481 return m_paths[0];
1483 int backSlashPos = 0;
1484 int searchStartPos = 0;
1485 while (bEqual)
1487 if(m_paths.empty())
1488 break;
1490 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1492 if (backSlashPos == 0)
1494 backSlashPos = it->GetWinPathString().Find('\\', searchStartPos+1);
1495 if ((backSlashPos < 0)&&(searchStartPos != it->GetWinPathString().GetLength()))
1496 backSlashPos = it->GetWinPathString().GetLength();
1497 sTempRoot = it->GetWinPathString().Left(backSlashPos+1);
1499 else if (it->GetWinPathString().Find('\\', searchStartPos+1) != backSlashPos || it->GetWinPathString().Left(backSlashPos+1) != sTempRoot.Left(backSlashPos+1))
1501 if (it->GetWinPathString().Find('\\', searchStartPos+1) < 0)
1503 if (it->GetWinPathString().GetLength() != backSlashPos || it->GetWinPathString().Left(backSlashPos+1) != sTempRoot.Left(backSlashPos+1))
1505 bEqual = false;
1506 break;
1509 else
1511 bEqual = false;
1512 break;
1515 if (backSlashPos < 0)
1517 bEqual = false;
1518 break;
1521 if (bEqual == false)
1523 if (searchStartPos)
1524 sRoot = m_paths[0].GetWinPathString().Left(searchStartPos+1);
1526 else
1528 searchStartPos = backSlashPos;
1530 backSlashPos = 0;
1533 return CTGitPath(sRoot.TrimRight('\\'));
1536 void CTGitPathList::SortByPathname(bool bReverse /*= false*/)
1538 std::sort(m_paths.begin(), m_paths.end());
1539 if (bReverse)
1540 std::reverse(m_paths.begin(), m_paths.end());
1543 void CTGitPathList::DeleteAllFiles(bool bTrash)
1545 PathVector::const_iterator it;
1546 if (bTrash)
1548 SortByPathname(true); // nested ones first
1549 CString sPaths;
1550 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1552 if ((it->Exists())&&(!it->IsDirectory()))
1554 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1555 sPaths += it->GetWinPath();
1556 sPaths += '\0';
1559 sPaths += '\0';
1560 sPaths += '\0';
1561 SHFILEOPSTRUCT shop = {0};
1562 shop.wFunc = FO_DELETE;
1563 shop.pFrom = (LPCTSTR)sPaths;
1564 shop.fFlags = FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT;
1565 SHFileOperation(&shop);
1567 else
1569 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1571 if (!it->IsDirectory())
1573 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1574 ::DeleteFile(it->GetWinPath());
1578 Clear();
1581 void CTGitPathList::RemoveDuplicates()
1583 SortByPathname();
1584 // Remove the duplicates
1585 // (Unique moves them to the end of the vector, then erase chops them off)
1586 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::PredLeftEquivalentToRight), m_paths.end());
1589 void CTGitPathList::RemoveAdminPaths()
1591 PathVector::iterator it;
1592 for(it = m_paths.begin(); it != m_paths.end(); )
1594 if (it->IsAdminDir())
1596 m_paths.erase(it);
1597 it = m_paths.begin();
1599 else
1600 ++it;
1604 void CTGitPathList::RemovePath(const CTGitPath& path)
1606 PathVector::iterator it;
1607 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1609 if (it->IsEquivalentTo(path))
1611 m_paths.erase(it);
1612 return;
1617 void CTGitPathList::RemoveItem(CTGitPath & path)
1619 PathVector::iterator it;
1620 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1622 if (it->GetGitPathString()==path.GetGitPathString())
1624 m_paths.erase(it);
1625 return;
1629 void CTGitPathList::RemoveChildren()
1631 SortByPathname();
1632 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::CheckChild), m_paths.end());
1635 bool CTGitPathList::IsEqual(const CTGitPathList& list)
1637 if (list.GetCount() != GetCount())
1638 return false;
1639 for (int i=0; i<list.GetCount(); ++i)
1641 if (!list[i].IsEquivalentTo(m_paths[i]))
1642 return false;
1644 return true;
1647 //////////////////////////////////////////////////////////////////////////
1648 #if 0
1649 apr_array_header_t * CTGitPathList::MakePathArray (apr_pool_t *pool) const
1651 apr_array_header_t *targets = apr_array_make (pool, GetCount(), sizeof(const char *));
1653 for(int nItem = 0; nItem < GetCount(); nItem++)
1655 const char * target = m_paths[nItem].GetGitApiPath(pool);
1656 (*((const char **) apr_array_push (targets))) = target;
1659 return targets;
1661 #endif
1662 //////////////////////////////////////////////////////////////////////////
1664 #if 0
1665 #if defined(_DEBUG)
1666 // Some test cases for these classes
1667 static class CTGitPathTests
1669 public:
1670 CTGitPathTests()
1672 apr_initialize();
1673 pool = svn_pool_create(NULL);
1674 GetDirectoryTest();
1675 AdminDirTest();
1676 SortTest();
1677 RawAppendTest();
1678 PathAppendTest();
1679 RemoveDuplicatesTest();
1680 RemoveChildrenTest();
1681 ContainingDirectoryTest();
1682 AncestorTest();
1683 SubversionPathTest();
1684 GetCommonRootTest();
1685 #if defined(_MFC_VER)
1686 ValidPathAndUrlTest();
1687 ListLoadingTest();
1688 #endif
1689 apr_terminate();
1692 private:
1693 // apr_pool_t * pool;
1694 void GetDirectoryTest()
1696 // Bit tricky, this test, because we need to know something about the file
1697 // layout on the machine which is running the test
1698 TCHAR winDir[MAX_PATH+1];
1699 GetWindowsDirectory(winDir, MAX_PATH);
1700 CString sWinDir(winDir);
1702 CTGitPath testPath;
1703 // This is a file which we know will always be there
1704 testPath.SetFromUnknown(sWinDir + _T("\\win.ini"));
1705 ATLASSERT(!testPath.IsDirectory());
1706 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1707 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() == sWinDir);
1709 // Now do the test on the win directory itself - It's hard to be sure about the containing directory
1710 // but we know it must be different to the directory itself
1711 testPath.SetFromUnknown(sWinDir);
1712 ATLASSERT(testPath.IsDirectory());
1713 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1714 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() != sWinDir);
1715 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString().GetLength() < sWinDir.GetLength());
1717 // Try a root path
1718 testPath.SetFromUnknown(_T("C:\\"));
1719 ATLASSERT(testPath.IsDirectory());
1720 ATLASSERT(testPath.GetDirectory().GetWinPathString().CompareNoCase(_T("C:\\"))==0);
1721 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1722 // Try a root UNC path
1723 testPath.SetFromUnknown(_T("\\MYSTATION"));
1724 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1727 void AdminDirTest()
1729 CTGitPath testPath;
1730 testPath.SetFromUnknown(_T("c:\\.svndir"));
1731 ATLASSERT(!testPath.IsAdminDir());
1732 testPath.SetFromUnknown(_T("c:\\test.svn"));
1733 ATLASSERT(!testPath.IsAdminDir());
1734 testPath.SetFromUnknown(_T("c:\\.svn"));
1735 ATLASSERT(testPath.IsAdminDir());
1736 testPath.SetFromUnknown(_T("c:\\.svndir\\test"));
1737 ATLASSERT(!testPath.IsAdminDir());
1738 testPath.SetFromUnknown(_T("c:\\.svn\\test"));
1739 ATLASSERT(testPath.IsAdminDir());
1741 CTGitPathList pathList;
1742 pathList.AddPath(CTGitPath(_T("c:\\.svndir")));
1743 pathList.AddPath(CTGitPath(_T("c:\\.svn")));
1744 pathList.AddPath(CTGitPath(_T("c:\\.svn\\test")));
1745 pathList.AddPath(CTGitPath(_T("c:\\test")));
1746 pathList.RemoveAdminPaths();
1747 ATLASSERT(pathList.GetCount()==2);
1748 pathList.Clear();
1749 pathList.AddPath(CTGitPath(_T("c:\\test")));
1750 pathList.RemoveAdminPaths();
1751 ATLASSERT(pathList.GetCount()==1);
1754 void SortTest()
1756 CTGitPathList testList;
1757 CTGitPath testPath;
1758 testPath.SetFromUnknown(_T("c:/Z"));
1759 testList.AddPath(testPath);
1760 testPath.SetFromUnknown(_T("c:/B"));
1761 testList.AddPath(testPath);
1762 testPath.SetFromUnknown(_T("c:\\a"));
1763 testList.AddPath(testPath);
1764 testPath.SetFromUnknown(_T("c:/Test"));
1765 testList.AddPath(testPath);
1767 testList.SortByPathname();
1769 ATLASSERT(testList[0].GetWinPathString() == _T("c:\\a"));
1770 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\B"));
1771 ATLASSERT(testList[2].GetWinPathString() == _T("c:\\Test"));
1772 ATLASSERT(testList[3].GetWinPathString() == _T("c:\\Z"));
1775 void RawAppendTest()
1777 CTGitPath testPath(_T("c:/test/"));
1778 testPath.AppendRawString(_T("/Hello"));
1779 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1781 testPath.AppendRawString(_T("\\T2"));
1782 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1784 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1785 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1786 testBasePath.AppendRawString(testFilePath.GetFileExtension());
1787 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt.ini"));
1790 void PathAppendTest()
1792 CTGitPath testPath(_T("c:/test/"));
1793 testPath.AppendPathString(_T("/Hello"));
1794 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1796 testPath.AppendPathString(_T("T2"));
1797 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1799 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1800 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1801 // You wouldn't want to do this in real life - you'd use append-raw
1802 testBasePath.AppendPathString(testFilePath.GetFileExtension());
1803 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt\\.ini"));
1806 void RemoveDuplicatesTest()
1808 CTGitPathList list;
1809 list.AddPath(CTGitPath(_T("Z")));
1810 list.AddPath(CTGitPath(_T("A")));
1811 list.AddPath(CTGitPath(_T("E")));
1812 list.AddPath(CTGitPath(_T("E")));
1814 ATLASSERT(list[2].IsEquivalentTo(list[3]));
1815 ATLASSERT(list[2]==list[3]);
1817 ATLASSERT(list.GetCount() == 4);
1819 list.RemoveDuplicates();
1821 ATLASSERT(list.GetCount() == 3);
1823 ATLASSERT(list[0].GetWinPathString() == _T("A"));
1824 ATLASSERT(list[1].GetWinPathString().Compare(_T("E")) == 0);
1825 ATLASSERT(list[2].GetWinPathString() == _T("Z"));
1828 void RemoveChildrenTest()
1830 CTGitPathList list;
1831 list.AddPath(CTGitPath(_T("c:\\test")));
1832 list.AddPath(CTGitPath(_T("c:\\test\\file")));
1833 list.AddPath(CTGitPath(_T("c:\\testfile")));
1834 list.AddPath(CTGitPath(_T("c:\\parent")));
1835 list.AddPath(CTGitPath(_T("c:\\parent\\child")));
1836 list.AddPath(CTGitPath(_T("c:\\parent\\child1")));
1837 list.AddPath(CTGitPath(_T("c:\\parent\\child2")));
1839 ATLASSERT(list.GetCount() == 7);
1841 list.RemoveChildren();
1843 ATLTRACE("count = %d\n", list.GetCount());
1844 ATLASSERT(list.GetCount() == 3);
1846 list.SortByPathname();
1848 ATLASSERT(list[0].GetWinPathString().Compare(_T("c:\\parent")) == 0);
1849 ATLASSERT(list[1].GetWinPathString().Compare(_T("c:\\test")) == 0);
1850 ATLASSERT(list[2].GetWinPathString().Compare(_T("c:\\testfile")) == 0);
1853 #if defined(_MFC_VER)
1854 void ListLoadingTest()
1856 TCHAR buf[MAX_PATH];
1857 GetCurrentDirectory(MAX_PATH, buf);
1858 CString sPathList(_T("Path1*c:\\path2 with spaces and stuff*\\funnypath\\*"));
1859 CTGitPathList testList;
1860 testList.LoadFromAsteriskSeparatedString(sPathList);
1862 ATLASSERT(testList.GetCount() == 3);
1863 ATLASSERT(testList[0].GetWinPathString() == CString(buf) + _T("\\Path1"));
1864 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\path2 with spaces and stuff"));
1865 ATLASSERT(testList[2].GetWinPathString() == _T("\\funnypath"));
1867 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T(""));
1868 testList.Clear();
1869 sPathList = _T("c:\\path2 with spaces and stuff*c:\\funnypath\\*");
1870 testList.LoadFromAsteriskSeparatedString(sPathList);
1871 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T("c:\\"));
1873 #endif
1875 void ContainingDirectoryTest()
1878 CTGitPath testPath;
1879 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1880 CTGitPath dir;
1881 dir = testPath.GetContainingDirectory();
1882 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c\\d"));
1883 dir = dir.GetContainingDirectory();
1884 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c"));
1885 dir = dir.GetContainingDirectory();
1886 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b"));
1887 dir = dir.GetContainingDirectory();
1888 ATLASSERT(dir.GetWinPathString() == _T("c:\\a"));
1889 dir = dir.GetContainingDirectory();
1890 ATLASSERT(dir.GetWinPathString() == _T("c:\\"));
1891 dir = dir.GetContainingDirectory();
1892 ATLASSERT(dir.IsEmpty());
1893 ATLASSERT(dir.GetWinPathString() == _T(""));
1896 void AncestorTest()
1898 CTGitPath testPath;
1899 testPath.SetFromWin(_T("c:\\windows"));
1900 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\")))==false);
1901 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows"))));
1902 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windowsdummy")))==false);
1903 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\test.txt"))));
1904 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\system32\\test.txt"))));
1907 void SubversionPathTest()
1909 CTGitPath testPath;
1910 testPath.SetFromWin(_T("c:\\"));
1911 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:") == 0);
1912 testPath.SetFromWin(_T("c:\\folder"));
1913 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/folder") == 0);
1914 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1915 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/a/b/c/d/e") == 0);
1916 testPath.SetFromUnknown(_T("http://testing/"));
1917 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing") == 0);
1918 testPath.SetFromGit(NULL);
1919 ATLASSERT(strlen(testPath.GetGitApiPath(pool))==0);
1920 #if defined(_MFC_VER)
1921 testPath.SetFromUnknown(_T("http://testing again"));
1922 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1923 testPath.SetFromUnknown(_T("http://testing%20again"));
1924 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1925 testPath.SetFromUnknown(_T("http://testing special chars \344\366\374"));
1926 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20special%20chars%20%c3%a4%c3%b6%c3%bc") == 0);
1927 #endif
1930 void GetCommonRootTest()
1932 CTGitPath pathA (_T("C:\\Development\\LogDlg.cpp"));
1933 CTGitPath pathB (_T("C:\\Development\\LogDlg.h"));
1934 CTGitPath pathC (_T("C:\\Development\\SomeDir\\LogDlg.h"));
1936 CTGitPathList list;
1937 list.AddPath(pathA);
1938 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development\\LogDlg.cpp"))==0);
1939 list.AddPath(pathB);
1940 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1941 list.AddPath(pathC);
1942 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1943 #ifdef _MFC_VER
1944 list.Clear();
1945 CString sPathList = _T("D:\\Development\\StExBar\\StExBar\\src\\setup\\Setup64.wxs*D:\\Development\\StExBar\\StExBar\\src\\setup\\Setup.wxs*D:\\Development\\StExBar\\SKTimeStamp\\src\\setup\\Setup.wxs*D:\\Development\\StExBar\\SKTimeStamp\\src\\setup\\Setup64.wxs");
1946 list.LoadFromAsteriskSeparatedString(sPathList);
1947 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("D:\\Development\\StExBar"))==0);
1949 list.Clear();
1950 sPathList = _T("c:\\windows\\explorer.exe*c:\\windows");
1951 list.LoadFromAsteriskSeparatedString(sPathList);
1952 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1954 list.Clear();
1955 sPathList = _T("c:\\windows\\*c:\\windows");
1956 list.LoadFromAsteriskSeparatedString(sPathList);
1957 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1959 list.Clear();
1960 sPathList = _T("c:\\windows\\system32*c:\\windows\\system");
1961 list.LoadFromAsteriskSeparatedString(sPathList);
1962 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1964 list.Clear();
1965 sPathList = _T("c:\\windowsdummy*c:\\windows");
1966 list.LoadFromAsteriskSeparatedString(sPathList);
1967 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\"))==0);
1968 #endif
1971 void ValidPathAndUrlTest()
1973 CTGitPath testPath;
1974 testPath.SetFromWin(_T("c:\\a\\b\\c.test.txt"));
1975 ATLASSERT(testPath.IsValidOnWindows());
1976 testPath.SetFromWin(_T("c:\\"));
1977 ATLASSERT(testPath.IsValidOnWindows());
1978 testPath.SetFromWin(_T("D:\\.Net\\SpindleSearch\\"));
1979 ATLASSERT(testPath.IsValidOnWindows());
1980 testPath.SetFromWin(_T("c"));
1981 ATLASSERT(testPath.IsValidOnWindows());
1982 testPath.SetFromWin(_T("c:\\test folder\\file"));
1983 ATLASSERT(testPath.IsValidOnWindows());
1984 testPath.SetFromWin(_T("c:\\folder\\"));
1985 ATLASSERT(testPath.IsValidOnWindows());
1986 testPath.SetFromWin(_T("c:\\ext.ext.ext\\ext.ext.ext.ext"));
1987 ATLASSERT(testPath.IsValidOnWindows());
1988 testPath.SetFromWin(_T("c:\\.svn"));
1989 ATLASSERT(testPath.IsValidOnWindows());
1990 testPath.SetFromWin(_T("c:\\com\\file"));
1991 ATLASSERT(testPath.IsValidOnWindows());
1992 testPath.SetFromWin(_T("c:\\test\\conf"));
1993 ATLASSERT(testPath.IsValidOnWindows());
1994 testPath.SetFromWin(_T("c:\\LPT"));
1995 ATLASSERT(testPath.IsValidOnWindows());
1996 testPath.SetFromWin(_T("c:\\test\\LPT"));
1997 ATLASSERT(testPath.IsValidOnWindows());
1998 testPath.SetFromWin(_T("c:\\com1test"));
1999 ATLASSERT(testPath.IsValidOnWindows());
2000 testPath.SetFromWin(_T("\\\\?\\c:\\test\\com1test"));
2001 ATLASSERT(testPath.IsValidOnWindows());
2003 testPath.SetFromWin(_T("\\\\Share\\filename"));
2004 ATLASSERT(testPath.IsValidOnWindows());
2005 testPath.SetFromWin(_T("\\\\Share\\filename.extension"));
2006 ATLASSERT(testPath.IsValidOnWindows());
2007 testPath.SetFromWin(_T("\\\\Share\\.svn"));
2008 ATLASSERT(testPath.IsValidOnWindows());
2010 // now the negative tests
2011 testPath.SetFromWin(_T("c:\\test:folder"));
2012 ATLASSERT(!testPath.IsValidOnWindows());
2013 testPath.SetFromWin(_T("c:\\file<name"));
2014 ATLASSERT(!testPath.IsValidOnWindows());
2015 testPath.SetFromWin(_T("c:\\something*else"));
2016 ATLASSERT(!testPath.IsValidOnWindows());
2017 testPath.SetFromWin(_T("c:\\folder\\file?nofile"));
2018 ATLASSERT(!testPath.IsValidOnWindows());
2019 testPath.SetFromWin(_T("c:\\ext.>ension"));
2020 ATLASSERT(!testPath.IsValidOnWindows());
2021 testPath.SetFromWin(_T("c:\\com1\\filename"));
2022 ATLASSERT(!testPath.IsValidOnWindows());
2023 testPath.SetFromWin(_T("c:\\com1"));
2024 ATLASSERT(!testPath.IsValidOnWindows());
2025 testPath.SetFromWin(_T("c:\\com1\\AuX"));
2026 ATLASSERT(!testPath.IsValidOnWindows());
2028 testPath.SetFromWin(_T("\\\\Share\\lpt9\\filename"));
2029 ATLASSERT(!testPath.IsValidOnWindows());
2030 testPath.SetFromWin(_T("\\\\Share\\prn"));
2031 ATLASSERT(!testPath.IsValidOnWindows());
2032 testPath.SetFromWin(_T("\\\\Share\\NUL"));
2033 ATLASSERT(!testPath.IsValidOnWindows());
2035 // now come some URL tests
2036 testPath.SetFromGit(_T("http://myserver.com/repos/trunk"));
2037 ATLASSERT(testPath.IsValidOnWindows());
2038 testPath.SetFromGit(_T("https://myserver.com/repos/trunk/file%20with%20spaces"));
2039 ATLASSERT(testPath.IsValidOnWindows());
2040 testPath.SetFromGit(_T("svn://myserver.com/repos/trunk/file with spaces"));
2041 ATLASSERT(testPath.IsValidOnWindows());
2042 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk"));
2043 ATLASSERT(testPath.IsValidOnWindows());
2044 testPath.SetFromGit(_T("http://localhost:90/repos/trunk"));
2045 ATLASSERT(testPath.IsValidOnWindows());
2046 testPath.SetFromGit(_T("file:///C:/GitRepos/Tester/Proj1/tags/t2"));
2047 ATLASSERT(testPath.IsValidOnWindows());
2048 // and some negative URL tests
2049 testPath.SetFromGit(_T("httpp://myserver.com/repos/trunk"));
2050 ATLASSERT(!testPath.IsValidOnWindows());
2051 testPath.SetFromGit(_T("https://myserver.com/rep:os/trunk/file%20with%20spaces"));
2052 ATLASSERT(!testPath.IsValidOnWindows());
2053 testPath.SetFromGit(_T("svn://myserver.com/rep<os/trunk/file with spaces"));
2054 ATLASSERT(!testPath.IsValidOnWindows());
2055 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk/prn/"));
2056 ATLASSERT(!testPath.IsValidOnWindows());
2057 testPath.SetFromGit(_T("http://localhost:90/repos/trunk/com1"));
2058 ATLASSERT(!testPath.IsValidOnWindows());
2062 } TGitPathTestobject;
2063 #endif
2064 #endif
2066 CTGitPath * CTGitPathList::LookForGitPath(CString path)
2068 int i=0;
2069 for(i=0;i<this->GetCount();i++)
2071 if((*this)[i].GetGitPathString() == path )
2072 return (CTGitPath*)&(*this)[i];
2074 return NULL;
2076 CString CTGitPath::GetActionName(int action)
2078 if(action & CTGitPath::LOGACTIONS_UNMERGED)
2079 return MAKEINTRESOURCE(IDS_PATHACTIONS_CONFLICT);
2080 if(action & CTGitPath::LOGACTIONS_ADDED)
2081 return MAKEINTRESOURCE(IDS_PATHACTIONS_ADD);
2082 if(action & CTGitPath::LOGACTIONS_DELETED)
2083 return MAKEINTRESOURCE(IDS_PATHACTIONS_DELETE);
2084 if(action & CTGitPath::LOGACTIONS_MERGED )
2085 return MAKEINTRESOURCE(IDS_PATHACTIONS_MERGED);
2087 if(action & CTGitPath::LOGACTIONS_MODIFIED)
2088 return MAKEINTRESOURCE(IDS_PATHACTIONS_MODIFIED);
2089 if(action & CTGitPath::LOGACTIONS_REPLACED)
2090 return MAKEINTRESOURCE(IDS_PATHACTIONS_RENAME);
2091 if(action & CTGitPath::LOGACTIONS_COPY)
2092 return MAKEINTRESOURCE(IDS_PATHACTIONS_COPY);
2094 if(action & CTGitPath::LOGACTIONS_FORWORD )
2095 return MAKEINTRESOURCE(IDS_PATHACTIONS_FORWARD);
2097 if(action & CTGitPath::LOGACTIONS_REBASE_EDIT)
2098 return MAKEINTRESOURCE(IDS_PATHACTIONS_EDIT);
2099 if(action & CTGitPath::LOGACTIONS_REBASE_SQUASH)
2100 return MAKEINTRESOURCE(IDS_PATHACTIONS_SQUASH);
2101 if(action & CTGitPath::LOGACTIONS_REBASE_PICK)
2102 return MAKEINTRESOURCE(IDS_PATHACTIONS_PICK);
2103 if(action & CTGitPath::LOGACTIONS_REBASE_SKIP)
2104 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIP);
2106 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN);
2108 CString CTGitPath::GetActionName()
2110 return GetActionName(m_Action);
2113 int CTGitPathList::GetAction()
2115 return m_Action;