Catch the CMemoryExceptions when loading files in TortoiseMerge
[TortoiseGit.git] / src / Git / TGitPath.cpp
bloba9b99fca0df2060b3d81bb19d669439695ceffb3
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 "StringUtils.h"
30 #include "../Resources/LoglistCommonResource.h"
32 #if defined(_MFC_VER)
33 //#include "MessageBox.h"
34 //#include "AppUtils.h"
35 #endif
37 #ifndef ASSERT
38 #define ASSERT()
39 #endif
40 using namespace std;
41 extern CGit g_Git;
43 CTGitPath::CTGitPath(void)
44 : m_bDirectoryKnown(false)
45 , m_bIsDirectory(false)
46 , m_bIsURL(false)
47 , m_bURLKnown(false)
48 , m_bHasAdminDirKnown(false)
49 , m_bHasAdminDir(false)
50 , m_bIsValidOnWindowsKnown(false)
51 , m_bIsValidOnWindows(false)
52 , m_bIsReadOnly(false)
53 , m_bIsAdminDirKnown(false)
54 , m_bIsAdminDir(false)
55 , m_bExists(false)
56 , m_bExistsKnown(false)
57 , m_bLastWriteTimeKnown(0)
58 , m_lastWriteTime(0)
59 , m_customData(NULL)
60 , m_bIsSpecialDirectoryKnown(false)
61 , m_bIsSpecialDirectory(false)
62 , m_bIsWCRootKnown(false)
63 , m_bIsWCRoot(false)
65 m_Action=0;
66 m_ParentNo=0;
69 CTGitPath::~CTGitPath(void)
72 // Create a TGitPath object from an unknown path type (same as using SetFromUnknown)
73 CTGitPath::CTGitPath(const CString& sUnknownPath) :
74 m_bDirectoryKnown(false)
75 , m_bIsDirectory(false)
76 , m_bIsURL(false)
77 , m_bURLKnown(false)
78 , m_bHasAdminDirKnown(false)
79 , m_bHasAdminDir(false)
80 , m_bIsValidOnWindowsKnown(false)
81 , m_bIsValidOnWindows(false)
82 , m_bIsReadOnly(false)
83 , m_bIsAdminDirKnown(false)
84 , m_bIsAdminDir(false)
85 , m_bExists(false)
86 , m_bExistsKnown(false)
87 , m_bLastWriteTimeKnown(0)
88 , m_lastWriteTime(0)
89 , m_customData(NULL)
90 , m_bIsSpecialDirectoryKnown(false)
91 , m_bIsSpecialDirectory(false)
92 , m_bIsWCRootKnown(false)
93 , m_bIsWCRoot(false)
95 SetFromUnknown(sUnknownPath);
96 m_Action=0;
97 m_Stage=0;
98 m_ParentNo=0;
101 int CTGitPath::ParserAction(BYTE action)
103 //action=action.TrimLeft();
104 //TCHAR c=action.GetAt(0);
105 if(action == 'M')
106 m_Action|= LOGACTIONS_MODIFIED;
107 if(action == 'R')
108 m_Action|= LOGACTIONS_REPLACED;
109 if(action == 'A')
110 m_Action|= LOGACTIONS_ADDED;
111 if(action == 'D')
112 m_Action|= LOGACTIONS_DELETED;
113 if(action == 'U')
114 m_Action|= LOGACTIONS_UNMERGED;
115 if(action == 'K')
116 m_Action|= LOGACTIONS_DELETED;
117 if(action == 'H')
118 m_Action|= LOGACTIONS_CACHE;
119 if(action == 'C' )
120 m_Action|= LOGACTIONS_COPY;
122 return m_Action;
124 void CTGitPath::SetFromGit(const char* pPath)
126 Reset();
127 if (pPath == NULL)
128 return;
129 int len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, NULL, 0);
130 if (len)
132 len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, m_sFwdslashPath.GetBuffer(len+1), len+1);
133 m_sFwdslashPath.ReleaseBuffer(len-1);
135 SanitizeRootPath(m_sFwdslashPath, true);
138 void CTGitPath::SetFromGit(const char* pPath, bool bIsDirectory)
140 SetFromGit(pPath);
141 m_bDirectoryKnown = true;
142 m_bIsDirectory = bIsDirectory;
145 void CTGitPath::SetFromGit(const TCHAR* pPath, bool bIsDirectory)
147 Reset();
148 if (pPath)
150 m_sFwdslashPath = pPath;
151 SanitizeRootPath(m_sFwdslashPath, true);
153 m_bDirectoryKnown = true;
154 m_bIsDirectory = bIsDirectory;
157 void CTGitPath::SetFromGit(const CString& sPath,CString *oldpath)
159 Reset();
160 m_sFwdslashPath = sPath;
161 SanitizeRootPath(m_sFwdslashPath, true);
162 if(oldpath)
163 m_sOldFwdslashPath = *oldpath;
166 void CTGitPath::SetFromWin(LPCTSTR pPath)
168 Reset();
169 m_sBackslashPath = pPath;
170 SanitizeRootPath(m_sBackslashPath, false);
171 ATLASSERT(m_sBackslashPath.Find('/')<0);
173 void CTGitPath::SetFromWin(const CString& sPath)
175 Reset();
176 m_sBackslashPath = sPath;
177 SanitizeRootPath(m_sBackslashPath, false);
179 void CTGitPath::SetFromWin(const CString& sPath, bool bIsDirectory)
181 Reset();
182 m_sBackslashPath = sPath;
183 m_bIsDirectory = bIsDirectory;
184 m_bDirectoryKnown = true;
185 SanitizeRootPath(m_sBackslashPath, false);
187 void CTGitPath::SetFromUnknown(const CString& sPath)
189 Reset();
190 // Just set whichever path we think is most likely to be used
191 // GitAdminDir admin;
192 // CString p;
193 // if(admin.HasAdminDir(sPath,&p))
194 // SetFwdslashPath(sPath.Right(sPath.GetLength()-p.GetLength()));
195 // else
196 SetFwdslashPath(sPath);
199 LPCTSTR CTGitPath::GetWinPath() const
201 if(IsEmpty())
203 return _T("");
205 if(m_sBackslashPath.IsEmpty())
207 SetBackslashPath(m_sFwdslashPath);
209 return m_sBackslashPath;
211 // This is a temporary function, to be used during the migration to
212 // the path class. Ultimately, functions consuming paths should take a CTGitPath&, not a CString
213 const CString& CTGitPath::GetWinPathString() const
215 if(m_sBackslashPath.IsEmpty())
217 SetBackslashPath(m_sFwdslashPath);
219 return m_sBackslashPath;
222 const CString& CTGitPath::GetGitPathString() const
224 if(m_sFwdslashPath.IsEmpty())
226 SetFwdslashPath(m_sBackslashPath);
228 return m_sFwdslashPath;
231 const CString &CTGitPath::GetGitOldPathString() const
233 return m_sOldFwdslashPath;
235 #if 0
236 const char* CTGitPath::GetGitApiPath(apr_pool_t *pool) const
238 // This funny-looking 'if' is to avoid a subtle problem with empty paths, whereby
239 // each call to GetGitApiPath returns a different pointer value.
240 // If you made multiple calls to GetGitApiPath on the same string, only the last
241 // one would give you a valid pointer to an empty string, because each
242 // call would invalidate the previous call's return.
243 if(IsEmpty())
245 return "";
247 if(m_sFwdslashPath.IsEmpty())
249 SetFwdslashPath(m_sBackslashPath);
251 if(m_sUTF8FwdslashPath.IsEmpty())
253 SetUTF8FwdslashPath(m_sFwdslashPath);
255 if (svn_path_is_url(m_sUTF8FwdslashPath))
257 m_sUTF8FwdslashPathEscaped = CPathUtils::PathEscape(m_sUTF8FwdslashPath);
258 m_sUTF8FwdslashPathEscaped.Replace("file:////", "file:///\\");
259 m_sUTF8FwdslashPathEscaped = svn_path_canonicalize(m_sUTF8FwdslashPathEscaped, pool);
260 return m_sUTF8FwdslashPathEscaped;
262 m_sUTF8FwdslashPath = svn_path_canonicalize(m_sUTF8FwdslashPath, pool);
264 return m_sUTF8FwdslashPath;
266 #endif
268 const CString& CTGitPath::GetUIPathString() const
270 if (m_sUIPath.IsEmpty())
272 #if defined(_MFC_VER)
273 //BUGBUG HORRIBLE!!! - CPathUtils::IsEscaped doesn't need to be MFC-only
274 if (IsUrl())
276 m_sUIPath = CPathUtils::PathUnescape(GetGitPathString());
277 m_sUIPath.Replace(_T("file:////"), _T("file:///\\"));
280 else
281 #endif
283 m_sUIPath = GetWinPathString();
286 return m_sUIPath;
289 void CTGitPath::SetFwdslashPath(const CString& sPath) const
291 m_sFwdslashPath = sPath;
292 m_sFwdslashPath.Replace('\\', '/');
294 // We don't leave a trailing /
295 m_sFwdslashPath.TrimRight('/');
297 SanitizeRootPath(m_sFwdslashPath, true);
299 m_sFwdslashPath.Replace(_T("file:////"), _T("file:///\\"));
301 m_sUTF8FwdslashPath.Empty();
304 void CTGitPath::SetBackslashPath(const CString& sPath) const
306 m_sBackslashPath = sPath;
307 m_sBackslashPath.Replace('/', '\\');
308 m_sBackslashPath.TrimRight('\\');
309 SanitizeRootPath(m_sBackslashPath, false);
312 void CTGitPath::SetUTF8FwdslashPath(const CString& sPath) const
314 m_sUTF8FwdslashPath = CUnicodeUtils::GetUTF8(sPath);
317 void CTGitPath::SanitizeRootPath(CString& sPath, bool bIsForwardPath) const
319 // Make sure to add the trailing slash to root paths such as 'C:'
320 if (sPath.GetLength() == 2 && sPath[1] == ':')
322 sPath += (bIsForwardPath) ? _T("/") : _T("\\");
326 bool CTGitPath::IsUrl() const
328 #if 0
329 if (!m_bURLKnown)
331 EnsureFwdslashPathSet();
332 if(m_sUTF8FwdslashPath.IsEmpty())
334 SetUTF8FwdslashPath(m_sFwdslashPath);
336 m_bIsURL = !!svn_path_is_url(m_sUTF8FwdslashPath);
337 m_bURLKnown = true;
339 return m_bIsURL;
340 #endif
341 return false;
344 bool CTGitPath::IsDirectory() const
346 if(!m_bDirectoryKnown)
348 UpdateAttributes();
350 return m_bIsDirectory;
353 bool CTGitPath::Exists() const
355 if (!m_bExistsKnown)
357 UpdateAttributes();
359 return m_bExists;
362 bool CTGitPath::Delete(bool bTrash) const
364 EnsureBackslashPathSet();
365 ::SetFileAttributes(m_sBackslashPath, FILE_ATTRIBUTE_NORMAL);
366 bool bRet = false;
367 if (Exists())
369 if ((bTrash)||(IsDirectory()))
371 TCHAR * buf = new TCHAR[m_sBackslashPath.GetLength()+2];
372 _tcscpy_s(buf, m_sBackslashPath.GetLength()+2, m_sBackslashPath);
373 buf[m_sBackslashPath.GetLength()] = 0;
374 buf[m_sBackslashPath.GetLength()+1] = 0;
375 bRet = CTGitPathList::DeleteViaShell(buf, bTrash);
376 delete [] buf;
378 else
380 bRet = !!::DeleteFile(m_sBackslashPath);
383 m_bExists = false;
384 m_bExistsKnown = true;
385 return bRet;
388 __int64 CTGitPath::GetLastWriteTime() const
390 if(!m_bLastWriteTimeKnown)
392 UpdateAttributes();
394 return m_lastWriteTime;
397 bool CTGitPath::IsReadOnly() const
399 if(!m_bLastWriteTimeKnown)
401 UpdateAttributes();
403 return m_bIsReadOnly;
406 void CTGitPath::UpdateAttributes() const
408 EnsureBackslashPathSet();
409 WIN32_FILE_ATTRIBUTE_DATA attribs;
410 if(GetFileAttributesEx(m_sBackslashPath, GetFileExInfoStandard, &attribs))
412 m_bIsDirectory = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
413 m_lastWriteTime = *(__int64*)&attribs.ftLastWriteTime;
414 m_bIsReadOnly = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_READONLY);
415 m_bExists = true;
417 else
419 DWORD err = GetLastError();
420 if ((err == ERROR_FILE_NOT_FOUND)||(err == ERROR_PATH_NOT_FOUND)||(err == ERROR_INVALID_NAME))
422 m_bIsDirectory = false;
423 m_lastWriteTime = 0;
424 m_bExists = false;
426 else
428 m_bIsDirectory = false;
429 m_lastWriteTime = 0;
430 m_bExists = true;
431 return;
434 m_bDirectoryKnown = true;
435 m_bLastWriteTimeKnown = true;
436 m_bExistsKnown = true;
439 CTGitPath CTGitPath::GetSubPath(const CTGitPath &root)
441 CTGitPath path;
443 if(GetWinPathString().Left(root.GetWinPathString().GetLength()) == root.GetWinPathString())
445 CString str=GetWinPathString();
446 path.SetFromWin(str.Right(str.GetLength()-root.GetWinPathString().GetLength()-1));
448 return path;
451 void CTGitPath::EnsureBackslashPathSet() const
453 if(m_sBackslashPath.IsEmpty())
455 SetBackslashPath(m_sFwdslashPath);
456 ATLASSERT(IsEmpty() || !m_sBackslashPath.IsEmpty());
459 void CTGitPath::EnsureFwdslashPathSet() const
461 if(m_sFwdslashPath.IsEmpty())
463 SetFwdslashPath(m_sBackslashPath);
464 ATLASSERT(IsEmpty() || !m_sFwdslashPath.IsEmpty());
469 // Reset all the caches
470 void CTGitPath::Reset()
472 m_bDirectoryKnown = false;
473 m_bURLKnown = false;
474 m_bLastWriteTimeKnown = false;
475 m_bHasAdminDirKnown = false;
476 m_bIsValidOnWindowsKnown = false;
477 m_bIsAdminDirKnown = false;
478 m_bExistsKnown = false;
479 m_bIsSpecialDirectoryKnown = false;
480 m_bIsSpecialDirectory = false;
482 m_sBackslashPath.Empty();
483 m_sFwdslashPath.Empty();
484 m_sUTF8FwdslashPath.Empty();
485 this->m_Action=0;
486 this->m_StatAdd=_T("");
487 this->m_StatDel=_T("");
488 m_ParentNo=0;
489 ATLASSERT(IsEmpty());
492 CTGitPath CTGitPath::GetDirectory() const
494 if ((IsDirectory())||(!Exists()))
496 return *this;
498 return GetContainingDirectory();
501 CTGitPath CTGitPath::GetContainingDirectory() const
503 EnsureBackslashPathSet();
505 CString sDirName = m_sBackslashPath.Left(m_sBackslashPath.ReverseFind('\\'));
506 if(sDirName.GetLength() == 2 && sDirName[1] == ':')
508 // This is a root directory, which needs a trailing slash
509 sDirName += '\\';
510 if(sDirName == m_sBackslashPath)
512 // We were clearly provided with a root path to start with - we should return nothing now
513 sDirName.Empty();
516 if(sDirName.GetLength() == 1 && sDirName[0] == '\\')
518 // We have an UNC path and we already are the root
519 sDirName.Empty();
521 CTGitPath retVal;
522 retVal.SetFromWin(sDirName);
523 return retVal;
526 CString CTGitPath::GetRootPathString() const
528 EnsureBackslashPathSet();
529 CString workingPath = m_sBackslashPath;
530 LPTSTR pPath = workingPath.GetBuffer(MAX_PATH); // MAX_PATH ok here.
531 ATLVERIFY(::PathStripToRoot(pPath));
532 workingPath.ReleaseBuffer();
533 return workingPath;
537 CString CTGitPath::GetFilename() const
539 //ATLASSERT(!IsDirectory());
540 return GetFileOrDirectoryName();
543 CString CTGitPath::GetFileOrDirectoryName() const
545 EnsureBackslashPathSet();
546 return m_sBackslashPath.Mid(m_sBackslashPath.ReverseFind('\\')+1);
549 CString CTGitPath::GetUIFileOrDirectoryName() const
551 GetUIPathString();
552 return m_sUIPath.Mid(m_sUIPath.ReverseFind('\\')+1);
555 CString CTGitPath::GetFileExtension() const
557 if(!IsDirectory())
559 EnsureBackslashPathSet();
560 int dotPos = m_sBackslashPath.ReverseFind('.');
561 int slashPos = m_sBackslashPath.ReverseFind('\\');
562 if (dotPos > slashPos)
563 return m_sBackslashPath.Mid(dotPos);
565 return CString();
567 CString CTGitPath::GetBaseFilename() const
569 int dot;
570 CString filename=GetFilename();
571 dot = filename.ReverseFind(_T('.'));
572 if(dot>0)
573 return filename.Left(dot);
574 else
575 return filename;
578 bool CTGitPath::ArePathStringsEqual(const CString& sP1, const CString& sP2)
580 int length = sP1.GetLength();
581 if(length != sP2.GetLength())
583 // Different lengths
584 return false;
586 // We work from the end of the strings, because path differences
587 // are more likely to occur at the far end of a string
588 LPCTSTR pP1Start = sP1;
589 LPCTSTR pP1 = pP1Start+(length-1);
590 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
591 while(length-- > 0)
593 if(_totlower(*pP1--) != _totlower(*pP2--))
595 return false;
598 return true;
601 bool CTGitPath::ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2)
603 int length = sP1.GetLength();
604 if(length != sP2.GetLength())
606 // Different lengths
607 return false;
609 // We work from the end of the strings, because path differences
610 // are more likely to occur at the far end of a string
611 LPCTSTR pP1Start = sP1;
612 LPCTSTR pP1 = pP1Start+(length-1);
613 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
614 while(length-- > 0)
616 if((*pP1--) != (*pP2--))
618 return false;
621 return true;
624 bool CTGitPath::IsEmpty() const
626 // Check the backward slash path first, since the chance that this
627 // one is set is higher. In case of a 'false' return value it's a little
628 // bit faster.
629 return m_sBackslashPath.IsEmpty() && m_sFwdslashPath.IsEmpty();
632 // Test if both paths refer to the same item
633 // Ignores case and slash direction
634 bool CTGitPath::IsEquivalentTo(const CTGitPath& rhs) const
636 // Try and find a slash direction which avoids having to convert
637 // both filenames
638 if(!m_sBackslashPath.IsEmpty())
640 // *We've* got a \ path - make sure that the RHS also has a \ path
641 rhs.EnsureBackslashPathSet();
642 return ArePathStringsEqualWithCase(m_sBackslashPath, rhs.m_sBackslashPath);
644 else
646 // Assume we've got a fwdslash path and make sure that the RHS has one
647 rhs.EnsureFwdslashPathSet();
648 return ArePathStringsEqualWithCase(m_sFwdslashPath, rhs.m_sFwdslashPath);
652 bool CTGitPath::IsEquivalentToWithoutCase(const CTGitPath& rhs) const
654 // Try and find a slash direction which avoids having to convert
655 // both filenames
656 if(!m_sBackslashPath.IsEmpty())
658 // *We've* got a \ path - make sure that the RHS also has a \ path
659 rhs.EnsureBackslashPathSet();
660 return ArePathStringsEqual(m_sBackslashPath, rhs.m_sBackslashPath);
662 else
664 // Assume we've got a fwdslash path and make sure that the RHS has one
665 rhs.EnsureFwdslashPathSet();
666 return ArePathStringsEqual(m_sFwdslashPath, rhs.m_sFwdslashPath);
670 bool CTGitPath::IsAncestorOf(const CTGitPath& possibleDescendant) const
672 possibleDescendant.EnsureBackslashPathSet();
673 EnsureBackslashPathSet();
675 bool bPathStringsEqual = ArePathStringsEqual(m_sBackslashPath, possibleDescendant.m_sBackslashPath.Left(m_sBackslashPath.GetLength()));
676 if (m_sBackslashPath.GetLength() >= possibleDescendant.GetWinPathString().GetLength())
678 return bPathStringsEqual;
681 return (bPathStringsEqual &&
682 ((possibleDescendant.m_sBackslashPath[m_sBackslashPath.GetLength()] == '\\')||
683 (m_sBackslashPath.GetLength()==3 && m_sBackslashPath[1]==':')));
686 // Get a string representing the file path, optionally with a base
687 // section stripped off the front.
688 CString CTGitPath::GetDisplayString(const CTGitPath* pOptionalBasePath /* = NULL*/) const
690 EnsureFwdslashPathSet();
691 if(pOptionalBasePath != NULL)
693 // Find the length of the base-path without having to do an 'ensure' on it
694 int baseLength = max(pOptionalBasePath->m_sBackslashPath.GetLength(), pOptionalBasePath->m_sFwdslashPath.GetLength());
696 // Now, chop that baseLength of the front of the path
697 return m_sFwdslashPath.Mid(baseLength).TrimLeft('/');
699 return m_sFwdslashPath;
702 int CTGitPath::Compare(const CTGitPath& left, const CTGitPath& right)
704 left.EnsureBackslashPathSet();
705 right.EnsureBackslashPathSet();
706 return left.m_sBackslashPath.CompareNoCase(right.m_sBackslashPath);
709 bool operator<(const CTGitPath& left, const CTGitPath& right)
711 return CTGitPath::Compare(left, right) < 0;
714 bool CTGitPath::PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right)
716 return left.IsEquivalentTo(right);
719 bool CTGitPath::PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right)
721 if (left.IsAdminDir() && right.IsAdminDir())
723 CTGitPath l = left;
724 CTGitPath r = right;
727 l = l.GetContainingDirectory();
728 } while(l.HasAdminDir());
731 r = r.GetContainingDirectory();
732 } while(r.HasAdminDir());
733 return l.GetContainingDirectory().IsEquivalentTo(r.GetContainingDirectory());
735 return left.GetDirectory().IsEquivalentTo(right.GetDirectory());
738 bool CTGitPath::CheckChild(const CTGitPath &parent, const CTGitPath& child)
740 return parent.IsAncestorOf(child);
743 void CTGitPath::AppendRawString(const CString& sAppend)
745 EnsureFwdslashPathSet();
746 CString strCopy = m_sFwdslashPath += sAppend;
747 SetFromUnknown(strCopy);
750 void CTGitPath::AppendPathString(const CString& sAppend)
752 EnsureBackslashPathSet();
753 CString cleanAppend(sAppend);
754 cleanAppend.Replace('/', '\\');
755 cleanAppend.TrimLeft('\\');
756 m_sBackslashPath.TrimRight('\\');
757 CString strCopy = m_sBackslashPath + _T("\\") + cleanAppend;
758 SetFromWin(strCopy);
761 bool CTGitPath::IsWCRoot() const
763 if (m_bIsWCRootKnown)
764 return m_bIsWCRoot;
766 m_bIsWCRootKnown = true;
767 m_bIsWCRoot = false;
769 CString topDirectory;
770 if (!IsDirectory() || !HasAdminDir(&topDirectory))
772 return m_bIsWCRoot;
775 if (IsEquivalentToWithoutCase(topDirectory))
777 m_bIsWCRoot = true;
780 return m_bIsWCRoot;
783 bool CTGitPath::HasAdminDir() const
785 if (m_bHasAdminDirKnown)
786 return m_bHasAdminDir;
788 EnsureBackslashPathSet();
789 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
790 m_bHasAdminDirKnown = true;
791 return m_bHasAdminDir;
794 bool CTGitPath::HasSubmodules() const
796 if (HasAdminDir())
798 CString path = m_sProjectRoot;
799 path += _T("\\.gitmodules");
800 if( PathFileExists(path) )
801 return true;
803 return false;
806 int CTGitPath::GetAdminDirMask() const
808 int status = 0;
809 CString topdir;
810 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
812 return status;
815 // ITEMIS_INGIT will be revoked if necessary in TortoiseShell/ContextMenu.cpp
816 status |= ITEMIS_INGIT|ITEMIS_INVERSIONEDFOLDER;
818 if (IsDirectory())
820 status |= ITEMIS_FOLDERINGIT;
821 if (IsWCRoot())
822 status |= ITEMIS_WCROOT;
825 CString dotGitPath;
826 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
828 if (PathFileExists(dotGitPath + _T("BISECT_START")))
829 status |= ITEMIS_BISECT;
831 if (PathFileExists(dotGitPath + _T("refs\\stash")))
832 status |= ITEMIS_STASH;
834 if (PathFileExists(dotGitPath + _T("svn")))
835 status |= ITEMIS_GITSVN;
837 if (PathFileExists(topdir + _T("\\.gitmodules")))
838 status |= ITEMIS_SUBMODULECONTAINER;
840 return status;
843 bool CTGitPath::HasStashDir() const
845 CString topdir;
846 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
848 return false;
851 CString dotGitPath;
852 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
854 return !!PathFileExists(dotGitPath + _T("\\refs\\stash"));
856 bool CTGitPath::HasGitSVNDir() const
858 CString topdir;
859 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
861 return false;
864 CString dotGitPath;
865 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
867 return !!PathFileExists(dotGitPath + _T("svn"));
869 bool CTGitPath::IsBisectActive() const
871 CString topdir;
872 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
874 return false;
877 CString dotGitPath;
878 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
880 return !!PathFileExists(dotGitPath + _T("BISECT_START"));
882 bool CTGitPath::IsMergeActive() const
884 CString topdir;
885 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
887 return false;
890 CString dotGitPath;
891 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
893 return !!PathFileExists(dotGitPath + _T("MERGE_HEAD"));
895 bool CTGitPath::HasRebaseApply() const
897 CString topdir;
898 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
900 return false;
903 CString dotGitPath;
904 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
906 return !!PathFileExists(dotGitPath + _T("rebase-apply"));
909 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const
911 if (m_bHasAdminDirKnown)
913 if (ProjectTopDir)
914 *ProjectTopDir = m_sProjectRoot;
915 return m_bHasAdminDir;
918 EnsureBackslashPathSet();
919 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
920 m_bHasAdminDirKnown = true;
921 if (ProjectTopDir)
922 *ProjectTopDir = m_sProjectRoot;
923 return m_bHasAdminDir;
926 bool CTGitPath::IsAdminDir() const
928 if (m_bIsAdminDirKnown)
929 return m_bIsAdminDir;
931 EnsureBackslashPathSet();
932 m_bIsAdminDir = g_GitAdminDir.IsAdminDirPath(m_sBackslashPath);
933 m_bIsAdminDirKnown = true;
934 return m_bIsAdminDir;
937 bool CTGitPath::IsValidOnWindows() const
939 if (m_bIsValidOnWindowsKnown)
940 return m_bIsValidOnWindows;
942 m_bIsValidOnWindows = false;
943 EnsureBackslashPathSet();
944 CString sMatch = m_sBackslashPath + _T("\r\n");
945 wstring sPattern;
946 // the 'file://' URL is just a normal windows path:
947 if (sMatch.Left(7).CompareNoCase(_T("file:\\\\"))==0)
949 sMatch = sMatch.Mid(7);
950 sMatch.TrimLeft(_T("\\"));
951 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
953 else if (IsUrl())
955 sPattern = _T("^((http|https|svn|svn\\+ssh|file)\\:\\\\+([^\\\\@\\:]+\\:[^\\\\@\\:]+@)?\\\\[^\\\\]+(\\:\\d+)?)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
957 else
959 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
964 tr1::wregex rx(sPattern, tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
965 tr1::wsmatch match;
967 wstring rmatch = wstring((LPCTSTR)sMatch);
968 if (tr1::regex_match(rmatch, match, rx))
970 if (wstring(match[0]).compare(sMatch)==0)
971 m_bIsValidOnWindows = true;
973 if (m_bIsValidOnWindows)
975 // now check for illegal filenames
976 tr1::wregex rx2(_T("\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$)"), tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
977 rmatch = m_sBackslashPath;
978 if (tr1::regex_search(rmatch, rx2, tr1::regex_constants::match_default))
979 m_bIsValidOnWindows = false;
982 catch (exception) {}
984 m_bIsValidOnWindowsKnown = true;
985 return m_bIsValidOnWindows;
988 bool CTGitPath::IsSpecialDirectory() const
990 if (m_bIsSpecialDirectoryKnown)
991 return m_bIsSpecialDirectory;
993 static LPCTSTR specialDirectories[]
994 = { _T("trunk"), _T("tags"), _T("branches") };
996 for (int i = 0; i < _countof(specialDirectories); ++i)
998 CString name = GetFileOrDirectoryName();
999 if (0 == name.CompareNoCase(specialDirectories[i]))
1001 m_bIsSpecialDirectory = true;
1002 break;
1006 m_bIsSpecialDirectoryKnown = true;
1008 return m_bIsSpecialDirectory;
1011 //////////////////////////////////////////////////////////////////////////
1013 CTGitPathList::CTGitPathList()
1018 // A constructor which allows a path list to be easily built which one initial entry in
1019 CTGitPathList::CTGitPathList(const CTGitPath& firstEntry)
1021 AddPath(firstEntry);
1023 int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool /*staged*/)
1025 unsigned int pos=0;
1026 CString one;
1027 CTGitPath path;
1028 CString part;
1029 this->Clear();
1031 while(pos>=0 && pos<out.size())
1033 one.Empty();
1034 path.Reset();
1036 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1037 int tabstart=0;
1038 path.m_Action=path.ParserAction(out[pos]);
1039 one.Tokenize(_T("\t"),tabstart);
1041 if(tabstart>=0)
1042 path.SetFromGit(one.Right(one.GetLength()-tabstart));
1044 tabstart=0;
1046 part=one.Tokenize(_T(" "),tabstart); //Tag
1048 part=one.Tokenize(_T(" "),tabstart); //Mode
1050 part=one.Tokenize(_T(" "),tabstart); //Hash
1052 part=one.Tokenize(_T("\t"),tabstart); //Stage
1054 path.m_Stage=_ttol(part);
1056 this->AddPath(path);
1058 pos=out.findNextString(pos);
1060 return pos;
1062 int CTGitPathList::FillUnRev(unsigned int action,CTGitPathList *list)
1064 int pos=0;
1065 this->Clear();
1066 CTGitPath path;
1068 int count;
1069 if(list==NULL)
1070 count=1;
1071 else
1072 count=list->GetCount();
1073 for(int i=0;i<count;i++)
1075 CString cmd;
1076 pos=0;
1078 CString ignored;
1079 if(action & CTGitPath::LOGACTIONS_IGNORE)
1080 ignored= _T(" -i");
1082 if(list==NULL)
1084 cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");
1085 cmd+=ignored;
1088 else
1089 { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z%s -- \"%s\""),
1090 ignored,
1091 (*list)[i].GetWinPathString());
1094 BYTE_VECTOR out;
1095 out.clear();
1096 g_Git.Run(cmd, &out);
1098 pos=0;
1099 CString one;
1100 while( pos>=0 && pos<out.size())
1102 one.Empty();
1103 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1104 if(!one.IsEmpty())
1106 //SetFromGit will clear all status
1107 path.SetFromGit(one);
1108 path.m_Action=action;
1109 AddPath(path);
1111 pos=out.findNextString(pos);
1115 return 0;
1117 int CTGitPathList::ParserFromLog(BYTE_VECTOR &log, bool parseDeletes /*false*/)
1119 this->Clear();
1120 int pos=0;
1121 //BYTE *p=&log[0];
1122 //CString one;
1123 CTGitPath path;
1124 m_Action=0;
1125 while( pos>=0 && pos<log.size())
1127 //one=log.Tokenize(_T("\n"),pos);
1128 path.Reset();
1129 if(log[pos]=='\n')
1130 pos++;
1132 if(log[pos]==':')
1134 bool merged=false;
1135 if(log[pos+1] ==':')
1137 merged=true;
1139 int end=log.find(0,pos);
1140 int actionstart=-1;
1141 int numfile=1;
1142 int file1=-1,file2=-1;
1143 if( end>0 )
1145 actionstart=log.find(' ',end-6);
1146 pos=actionstart;
1148 if( actionstart>0 )
1150 actionstart++;
1152 file1 = log.find(0,actionstart);
1153 if( file1>=0 )
1155 file1++;
1156 pos=file1;
1158 if( log[actionstart] == 'C' || log[actionstart] == 'R' )
1160 file2=file1;
1161 numfile=2;
1162 file1 = log.find(0,file1);
1163 if(file1>=0 )
1165 file1++;
1166 pos=file1;
1172 CString pathname1;
1173 CString pathname2;
1175 if( file1>=0 )
1176 g_Git.StringAppend(&pathname1, &log[file1], CP_UTF8);
1177 if( file2>=0 )
1178 g_Git.StringAppend(&pathname2, &log[file2], CP_UTF8);
1180 CTGitPath *GitPath=LookForGitPath(pathname1);
1182 if(GitPath)
1184 GitPath->ParserAction( log[actionstart] );
1186 if(merged)
1188 GitPath->m_Action |= CTGitPath::LOGACTIONS_MERGED;
1189 GitPath->m_Action &= ~CTGitPath::LOGACTIONS_FORWORD;
1191 m_Action |=GitPath->m_Action;
1194 else
1196 int ac=path.ParserAction(log[actionstart] );
1197 ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;
1199 path.SetFromGit(pathname1,&pathname2);
1200 path.m_Action=ac;
1201 //action must be set after setfromgit. SetFromGit will clear all status.
1202 this->m_Action|=ac;
1204 AddPath(path);
1209 else
1211 int tabstart=0;
1212 path.Reset();
1213 CString StatAdd;
1214 CString StatDel;
1215 CString file1;
1216 CString file2;
1218 tabstart=log.find('\t',pos);
1219 if(tabstart >=0)
1221 log[tabstart]=0;
1222 g_Git.StringAppend(&StatAdd,&log[pos],CP_UTF8);
1223 pos=tabstart+1;
1226 tabstart=log.find('\t',pos);
1227 if(tabstart >=0)
1229 log[tabstart]=0;
1231 g_Git.StringAppend(&StatDel,&log[pos],CP_UTF8);
1232 pos=tabstart+1;
1235 if(log[pos] == 0) //rename
1237 pos++;
1238 g_Git.StringAppend(&file2, &log[pos], CP_UTF8);
1239 int sec=log.find(0,pos);
1240 if(sec>=0)
1242 sec++;
1243 g_Git.StringAppend(&file1, &log[sec], CP_UTF8);
1245 pos=sec;
1248 else
1250 g_Git.StringAppend(&file1, &log[pos], CP_UTF8);
1252 path.SetFromGit(file1,&file2);
1254 CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());
1255 if(GitPath)
1257 GitPath->m_StatAdd=StatAdd;
1258 GitPath->m_StatDel=StatDel;
1260 else
1262 //path.SetFromGit(pathname);
1263 if (parseDeletes)
1265 path.m_StatAdd=_T("0");
1266 path.m_StatDel=_T("0");
1267 path.m_Action |= CTGitPath::LOGACTIONS_DELETED;
1269 else
1271 path.m_StatAdd=StatAdd;
1272 path.m_StatDel=StatDel;
1273 path.m_Action |= CTGitPath::LOGACTIONS_FORWORD;
1275 AddPath(path);
1279 pos=log.findNextString(pos);
1281 return pos;
1284 void CTGitPathList::AddPath(const CTGitPath& newPath)
1286 m_paths.push_back(newPath);
1287 m_commonBaseDirectory.Reset();
1289 int CTGitPathList::GetCount() const
1291 return (int)m_paths.size();
1293 void CTGitPathList::Clear()
1295 m_paths.clear();
1296 m_commonBaseDirectory.Reset();
1299 const CTGitPath& CTGitPathList::operator[](INT_PTR index) const
1301 ATLASSERT(index >= 0 && index < (INT_PTR)m_paths.size());
1302 return m_paths[index];
1305 bool CTGitPathList::AreAllPathsFiles() const
1307 // Look through the vector for any directories - if we find them, return false
1308 return std::find_if(m_paths.begin(), m_paths.end(), std::mem_fun_ref(&CTGitPath::IsDirectory)) == m_paths.end();
1312 #if defined(_MFC_VER)
1314 bool CTGitPathList::LoadFromFile(const CTGitPath& filename)
1316 Clear();
1319 CString strLine;
1320 CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);
1322 // for every selected file/folder
1323 CTGitPath path;
1324 while (file.ReadString(strLine))
1326 path.SetFromUnknown(strLine);
1327 AddPath(path);
1329 file.Close();
1331 catch (CFileException* pE)
1333 TRACE("CFileException loading target file list\n");
1334 TCHAR error[10000] = {0};
1335 pE->GetErrorMessage(error, 10000);
1336 // CMessageBox::Show(NULL, error, _T("TortoiseGit"), MB_ICONERROR);
1337 pE->Delete();
1338 return false;
1340 return true;
1343 bool CTGitPathList::WriteToFile(const CString& sFilename, bool bANSI /* = false */) const
1347 if (bANSI)
1349 CStdioFile file(sFilename, CFile::typeText | CFile::modeReadWrite | CFile::modeCreate);
1350 PathVector::const_iterator it;
1351 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1353 CStringA line = CStringA(it->GetGitPathString()) + '\n';
1354 file.Write(line, line.GetLength());
1356 file.Close();
1358 else
1360 CStdioFile file(sFilename, CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate);
1361 PathVector::const_iterator it;
1362 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1364 file.WriteString(it->GetGitPathString()+_T("\n"));
1366 file.Close();
1369 catch (CFileException* pE)
1371 TRACE("CFileException in writing temp file\n");
1372 pE->Delete();
1373 return false;
1375 return true;
1379 void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
1381 int pos = 0;
1382 CString temp;
1383 for(;;)
1385 temp = sPathString.Tokenize(_T("*"),pos);
1386 if(temp.IsEmpty())
1388 break;
1390 AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
1394 CString CTGitPathList::CreateAsteriskSeparatedString() const
1396 CString sRet;
1397 PathVector::const_iterator it;
1398 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1400 if (!sRet.IsEmpty())
1401 sRet += _T("*");
1402 sRet += it->GetWinPathString();
1404 return sRet;
1406 #endif // _MFC_VER
1408 bool
1409 CTGitPathList::AreAllPathsFilesInOneDirectory() const
1411 // Check if all the paths are files and in the same directory
1412 PathVector::const_iterator it;
1413 m_commonBaseDirectory.Reset();
1414 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1416 if(it->IsDirectory())
1418 return false;
1420 const CTGitPath& baseDirectory = it->GetDirectory();
1421 if(m_commonBaseDirectory.IsEmpty())
1423 m_commonBaseDirectory = baseDirectory;
1425 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1427 // Different path
1428 m_commonBaseDirectory.Reset();
1429 return false;
1432 return true;
1435 CTGitPath CTGitPathList::GetCommonDirectory() const
1437 if (m_commonBaseDirectory.IsEmpty())
1439 PathVector::const_iterator it;
1440 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1442 const CTGitPath& baseDirectory = it->GetDirectory();
1443 if(m_commonBaseDirectory.IsEmpty())
1445 m_commonBaseDirectory = baseDirectory;
1447 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1449 // Different path
1450 m_commonBaseDirectory.Reset();
1451 break;
1455 // since we only checked strings, not paths,
1456 // we have to make sure now that we really return a *path* here
1457 PathVector::const_iterator iter;
1458 for(iter = m_paths.begin(); iter != m_paths.end(); ++iter)
1460 if (!m_commonBaseDirectory.IsAncestorOf(*iter))
1462 m_commonBaseDirectory = m_commonBaseDirectory.GetContainingDirectory();
1463 break;
1466 return m_commonBaseDirectory;
1469 CTGitPath CTGitPathList::GetCommonRoot() const
1471 if (GetCount() == 0)
1472 return CTGitPath();
1474 if (GetCount() == 1)
1475 return m_paths[0];
1477 // first entry is common root for itself
1478 // (add trailing '\\' to detect partial matches of the last path element)
1479 CString root = m_paths[0].GetWinPathString() + _T('\\');
1480 int rootLength = root.GetLength();
1482 // determine common path string prefix
1483 for (PathVector::const_iterator it = m_paths.begin() + 1; it != m_paths.end(); ++it)
1485 CString path = it->GetWinPathString() + _T('\\');
1487 int newLength = CStringUtils::GetMatchingLength(root, path);
1488 if (newLength != rootLength)
1490 root.Delete(newLength, rootLength);
1491 rootLength = newLength;
1495 // remove the last (partial) path element
1496 if (rootLength > 0)
1497 root.Delete(root.ReverseFind(_T('\\')), rootLength);
1499 // done
1500 return CTGitPath(root);
1503 void CTGitPathList::SortByPathname(bool bReverse /*= false*/)
1505 std::sort(m_paths.begin(), m_paths.end());
1506 if (bReverse)
1507 std::reverse(m_paths.begin(), m_paths.end());
1510 void CTGitPathList::DeleteAllFiles(bool bTrash, bool bFilesOnly)
1512 PathVector::const_iterator it;
1513 SortByPathname(true); // nested ones first
1515 CString sPaths;
1516 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1518 if ((it->Exists()) && ((it->IsDirectory() != bFilesOnly) || !bFilesOnly))
1520 if (!it->IsDirectory())
1521 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1523 sPaths += it->GetWinPath();
1524 sPaths += '\0';
1527 sPaths += '\0';
1528 sPaths += '\0';
1529 DeleteViaShell((LPCTSTR)sPaths, bTrash);
1530 Clear();
1533 bool CTGitPathList::DeleteViaShell(LPCTSTR path, bool bTrash)
1535 SHFILEOPSTRUCT shop = {0};
1536 shop.wFunc = FO_DELETE;
1537 shop.pFrom = path;
1538 shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
1539 if (bTrash)
1540 shop.fFlags |= FOF_ALLOWUNDO;
1541 const bool bRet = (SHFileOperation(&shop) == 0);
1542 return bRet;
1545 void CTGitPathList::RemoveDuplicates()
1547 SortByPathname();
1548 // Remove the duplicates
1549 // (Unique moves them to the end of the vector, then erase chops them off)
1550 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::PredLeftEquivalentToRight), m_paths.end());
1553 void CTGitPathList::RemoveAdminPaths()
1555 PathVector::iterator it;
1556 for(it = m_paths.begin(); it != m_paths.end(); )
1558 if (it->IsAdminDir())
1560 m_paths.erase(it);
1561 it = m_paths.begin();
1563 else
1564 ++it;
1568 void CTGitPathList::RemovePath(const CTGitPath& path)
1570 PathVector::iterator it;
1571 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1573 if (it->IsEquivalentTo(path))
1575 m_paths.erase(it);
1576 return;
1581 void CTGitPathList::RemoveItem(CTGitPath & path)
1583 PathVector::iterator it;
1584 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1586 if (it->GetGitPathString()==path.GetGitPathString())
1588 m_paths.erase(it);
1589 return;
1593 void CTGitPathList::RemoveChildren()
1595 SortByPathname();
1596 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::CheckChild), m_paths.end());
1599 bool CTGitPathList::IsEqual(const CTGitPathList& list)
1601 if (list.GetCount() != GetCount())
1602 return false;
1603 for (int i=0; i<list.GetCount(); ++i)
1605 if (!list[i].IsEquivalentTo(m_paths[i]))
1606 return false;
1608 return true;
1611 //////////////////////////////////////////////////////////////////////////
1612 #if 0
1613 apr_array_header_t * CTGitPathList::MakePathArray (apr_pool_t *pool) const
1615 apr_array_header_t *targets = apr_array_make (pool, GetCount(), sizeof(const char *));
1617 for(int nItem = 0; nItem < GetCount(); nItem++)
1619 const char * target = m_paths[nItem].GetGitApiPath(pool);
1620 (*((const char **) apr_array_push (targets))) = target;
1623 return targets;
1625 #endif
1626 //////////////////////////////////////////////////////////////////////////
1628 #if 0
1629 #if defined(_DEBUG)
1630 // Some test cases for these classes
1631 static class CTGitPathTests
1633 public:
1634 CTGitPathTests()
1636 apr_initialize();
1637 pool = svn_pool_create(NULL);
1638 GetDirectoryTest();
1639 AdminDirTest();
1640 SortTest();
1641 RawAppendTest();
1642 PathAppendTest();
1643 RemoveDuplicatesTest();
1644 RemoveChildrenTest();
1645 ContainingDirectoryTest();
1646 AncestorTest();
1647 SubversionPathTest();
1648 GetCommonRootTest();
1649 #if defined(_MFC_VER)
1650 ValidPathAndUrlTest();
1651 ListLoadingTest();
1652 #endif
1653 apr_terminate();
1656 private:
1657 // apr_pool_t * pool;
1658 void GetDirectoryTest()
1660 // Bit tricky, this test, because we need to know something about the file
1661 // layout on the machine which is running the test
1662 TCHAR winDir[MAX_PATH+1];
1663 GetWindowsDirectory(winDir, MAX_PATH);
1664 CString sWinDir(winDir);
1666 CTGitPath testPath;
1667 // This is a file which we know will always be there
1668 testPath.SetFromUnknown(sWinDir + _T("\\win.ini"));
1669 ATLASSERT(!testPath.IsDirectory());
1670 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1671 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() == sWinDir);
1673 // Now do the test on the win directory itself - It's hard to be sure about the containing directory
1674 // but we know it must be different to the directory itself
1675 testPath.SetFromUnknown(sWinDir);
1676 ATLASSERT(testPath.IsDirectory());
1677 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1678 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() != sWinDir);
1679 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString().GetLength() < sWinDir.GetLength());
1681 // Try a root path
1682 testPath.SetFromUnknown(_T("C:\\"));
1683 ATLASSERT(testPath.IsDirectory());
1684 ATLASSERT(testPath.GetDirectory().GetWinPathString().CompareNoCase(_T("C:\\"))==0);
1685 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1686 // Try a root UNC path
1687 testPath.SetFromUnknown(_T("\\MYSTATION"));
1688 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1691 void AdminDirTest()
1693 CTGitPath testPath;
1694 testPath.SetFromUnknown(_T("c:\\.svndir"));
1695 ATLASSERT(!testPath.IsAdminDir());
1696 testPath.SetFromUnknown(_T("c:\\test.svn"));
1697 ATLASSERT(!testPath.IsAdminDir());
1698 testPath.SetFromUnknown(_T("c:\\.svn"));
1699 ATLASSERT(testPath.IsAdminDir());
1700 testPath.SetFromUnknown(_T("c:\\.svndir\\test"));
1701 ATLASSERT(!testPath.IsAdminDir());
1702 testPath.SetFromUnknown(_T("c:\\.svn\\test"));
1703 ATLASSERT(testPath.IsAdminDir());
1705 CTGitPathList pathList;
1706 pathList.AddPath(CTGitPath(_T("c:\\.svndir")));
1707 pathList.AddPath(CTGitPath(_T("c:\\.svn")));
1708 pathList.AddPath(CTGitPath(_T("c:\\.svn\\test")));
1709 pathList.AddPath(CTGitPath(_T("c:\\test")));
1710 pathList.RemoveAdminPaths();
1711 ATLASSERT(pathList.GetCount()==2);
1712 pathList.Clear();
1713 pathList.AddPath(CTGitPath(_T("c:\\test")));
1714 pathList.RemoveAdminPaths();
1715 ATLASSERT(pathList.GetCount()==1);
1718 void SortTest()
1720 CTGitPathList testList;
1721 CTGitPath testPath;
1722 testPath.SetFromUnknown(_T("c:/Z"));
1723 testList.AddPath(testPath);
1724 testPath.SetFromUnknown(_T("c:/B"));
1725 testList.AddPath(testPath);
1726 testPath.SetFromUnknown(_T("c:\\a"));
1727 testList.AddPath(testPath);
1728 testPath.SetFromUnknown(_T("c:/Test"));
1729 testList.AddPath(testPath);
1731 testList.SortByPathname();
1733 ATLASSERT(testList[0].GetWinPathString() == _T("c:\\a"));
1734 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\B"));
1735 ATLASSERT(testList[2].GetWinPathString() == _T("c:\\Test"));
1736 ATLASSERT(testList[3].GetWinPathString() == _T("c:\\Z"));
1739 void RawAppendTest()
1741 CTGitPath testPath(_T("c:/test/"));
1742 testPath.AppendRawString(_T("/Hello"));
1743 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1745 testPath.AppendRawString(_T("\\T2"));
1746 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1748 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1749 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1750 testBasePath.AppendRawString(testFilePath.GetFileExtension());
1751 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt.ini"));
1754 void PathAppendTest()
1756 CTGitPath testPath(_T("c:/test/"));
1757 testPath.AppendPathString(_T("/Hello"));
1758 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1760 testPath.AppendPathString(_T("T2"));
1761 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1763 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1764 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1765 // You wouldn't want to do this in real life - you'd use append-raw
1766 testBasePath.AppendPathString(testFilePath.GetFileExtension());
1767 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt\\.ini"));
1770 void RemoveDuplicatesTest()
1772 CTGitPathList list;
1773 list.AddPath(CTGitPath(_T("Z")));
1774 list.AddPath(CTGitPath(_T("A")));
1775 list.AddPath(CTGitPath(_T("E")));
1776 list.AddPath(CTGitPath(_T("E")));
1778 ATLASSERT(list[2].IsEquivalentTo(list[3]));
1779 ATLASSERT(list[2]==list[3]);
1781 ATLASSERT(list.GetCount() == 4);
1783 list.RemoveDuplicates();
1785 ATLASSERT(list.GetCount() == 3);
1787 ATLASSERT(list[0].GetWinPathString() == _T("A"));
1788 ATLASSERT(list[1].GetWinPathString().Compare(_T("E")) == 0);
1789 ATLASSERT(list[2].GetWinPathString() == _T("Z"));
1792 void RemoveChildrenTest()
1794 CTGitPathList list;
1795 list.AddPath(CTGitPath(_T("c:\\test")));
1796 list.AddPath(CTGitPath(_T("c:\\test\\file")));
1797 list.AddPath(CTGitPath(_T("c:\\testfile")));
1798 list.AddPath(CTGitPath(_T("c:\\parent")));
1799 list.AddPath(CTGitPath(_T("c:\\parent\\child")));
1800 list.AddPath(CTGitPath(_T("c:\\parent\\child1")));
1801 list.AddPath(CTGitPath(_T("c:\\parent\\child2")));
1803 ATLASSERT(list.GetCount() == 7);
1805 list.RemoveChildren();
1807 ATLTRACE("count = %d\n", list.GetCount());
1808 ATLASSERT(list.GetCount() == 3);
1810 list.SortByPathname();
1812 ATLASSERT(list[0].GetWinPathString().Compare(_T("c:\\parent")) == 0);
1813 ATLASSERT(list[1].GetWinPathString().Compare(_T("c:\\test")) == 0);
1814 ATLASSERT(list[2].GetWinPathString().Compare(_T("c:\\testfile")) == 0);
1817 #if defined(_MFC_VER)
1818 void ListLoadingTest()
1820 TCHAR buf[MAX_PATH];
1821 GetCurrentDirectory(MAX_PATH, buf);
1822 CString sPathList(_T("Path1*c:\\path2 with spaces and stuff*\\funnypath\\*"));
1823 CTGitPathList testList;
1824 testList.LoadFromAsteriskSeparatedString(sPathList);
1826 ATLASSERT(testList.GetCount() == 3);
1827 ATLASSERT(testList[0].GetWinPathString() == CString(buf) + _T("\\Path1"));
1828 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\path2 with spaces and stuff"));
1829 ATLASSERT(testList[2].GetWinPathString() == _T("\\funnypath"));
1831 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T(""));
1832 testList.Clear();
1833 sPathList = _T("c:\\path2 with spaces and stuff*c:\\funnypath\\*");
1834 testList.LoadFromAsteriskSeparatedString(sPathList);
1835 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T("c:\\"));
1837 #endif
1839 void ContainingDirectoryTest()
1842 CTGitPath testPath;
1843 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1844 CTGitPath dir;
1845 dir = testPath.GetContainingDirectory();
1846 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c\\d"));
1847 dir = dir.GetContainingDirectory();
1848 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c"));
1849 dir = dir.GetContainingDirectory();
1850 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b"));
1851 dir = dir.GetContainingDirectory();
1852 ATLASSERT(dir.GetWinPathString() == _T("c:\\a"));
1853 dir = dir.GetContainingDirectory();
1854 ATLASSERT(dir.GetWinPathString() == _T("c:\\"));
1855 dir = dir.GetContainingDirectory();
1856 ATLASSERT(dir.IsEmpty());
1857 ATLASSERT(dir.GetWinPathString() == _T(""));
1860 void AncestorTest()
1862 CTGitPath testPath;
1863 testPath.SetFromWin(_T("c:\\windows"));
1864 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\")))==false);
1865 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows"))));
1866 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windowsdummy")))==false);
1867 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\test.txt"))));
1868 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\system32\\test.txt"))));
1871 void SubversionPathTest()
1873 CTGitPath testPath;
1874 testPath.SetFromWin(_T("c:\\"));
1875 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:") == 0);
1876 testPath.SetFromWin(_T("c:\\folder"));
1877 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/folder") == 0);
1878 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1879 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/a/b/c/d/e") == 0);
1880 testPath.SetFromUnknown(_T("http://testing/"));
1881 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing") == 0);
1882 testPath.SetFromGit(NULL);
1883 ATLASSERT(strlen(testPath.GetGitApiPath(pool))==0);
1884 #if defined(_MFC_VER)
1885 testPath.SetFromUnknown(_T("http://testing again"));
1886 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1887 testPath.SetFromUnknown(_T("http://testing%20again"));
1888 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1889 testPath.SetFromUnknown(_T("http://testing special chars \344\366\374"));
1890 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20special%20chars%20%c3%a4%c3%b6%c3%bc") == 0);
1891 #endif
1894 void GetCommonRootTest()
1896 CTGitPath pathA (_T("C:\\Development\\LogDlg.cpp"));
1897 CTGitPath pathB (_T("C:\\Development\\LogDlg.h"));
1898 CTGitPath pathC (_T("C:\\Development\\SomeDir\\LogDlg.h"));
1900 CTGitPathList list;
1901 list.AddPath(pathA);
1902 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development\\LogDlg.cpp"))==0);
1903 list.AddPath(pathB);
1904 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1905 list.AddPath(pathC);
1906 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1907 #ifdef _MFC_VER
1908 list.Clear();
1909 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");
1910 list.LoadFromAsteriskSeparatedString(sPathList);
1911 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("D:\\Development\\StExBar"))==0);
1913 list.Clear();
1914 sPathList = _T("c:\\windows\\explorer.exe*c:\\windows");
1915 list.LoadFromAsteriskSeparatedString(sPathList);
1916 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1918 list.Clear();
1919 sPathList = _T("c:\\windows\\*c:\\windows");
1920 list.LoadFromAsteriskSeparatedString(sPathList);
1921 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1923 list.Clear();
1924 sPathList = _T("c:\\windows\\system32*c:\\windows\\system");
1925 list.LoadFromAsteriskSeparatedString(sPathList);
1926 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1928 list.Clear();
1929 sPathList = _T("c:\\windowsdummy*c:\\windows");
1930 list.LoadFromAsteriskSeparatedString(sPathList);
1931 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\"))==0);
1932 #endif
1935 void ValidPathAndUrlTest()
1937 CTGitPath testPath;
1938 testPath.SetFromWin(_T("c:\\a\\b\\c.test.txt"));
1939 ATLASSERT(testPath.IsValidOnWindows());
1940 testPath.SetFromWin(_T("c:\\"));
1941 ATLASSERT(testPath.IsValidOnWindows());
1942 testPath.SetFromWin(_T("D:\\.Net\\SpindleSearch\\"));
1943 ATLASSERT(testPath.IsValidOnWindows());
1944 testPath.SetFromWin(_T("c"));
1945 ATLASSERT(testPath.IsValidOnWindows());
1946 testPath.SetFromWin(_T("c:\\test folder\\file"));
1947 ATLASSERT(testPath.IsValidOnWindows());
1948 testPath.SetFromWin(_T("c:\\folder\\"));
1949 ATLASSERT(testPath.IsValidOnWindows());
1950 testPath.SetFromWin(_T("c:\\ext.ext.ext\\ext.ext.ext.ext"));
1951 ATLASSERT(testPath.IsValidOnWindows());
1952 testPath.SetFromWin(_T("c:\\.svn"));
1953 ATLASSERT(testPath.IsValidOnWindows());
1954 testPath.SetFromWin(_T("c:\\com\\file"));
1955 ATLASSERT(testPath.IsValidOnWindows());
1956 testPath.SetFromWin(_T("c:\\test\\conf"));
1957 ATLASSERT(testPath.IsValidOnWindows());
1958 testPath.SetFromWin(_T("c:\\LPT"));
1959 ATLASSERT(testPath.IsValidOnWindows());
1960 testPath.SetFromWin(_T("c:\\test\\LPT"));
1961 ATLASSERT(testPath.IsValidOnWindows());
1962 testPath.SetFromWin(_T("c:\\com1test"));
1963 ATLASSERT(testPath.IsValidOnWindows());
1964 testPath.SetFromWin(_T("\\\\?\\c:\\test\\com1test"));
1965 ATLASSERT(testPath.IsValidOnWindows());
1967 testPath.SetFromWin(_T("\\\\Share\\filename"));
1968 ATLASSERT(testPath.IsValidOnWindows());
1969 testPath.SetFromWin(_T("\\\\Share\\filename.extension"));
1970 ATLASSERT(testPath.IsValidOnWindows());
1971 testPath.SetFromWin(_T("\\\\Share\\.svn"));
1972 ATLASSERT(testPath.IsValidOnWindows());
1974 // now the negative tests
1975 testPath.SetFromWin(_T("c:\\test:folder"));
1976 ATLASSERT(!testPath.IsValidOnWindows());
1977 testPath.SetFromWin(_T("c:\\file<name"));
1978 ATLASSERT(!testPath.IsValidOnWindows());
1979 testPath.SetFromWin(_T("c:\\something*else"));
1980 ATLASSERT(!testPath.IsValidOnWindows());
1981 testPath.SetFromWin(_T("c:\\folder\\file?nofile"));
1982 ATLASSERT(!testPath.IsValidOnWindows());
1983 testPath.SetFromWin(_T("c:\\ext.>ension"));
1984 ATLASSERT(!testPath.IsValidOnWindows());
1985 testPath.SetFromWin(_T("c:\\com1\\filename"));
1986 ATLASSERT(!testPath.IsValidOnWindows());
1987 testPath.SetFromWin(_T("c:\\com1"));
1988 ATLASSERT(!testPath.IsValidOnWindows());
1989 testPath.SetFromWin(_T("c:\\com1\\AuX"));
1990 ATLASSERT(!testPath.IsValidOnWindows());
1992 testPath.SetFromWin(_T("\\\\Share\\lpt9\\filename"));
1993 ATLASSERT(!testPath.IsValidOnWindows());
1994 testPath.SetFromWin(_T("\\\\Share\\prn"));
1995 ATLASSERT(!testPath.IsValidOnWindows());
1996 testPath.SetFromWin(_T("\\\\Share\\NUL"));
1997 ATLASSERT(!testPath.IsValidOnWindows());
1999 // now come some URL tests
2000 testPath.SetFromGit(_T("http://myserver.com/repos/trunk"));
2001 ATLASSERT(testPath.IsValidOnWindows());
2002 testPath.SetFromGit(_T("https://myserver.com/repos/trunk/file%20with%20spaces"));
2003 ATLASSERT(testPath.IsValidOnWindows());
2004 testPath.SetFromGit(_T("svn://myserver.com/repos/trunk/file with spaces"));
2005 ATLASSERT(testPath.IsValidOnWindows());
2006 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk"));
2007 ATLASSERT(testPath.IsValidOnWindows());
2008 testPath.SetFromGit(_T("http://localhost:90/repos/trunk"));
2009 ATLASSERT(testPath.IsValidOnWindows());
2010 testPath.SetFromGit(_T("file:///C:/GitRepos/Tester/Proj1/tags/t2"));
2011 ATLASSERT(testPath.IsValidOnWindows());
2012 // and some negative URL tests
2013 testPath.SetFromGit(_T("httpp://myserver.com/repos/trunk"));
2014 ATLASSERT(!testPath.IsValidOnWindows());
2015 testPath.SetFromGit(_T("https://myserver.com/rep:os/trunk/file%20with%20spaces"));
2016 ATLASSERT(!testPath.IsValidOnWindows());
2017 testPath.SetFromGit(_T("svn://myserver.com/rep<os/trunk/file with spaces"));
2018 ATLASSERT(!testPath.IsValidOnWindows());
2019 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk/prn/"));
2020 ATLASSERT(!testPath.IsValidOnWindows());
2021 testPath.SetFromGit(_T("http://localhost:90/repos/trunk/com1"));
2022 ATLASSERT(!testPath.IsValidOnWindows());
2026 } TGitPathTestobject;
2027 #endif
2028 #endif
2030 CTGitPath * CTGitPathList::LookForGitPath(CString path)
2032 int i=0;
2033 for(i=0;i<this->GetCount();i++)
2035 if((*this)[i].GetGitPathString() == path )
2036 return (CTGitPath*)&(*this)[i];
2038 return NULL;
2040 CString CTGitPath::GetActionName(int action)
2042 if(action & CTGitPath::LOGACTIONS_UNMERGED)
2043 return MAKEINTRESOURCE(IDS_PATHACTIONS_CONFLICT);
2044 if(action & CTGitPath::LOGACTIONS_ADDED)
2045 return MAKEINTRESOURCE(IDS_PATHACTIONS_ADD);
2046 if(action & CTGitPath::LOGACTIONS_DELETED)
2047 return MAKEINTRESOURCE(IDS_PATHACTIONS_DELETE);
2048 if(action & CTGitPath::LOGACTIONS_MERGED )
2049 return MAKEINTRESOURCE(IDS_PATHACTIONS_MERGED);
2051 if(action & CTGitPath::LOGACTIONS_MODIFIED)
2052 return MAKEINTRESOURCE(IDS_PATHACTIONS_MODIFIED);
2053 if(action & CTGitPath::LOGACTIONS_REPLACED)
2054 return MAKEINTRESOURCE(IDS_PATHACTIONS_RENAME);
2055 if(action & CTGitPath::LOGACTIONS_COPY)
2056 return MAKEINTRESOURCE(IDS_PATHACTIONS_COPY);
2058 if(action & CTGitPath::LOGACTIONS_FORWORD )
2059 return MAKEINTRESOURCE(IDS_PATHACTIONS_FORWARD);
2061 if(action & CTGitPath::LOGACTIONS_REBASE_EDIT)
2062 return MAKEINTRESOURCE(IDS_PATHACTIONS_EDIT);
2063 if(action & CTGitPath::LOGACTIONS_REBASE_SQUASH)
2064 return MAKEINTRESOURCE(IDS_PATHACTIONS_SQUASH);
2065 if(action & CTGitPath::LOGACTIONS_REBASE_PICK)
2066 return MAKEINTRESOURCE(IDS_PATHACTIONS_PICK);
2067 if(action & CTGitPath::LOGACTIONS_REBASE_SKIP)
2068 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIP);
2070 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN);
2072 CString CTGitPath::GetActionName()
2074 return GetActionName(m_Action);
2077 int CTGitPathList::GetAction()
2079 return m_Action;