drop unused code for editing properties
[TortoiseGit.git] / src / Git / TGitPath.cpp
bloba7816874f42d697441651a41f2dd5e4abdf64f84
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"
30 #if defined(_MFC_VER)
31 //#include "MessageBox.h"
32 //#include "AppUtils.h"
33 #endif
35 #ifndef ASSERT
36 #define ASSERT()
37 #endif
38 using namespace std;
39 extern CGit g_Git;
41 CTGitPath::CTGitPath(void)
42 : m_bDirectoryKnown(false)
43 , m_bIsDirectory(false)
44 , m_bIsURL(false)
45 , m_bURLKnown(false)
46 , m_bHasAdminDirKnown(false)
47 , m_bHasAdminDir(false)
48 , m_bIsValidOnWindowsKnown(false)
49 , m_bIsValidOnWindows(false)
50 , m_bIsReadOnly(false)
51 , m_bIsAdminDirKnown(false)
52 , m_bIsAdminDir(false)
53 , m_bExists(false)
54 , m_bExistsKnown(false)
55 , m_bLastWriteTimeKnown(0)
56 , m_lastWriteTime(0)
57 , m_customData(NULL)
58 , m_bIsSpecialDirectoryKnown(false)
59 , m_bIsSpecialDirectory(false)
60 , m_bIsWCRootKnown(false)
61 , m_bIsWCRoot(false)
63 m_Action=0;
64 m_ParentNo=0;
67 CTGitPath::~CTGitPath(void)
70 // Create a TGitPath object from an unknown path type (same as using SetFromUnknown)
71 CTGitPath::CTGitPath(const CString& sUnknownPath) :
72 m_bDirectoryKnown(false)
73 , m_bIsDirectory(false)
74 , m_bIsURL(false)
75 , m_bURLKnown(false)
76 , m_bHasAdminDirKnown(false)
77 , m_bHasAdminDir(false)
78 , m_bIsValidOnWindowsKnown(false)
79 , m_bIsValidOnWindows(false)
80 , m_bIsReadOnly(false)
81 , m_bIsAdminDirKnown(false)
82 , m_bIsAdminDir(false)
83 , m_bExists(false)
84 , m_bExistsKnown(false)
85 , m_bLastWriteTimeKnown(0)
86 , m_lastWriteTime(0)
87 , m_customData(NULL)
88 , m_bIsSpecialDirectoryKnown(false)
89 , m_bIsSpecialDirectory(false)
90 , m_bIsWCRootKnown(false)
91 , m_bIsWCRoot(false)
93 SetFromUnknown(sUnknownPath);
94 m_Action=0;
95 m_Stage=0;
96 m_ParentNo=0;
99 int CTGitPath::ParserAction(BYTE action)
101 //action=action.TrimLeft();
102 //TCHAR c=action.GetAt(0);
103 if(action == 'M')
104 m_Action|= LOGACTIONS_MODIFIED;
105 if(action == 'R')
106 m_Action|= LOGACTIONS_REPLACED;
107 if(action == 'A')
108 m_Action|= LOGACTIONS_ADDED;
109 if(action == 'D')
110 m_Action|= LOGACTIONS_DELETED;
111 if(action == 'U')
112 m_Action|= LOGACTIONS_UNMERGED;
113 if(action == 'K')
114 m_Action|= LOGACTIONS_DELETED;
115 if(action == 'H')
116 m_Action|= LOGACTIONS_CACHE;
117 if(action == 'C' )
118 m_Action|= LOGACTIONS_COPY;
120 return m_Action;
122 void CTGitPath::SetFromGit(const char* pPath)
124 Reset();
125 if (pPath == NULL)
126 return;
127 int len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, NULL, 0);
128 if (len)
130 len = MultiByteToWideChar(CP_UTF8, 0, pPath, -1, m_sFwdslashPath.GetBuffer(len+1), len+1);
131 m_sFwdslashPath.ReleaseBuffer(len-1);
133 SanitizeRootPath(m_sFwdslashPath, true);
136 void CTGitPath::SetFromGit(const char* pPath, bool bIsDirectory)
138 SetFromGit(pPath);
139 m_bDirectoryKnown = true;
140 m_bIsDirectory = bIsDirectory;
143 void CTGitPath::SetFromGit(const TCHAR* pPath, bool bIsDirectory)
145 Reset();
146 if (pPath)
148 m_sFwdslashPath = pPath;
149 SanitizeRootPath(m_sFwdslashPath, true);
151 m_bDirectoryKnown = true;
152 m_bIsDirectory = bIsDirectory;
155 void CTGitPath::SetFromGit(const CString& sPath,CString *oldpath)
157 Reset();
158 m_sFwdslashPath = sPath;
159 SanitizeRootPath(m_sFwdslashPath, true);
160 if(oldpath)
161 m_sOldFwdslashPath = *oldpath;
164 void CTGitPath::SetFromWin(LPCTSTR pPath)
166 Reset();
167 m_sBackslashPath = pPath;
168 SanitizeRootPath(m_sBackslashPath, false);
169 ATLASSERT(m_sBackslashPath.Find('/')<0);
171 void CTGitPath::SetFromWin(const CString& sPath)
173 Reset();
174 m_sBackslashPath = sPath;
175 SanitizeRootPath(m_sBackslashPath, false);
177 void CTGitPath::SetFromWin(const CString& sPath, bool bIsDirectory)
179 Reset();
180 m_sBackslashPath = sPath;
181 m_bIsDirectory = bIsDirectory;
182 m_bDirectoryKnown = true;
183 SanitizeRootPath(m_sBackslashPath, false);
185 void CTGitPath::SetFromUnknown(const CString& sPath)
187 Reset();
188 // Just set whichever path we think is most likely to be used
189 // GitAdminDir admin;
190 // CString p;
191 // if(admin.HasAdminDir(sPath,&p))
192 // SetFwdslashPath(sPath.Right(sPath.GetLength()-p.GetLength()));
193 // else
194 SetFwdslashPath(sPath);
197 LPCTSTR CTGitPath::GetWinPath() const
199 if(IsEmpty())
201 return _T("");
203 if(m_sBackslashPath.IsEmpty())
205 SetBackslashPath(m_sFwdslashPath);
207 return m_sBackslashPath;
209 // This is a temporary function, to be used during the migration to
210 // the path class. Ultimately, functions consuming paths should take a CTGitPath&, not a CString
211 const CString& CTGitPath::GetWinPathString() const
213 if(m_sBackslashPath.IsEmpty())
215 SetBackslashPath(m_sFwdslashPath);
217 return m_sBackslashPath;
220 const CString& CTGitPath::GetGitPathString() const
222 if(m_sFwdslashPath.IsEmpty())
224 SetFwdslashPath(m_sBackslashPath);
226 return m_sFwdslashPath;
229 const CString &CTGitPath::GetGitOldPathString() const
231 return m_sOldFwdslashPath;
233 #if 0
234 const char* CTGitPath::GetGitApiPath(apr_pool_t *pool) const
236 // This funny-looking 'if' is to avoid a subtle problem with empty paths, whereby
237 // each call to GetGitApiPath returns a different pointer value.
238 // If you made multiple calls to GetGitApiPath on the same string, only the last
239 // one would give you a valid pointer to an empty string, because each
240 // call would invalidate the previous call's return.
241 if(IsEmpty())
243 return "";
245 if(m_sFwdslashPath.IsEmpty())
247 SetFwdslashPath(m_sBackslashPath);
249 if(m_sUTF8FwdslashPath.IsEmpty())
251 SetUTF8FwdslashPath(m_sFwdslashPath);
253 if (svn_path_is_url(m_sUTF8FwdslashPath))
255 m_sUTF8FwdslashPathEscaped = CPathUtils::PathEscape(m_sUTF8FwdslashPath);
256 m_sUTF8FwdslashPathEscaped.Replace("file:////", "file:///\\");
257 m_sUTF8FwdslashPathEscaped = svn_path_canonicalize(m_sUTF8FwdslashPathEscaped, pool);
258 return m_sUTF8FwdslashPathEscaped;
260 m_sUTF8FwdslashPath = svn_path_canonicalize(m_sUTF8FwdslashPath, pool);
262 return m_sUTF8FwdslashPath;
264 #endif
266 const CString& CTGitPath::GetUIPathString() const
268 if (m_sUIPath.IsEmpty())
270 #if defined(_MFC_VER)
271 //BUGBUG HORRIBLE!!! - CPathUtils::IsEscaped doesn't need to be MFC-only
272 if (IsUrl())
274 m_sUIPath = CPathUtils::PathUnescape(GetGitPathString());
275 m_sUIPath.Replace(_T("file:////"), _T("file:///\\"));
278 else
279 #endif
281 m_sUIPath = GetWinPathString();
284 return m_sUIPath;
287 void CTGitPath::SetFwdslashPath(const CString& sPath) const
289 m_sFwdslashPath = sPath;
290 m_sFwdslashPath.Replace('\\', '/');
292 // We don't leave a trailing /
293 m_sFwdslashPath.TrimRight('/');
295 SanitizeRootPath(m_sFwdslashPath, true);
297 m_sFwdslashPath.Replace(_T("file:////"), _T("file:///\\"));
299 m_sUTF8FwdslashPath.Empty();
302 void CTGitPath::SetBackslashPath(const CString& sPath) const
304 m_sBackslashPath = sPath;
305 m_sBackslashPath.Replace('/', '\\');
306 m_sBackslashPath.TrimRight('\\');
307 SanitizeRootPath(m_sBackslashPath, false);
310 void CTGitPath::SetUTF8FwdslashPath(const CString& sPath) const
312 m_sUTF8FwdslashPath = CUnicodeUtils::GetUTF8(sPath);
315 void CTGitPath::SanitizeRootPath(CString& sPath, bool bIsForwardPath) const
317 // Make sure to add the trailing slash to root paths such as 'C:'
318 if (sPath.GetLength() == 2 && sPath[1] == ':')
320 sPath += (bIsForwardPath) ? _T("/") : _T("\\");
324 bool CTGitPath::IsUrl() const
326 #if 0
327 if (!m_bURLKnown)
329 EnsureFwdslashPathSet();
330 if(m_sUTF8FwdslashPath.IsEmpty())
332 SetUTF8FwdslashPath(m_sFwdslashPath);
334 m_bIsURL = !!svn_path_is_url(m_sUTF8FwdslashPath);
335 m_bURLKnown = true;
337 return m_bIsURL;
338 #endif
339 return false;
342 bool CTGitPath::IsDirectory() const
344 if(!m_bDirectoryKnown)
346 UpdateAttributes();
348 return m_bIsDirectory;
351 bool CTGitPath::Exists() const
353 if (!m_bExistsKnown)
355 UpdateAttributes();
357 return m_bExists;
360 bool CTGitPath::Delete(bool bTrash) const
362 EnsureBackslashPathSet();
363 ::SetFileAttributes(m_sBackslashPath, FILE_ATTRIBUTE_NORMAL);
364 bool bRet = false;
365 if (Exists())
367 if ((bTrash)||(IsDirectory()))
369 TCHAR * buf = new TCHAR[m_sBackslashPath.GetLength()+2];
370 _tcscpy_s(buf, m_sBackslashPath.GetLength()+2, m_sBackslashPath);
371 buf[m_sBackslashPath.GetLength()] = 0;
372 buf[m_sBackslashPath.GetLength()+1] = 0;
373 SHFILEOPSTRUCT shop = {0};
374 shop.wFunc = FO_DELETE;
375 shop.pFrom = buf;
376 shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT;
377 if (bTrash)
378 shop.fFlags |= FOF_ALLOWUNDO;
379 bRet = (SHFileOperation(&shop) == 0);
380 delete [] buf;
382 else
384 bRet = !!::DeleteFile(m_sBackslashPath);
387 m_bExists = false;
388 m_bExistsKnown = true;
389 return bRet;
392 __int64 CTGitPath::GetLastWriteTime() const
394 if(!m_bLastWriteTimeKnown)
396 UpdateAttributes();
398 return m_lastWriteTime;
401 bool CTGitPath::IsReadOnly() const
403 if(!m_bLastWriteTimeKnown)
405 UpdateAttributes();
407 return m_bIsReadOnly;
410 void CTGitPath::UpdateAttributes() const
412 EnsureBackslashPathSet();
413 WIN32_FILE_ATTRIBUTE_DATA attribs;
414 if(GetFileAttributesEx(m_sBackslashPath, GetFileExInfoStandard, &attribs))
416 m_bIsDirectory = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
417 m_lastWriteTime = *(__int64*)&attribs.ftLastWriteTime;
418 m_bIsReadOnly = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_READONLY);
419 m_bExists = true;
421 else
423 DWORD err = GetLastError();
424 if ((err == ERROR_FILE_NOT_FOUND)||(err == ERROR_PATH_NOT_FOUND)||(err == ERROR_INVALID_NAME))
426 m_bIsDirectory = false;
427 m_lastWriteTime = 0;
428 m_bExists = false;
430 else
432 m_bIsDirectory = false;
433 m_lastWriteTime = 0;
434 m_bExists = true;
435 return;
438 m_bDirectoryKnown = true;
439 m_bLastWriteTimeKnown = true;
440 m_bExistsKnown = true;
443 CTGitPath CTGitPath::GetSubPath(const CTGitPath &root)
445 CTGitPath path;
447 if(GetWinPathString().Left(root.GetWinPathString().GetLength()) == root.GetWinPathString())
449 CString str=GetWinPathString();
450 path.SetFromWin(str.Right(str.GetLength()-root.GetWinPathString().GetLength()-1));
452 return path;
455 void CTGitPath::EnsureBackslashPathSet() const
457 if(m_sBackslashPath.IsEmpty())
459 SetBackslashPath(m_sFwdslashPath);
460 ATLASSERT(IsEmpty() || !m_sBackslashPath.IsEmpty());
463 void CTGitPath::EnsureFwdslashPathSet() const
465 if(m_sFwdslashPath.IsEmpty())
467 SetFwdslashPath(m_sBackslashPath);
468 ATLASSERT(IsEmpty() || !m_sFwdslashPath.IsEmpty());
473 // Reset all the caches
474 void CTGitPath::Reset()
476 m_bDirectoryKnown = false;
477 m_bURLKnown = false;
478 m_bLastWriteTimeKnown = false;
479 m_bHasAdminDirKnown = false;
480 m_bIsValidOnWindowsKnown = false;
481 m_bIsAdminDirKnown = false;
482 m_bExistsKnown = false;
483 m_bIsSpecialDirectoryKnown = false;
484 m_bIsSpecialDirectory = false;
486 m_sBackslashPath.Empty();
487 m_sFwdslashPath.Empty();
488 m_sUTF8FwdslashPath.Empty();
489 this->m_Action=0;
490 this->m_StatAdd=_T("");
491 this->m_StatDel=_T("");
492 m_ParentNo=0;
493 ATLASSERT(IsEmpty());
496 CTGitPath CTGitPath::GetDirectory() const
498 if ((IsDirectory())||(!Exists()))
500 return *this;
502 return GetContainingDirectory();
505 CTGitPath CTGitPath::GetContainingDirectory() const
507 EnsureBackslashPathSet();
509 CString sDirName = m_sBackslashPath.Left(m_sBackslashPath.ReverseFind('\\'));
510 if(sDirName.GetLength() == 2 && sDirName[1] == ':')
512 // This is a root directory, which needs a trailing slash
513 sDirName += '\\';
514 if(sDirName == m_sBackslashPath)
516 // We were clearly provided with a root path to start with - we should return nothing now
517 sDirName.Empty();
520 if(sDirName.GetLength() == 1 && sDirName[0] == '\\')
522 // We have an UNC path and we already are the root
523 sDirName.Empty();
525 CTGitPath retVal;
526 retVal.SetFromWin(sDirName);
527 return retVal;
530 CString CTGitPath::GetRootPathString() const
532 EnsureBackslashPathSet();
533 CString workingPath = m_sBackslashPath;
534 LPTSTR pPath = workingPath.GetBuffer(MAX_PATH); // MAX_PATH ok here.
535 ATLVERIFY(::PathStripToRoot(pPath));
536 workingPath.ReleaseBuffer();
537 return workingPath;
541 CString CTGitPath::GetFilename() const
543 //ATLASSERT(!IsDirectory());
544 return GetFileOrDirectoryName();
547 CString CTGitPath::GetFileOrDirectoryName() const
549 EnsureBackslashPathSet();
550 return m_sBackslashPath.Mid(m_sBackslashPath.ReverseFind('\\')+1);
553 CString CTGitPath::GetUIFileOrDirectoryName() const
555 GetUIPathString();
556 return m_sUIPath.Mid(m_sUIPath.ReverseFind('\\')+1);
559 CString CTGitPath::GetFileExtension() const
561 if(!IsDirectory())
563 EnsureBackslashPathSet();
564 int dotPos = m_sBackslashPath.ReverseFind('.');
565 int slashPos = m_sBackslashPath.ReverseFind('\\');
566 if (dotPos > slashPos)
567 return m_sBackslashPath.Mid(dotPos);
569 return CString();
571 CString CTGitPath::GetBaseFilename() const
573 int dot;
574 CString filename=GetFilename();
575 dot = filename.ReverseFind(_T('.'));
576 if(dot>0)
577 return filename.Left(dot);
578 else
579 return filename;
582 bool CTGitPath::ArePathStringsEqual(const CString& sP1, const CString& sP2)
584 int length = sP1.GetLength();
585 if(length != sP2.GetLength())
587 // Different lengths
588 return false;
590 // We work from the end of the strings, because path differences
591 // are more likely to occur at the far end of a string
592 LPCTSTR pP1Start = sP1;
593 LPCTSTR pP1 = pP1Start+(length-1);
594 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
595 while(length-- > 0)
597 if(_totlower(*pP1--) != _totlower(*pP2--))
599 return false;
602 return true;
605 bool CTGitPath::ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2)
607 int length = sP1.GetLength();
608 if(length != sP2.GetLength())
610 // Different lengths
611 return false;
613 // We work from the end of the strings, because path differences
614 // are more likely to occur at the far end of a string
615 LPCTSTR pP1Start = sP1;
616 LPCTSTR pP1 = pP1Start+(length-1);
617 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
618 while(length-- > 0)
620 if((*pP1--) != (*pP2--))
622 return false;
625 return true;
628 bool CTGitPath::IsEmpty() const
630 // Check the backward slash path first, since the chance that this
631 // one is set is higher. In case of a 'false' return value it's a little
632 // bit faster.
633 return m_sBackslashPath.IsEmpty() && m_sFwdslashPath.IsEmpty();
636 // Test if both paths refer to the same item
637 // Ignores case and slash direction
638 bool CTGitPath::IsEquivalentTo(const CTGitPath& rhs) const
640 // Try and find a slash direction which avoids having to convert
641 // both filenames
642 if(!m_sBackslashPath.IsEmpty())
644 // *We've* got a \ path - make sure that the RHS also has a \ path
645 rhs.EnsureBackslashPathSet();
646 return ArePathStringsEqualWithCase(m_sBackslashPath, rhs.m_sBackslashPath);
648 else
650 // Assume we've got a fwdslash path and make sure that the RHS has one
651 rhs.EnsureFwdslashPathSet();
652 return ArePathStringsEqualWithCase(m_sFwdslashPath, rhs.m_sFwdslashPath);
656 bool CTGitPath::IsEquivalentToWithoutCase(const CTGitPath& rhs) const
658 // Try and find a slash direction which avoids having to convert
659 // both filenames
660 if(!m_sBackslashPath.IsEmpty())
662 // *We've* got a \ path - make sure that the RHS also has a \ path
663 rhs.EnsureBackslashPathSet();
664 return ArePathStringsEqual(m_sBackslashPath, rhs.m_sBackslashPath);
666 else
668 // Assume we've got a fwdslash path and make sure that the RHS has one
669 rhs.EnsureFwdslashPathSet();
670 return ArePathStringsEqual(m_sFwdslashPath, rhs.m_sFwdslashPath);
674 bool CTGitPath::IsAncestorOf(const CTGitPath& possibleDescendant) const
676 possibleDescendant.EnsureBackslashPathSet();
677 EnsureBackslashPathSet();
679 bool bPathStringsEqual = ArePathStringsEqual(m_sBackslashPath, possibleDescendant.m_sBackslashPath.Left(m_sBackslashPath.GetLength()));
680 if (m_sBackslashPath.GetLength() >= possibleDescendant.GetWinPathString().GetLength())
682 return bPathStringsEqual;
685 return (bPathStringsEqual &&
686 ((possibleDescendant.m_sBackslashPath[m_sBackslashPath.GetLength()] == '\\')||
687 (m_sBackslashPath.GetLength()==3 && m_sBackslashPath[1]==':')));
690 // Get a string representing the file path, optionally with a base
691 // section stripped off the front.
692 CString CTGitPath::GetDisplayString(const CTGitPath* pOptionalBasePath /* = NULL*/) const
694 EnsureFwdslashPathSet();
695 if(pOptionalBasePath != NULL)
697 // Find the length of the base-path without having to do an 'ensure' on it
698 int baseLength = max(pOptionalBasePath->m_sBackslashPath.GetLength(), pOptionalBasePath->m_sFwdslashPath.GetLength());
700 // Now, chop that baseLength of the front of the path
701 return m_sFwdslashPath.Mid(baseLength).TrimLeft('/');
703 return m_sFwdslashPath;
706 int CTGitPath::Compare(const CTGitPath& left, const CTGitPath& right)
708 left.EnsureBackslashPathSet();
709 right.EnsureBackslashPathSet();
710 return left.m_sBackslashPath.CompareNoCase(right.m_sBackslashPath);
713 bool operator<(const CTGitPath& left, const CTGitPath& right)
715 return CTGitPath::Compare(left, right) < 0;
718 bool CTGitPath::PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right)
720 return left.IsEquivalentTo(right);
723 bool CTGitPath::PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right)
725 if (left.IsAdminDir() && right.IsAdminDir())
727 CTGitPath l = left;
728 CTGitPath r = right;
731 l = l.GetContainingDirectory();
732 } while(l.HasAdminDir());
735 r = r.GetContainingDirectory();
736 } while(r.HasAdminDir());
737 return l.GetContainingDirectory().IsEquivalentTo(r.GetContainingDirectory());
739 return left.GetDirectory().IsEquivalentTo(right.GetDirectory());
742 bool CTGitPath::CheckChild(const CTGitPath &parent, const CTGitPath& child)
744 return parent.IsAncestorOf(child);
747 void CTGitPath::AppendRawString(const CString& sAppend)
749 EnsureFwdslashPathSet();
750 CString strCopy = m_sFwdslashPath += sAppend;
751 SetFromUnknown(strCopy);
754 void CTGitPath::AppendPathString(const CString& sAppend)
756 EnsureBackslashPathSet();
757 CString cleanAppend(sAppend);
758 cleanAppend.Replace('/', '\\');
759 cleanAppend.TrimLeft('\\');
760 m_sBackslashPath.TrimRight('\\');
761 CString strCopy = m_sBackslashPath + _T("\\") + cleanAppend;
762 SetFromWin(strCopy);
765 bool CTGitPath::IsWCRoot() const
767 if (m_bIsWCRootKnown)
768 return m_bIsWCRoot;
770 m_bIsWCRootKnown = true;
771 m_bIsWCRoot = false;
773 CString topDirectory;
774 if (!IsDirectory() || !HasAdminDir(&topDirectory))
776 return m_bIsWCRoot;
779 if (IsEquivalentToWithoutCase(topDirectory))
781 m_bIsWCRoot = true;
784 return m_bIsWCRoot;
787 bool CTGitPath::HasAdminDir() const
789 if (m_bHasAdminDirKnown)
790 return m_bHasAdminDir;
792 EnsureBackslashPathSet();
793 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
794 m_bHasAdminDirKnown = true;
795 return m_bHasAdminDir;
798 bool CTGitPath::HasSubmodules() const
800 if (HasAdminDir())
802 CString path = m_sProjectRoot;
803 path += _T("\\.gitmodules");
804 if( PathFileExists(path) )
805 return true;
807 return false;
810 int CTGitPath::GetAdminDirMask() const
812 int status = 0;
813 CString topdir;
814 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
816 return status;
819 // ITEMIS_INGIT will be revoked if necessary in TortoiseShell/ContextMenu.cpp
820 status |= ITEMIS_INGIT|ITEMIS_INVERSIONEDFOLDER;
822 if (IsDirectory())
824 status |= ITEMIS_FOLDERINGIT;
825 if (IsWCRoot())
826 status |= ITEMIS_WCROOT;
829 CString dotGitPath;
830 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
832 if (PathFileExists(dotGitPath + _T("BISECT_START")))
833 status |= ITEMIS_BISECT;
835 if (PathFileExists(dotGitPath + _T("refs\\stash")))
836 status |= ITEMIS_STASH;
838 if (PathFileExists(dotGitPath + _T("svn")))
839 status |= ITEMIS_GITSVN;
841 if (PathFileExists(topdir + _T("\\.gitmodules")))
842 status |= ITEMIS_SUBMODULECONTAINER;
844 return status;
847 bool CTGitPath::HasStashDir() const
849 CString topdir;
850 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
852 return false;
855 CString dotGitPath;
856 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
858 return !!PathFileExists(dotGitPath + _T("\\refs\\stash"));
860 bool CTGitPath::HasGitSVNDir() const
862 CString topdir;
863 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
865 return false;
868 CString dotGitPath;
869 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
871 return !!PathFileExists(dotGitPath + _T("svn"));
873 bool CTGitPath::IsBisectActive() const
875 CString topdir;
876 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
878 return false;
881 CString dotGitPath;
882 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
884 return !!PathFileExists(dotGitPath + _T("BISECT_START"));
886 bool CTGitPath::IsMergeActive() const
888 CString topdir;
889 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
891 return false;
894 CString dotGitPath;
895 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
897 return !!PathFileExists(dotGitPath + _T("MERGE_HEAD"));
899 bool CTGitPath::HasRebaseApply() const
901 CString topdir;
902 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
904 return false;
907 CString dotGitPath;
908 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
910 return !!PathFileExists(dotGitPath + _T("rebase-apply"));
913 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const
915 if (m_bHasAdminDirKnown)
917 if (ProjectTopDir)
918 *ProjectTopDir = m_sProjectRoot;
919 return m_bHasAdminDir;
922 EnsureBackslashPathSet();
923 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
924 m_bHasAdminDirKnown = true;
925 if (ProjectTopDir)
926 *ProjectTopDir = m_sProjectRoot;
927 return m_bHasAdminDir;
930 bool CTGitPath::IsAdminDir() const
932 if (m_bIsAdminDirKnown)
933 return m_bIsAdminDir;
935 EnsureBackslashPathSet();
936 m_bIsAdminDir = g_GitAdminDir.IsAdminDirPath(m_sBackslashPath);
937 m_bIsAdminDirKnown = true;
938 return m_bIsAdminDir;
941 bool CTGitPath::IsValidOnWindows() const
943 if (m_bIsValidOnWindowsKnown)
944 return m_bIsValidOnWindows;
946 m_bIsValidOnWindows = false;
947 EnsureBackslashPathSet();
948 CString sMatch = m_sBackslashPath + _T("\r\n");
949 wstring sPattern;
950 // the 'file://' URL is just a normal windows path:
951 if (sMatch.Left(7).CompareNoCase(_T("file:\\\\"))==0)
953 sMatch = sMatch.Mid(7);
954 sMatch.TrimLeft(_T("\\"));
955 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
957 else if (IsUrl())
959 sPattern = _T("^((http|https|svn|svn\\+ssh|file)\\:\\\\+([^\\\\@\\:]+\\:[^\\\\@\\:]+@)?\\\\[^\\\\]+(\\:\\d+)?)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<>\\. ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
961 else
963 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
968 tr1::wregex rx(sPattern, tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
969 tr1::wsmatch match;
971 wstring rmatch = wstring((LPCTSTR)sMatch);
972 if (tr1::regex_match(rmatch, match, rx))
974 if (wstring(match[0]).compare(sMatch)==0)
975 m_bIsValidOnWindows = true;
977 if (m_bIsValidOnWindows)
979 // now check for illegal filenames
980 tr1::wregex rx2(_T("\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$)"), tr1::regex_constants::icase | tr1::regex_constants::ECMAScript);
981 rmatch = m_sBackslashPath;
982 if (tr1::regex_search(rmatch, rx2, tr1::regex_constants::match_default))
983 m_bIsValidOnWindows = false;
986 catch (exception) {}
988 m_bIsValidOnWindowsKnown = true;
989 return m_bIsValidOnWindows;
992 bool CTGitPath::IsSpecialDirectory() const
994 if (m_bIsSpecialDirectoryKnown)
995 return m_bIsSpecialDirectory;
997 static LPCTSTR specialDirectories[]
998 = { _T("trunk"), _T("tags"), _T("branches") };
1000 for (int i = 0; i < _countof(specialDirectories); ++i)
1002 CString name = GetFileOrDirectoryName();
1003 if (0 == name.CompareNoCase(specialDirectories[i]))
1005 m_bIsSpecialDirectory = true;
1006 break;
1010 m_bIsSpecialDirectoryKnown = true;
1012 return m_bIsSpecialDirectory;
1015 //////////////////////////////////////////////////////////////////////////
1017 CTGitPathList::CTGitPathList()
1022 // A constructor which allows a path list to be easily built which one initial entry in
1023 CTGitPathList::CTGitPathList(const CTGitPath& firstEntry)
1025 AddPath(firstEntry);
1027 int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool /*staged*/)
1029 unsigned int pos=0;
1030 CString one;
1031 CTGitPath path;
1032 CString part;
1033 this->Clear();
1035 while(pos>=0 && pos<out.size())
1037 one.Empty();
1038 path.Reset();
1040 g_Git.StringAppend(&one,&out[pos],CP_ACP);
1041 int tabstart=0;
1042 path.m_Action=path.ParserAction(out[pos]);
1043 one.Tokenize(_T("\t"),tabstart);
1045 if(tabstart>=0)
1046 path.SetFromGit(one.Right(one.GetLength()-tabstart));
1048 tabstart=0;
1050 part=one.Tokenize(_T(" "),tabstart); //Tag
1052 part=one.Tokenize(_T(" "),tabstart); //Mode
1054 part=one.Tokenize(_T(" "),tabstart); //Hash
1056 part=one.Tokenize(_T("\t"),tabstart); //Stage
1058 path.m_Stage=_ttol(part);
1060 this->AddPath(path);
1062 pos=out.findNextString(pos);
1064 return pos;
1066 int CTGitPathList::FillUnRev(unsigned int action,CTGitPathList *list)
1068 int pos=0;
1069 this->Clear();
1070 CTGitPath path;
1072 int count;
1073 if(list==NULL)
1074 count=1;
1075 else
1076 count=list->GetCount();
1077 for(int i=0;i<count;i++)
1079 CString cmd;
1080 pos=0;
1082 CString ignored;
1083 if(action & CTGitPath::LOGACTIONS_IGNORE)
1084 ignored= _T(" -i");
1086 if(list==NULL)
1088 cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");
1089 cmd+=ignored;
1092 else
1093 { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z%s -- \"%s\""),
1094 ignored,
1095 (*list)[i].GetWinPathString());
1098 BYTE_VECTOR out;
1099 out.clear();
1100 g_Git.Run(cmd, &out);
1102 pos=0;
1103 CString one;
1104 while( pos>=0 && pos<out.size())
1106 one.Empty();
1107 g_Git.StringAppend(&one,&out[pos],CP_ACP);
1108 if(!one.IsEmpty())
1110 //SetFromGit will clear all status
1111 path.SetFromGit(one);
1112 path.m_Action=action;
1113 AddPath(path);
1115 pos=out.findNextString(pos);
1119 return 0;
1121 int CTGitPathList::ParserFromLog(BYTE_VECTOR &log, bool parseDeletes /*false*/)
1123 this->Clear();
1124 int pos=0;
1125 //BYTE *p=&log[0];
1126 //CString one;
1127 CTGitPath path;
1128 m_Action=0;
1129 while( pos>=0 && pos<log.size())
1131 //one=log.Tokenize(_T("\n"),pos);
1132 path.Reset();
1133 if(log[pos]=='\n')
1134 pos++;
1136 if(log[pos]==':')
1138 bool merged=false;
1139 if(log[pos+1] ==':')
1141 merged=true;
1143 int end=log.find(0,pos);
1144 int actionstart=-1;
1145 int numfile=1;
1146 int file1=-1,file2=-1;
1147 if( end>0 )
1149 actionstart=log.find(' ',end-6);
1150 pos=actionstart;
1152 if( actionstart>0 )
1154 actionstart++;
1156 file1 = log.find(0,actionstart);
1157 if( file1>=0 )
1159 file1++;
1160 pos=file1;
1162 if( log[actionstart] == 'C' || log[actionstart] == 'R' )
1164 file2=file1;
1165 numfile=2;
1166 file1 = log.find(0,file1);
1167 if(file1>=0 )
1169 file1++;
1170 pos=file1;
1176 CString pathname1;
1177 CString pathname2;
1179 if( file1>=0 )
1180 g_Git.StringAppend(&pathname1,&log[file1],CP_ACP);
1181 if( file2>=0 )
1182 g_Git.StringAppend(&pathname2,&log[file2],CP_ACP);
1184 CTGitPath *GitPath=LookForGitPath(pathname1);
1186 if(GitPath)
1188 GitPath->ParserAction( log[actionstart] );
1190 if(merged)
1192 GitPath->m_Action |= CTGitPath::LOGACTIONS_MERGED;
1193 GitPath->m_Action &= ~CTGitPath::LOGACTIONS_FORWORD;
1195 m_Action |=GitPath->m_Action;
1198 else
1200 int ac=path.ParserAction(log[actionstart] );
1201 ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;
1203 path.SetFromGit(pathname1,&pathname2);
1204 path.m_Action=ac;
1205 //action must be set after setfromgit. SetFromGit will clear all status.
1206 this->m_Action|=ac;
1208 AddPath(path);
1213 else
1215 int tabstart=0;
1216 path.Reset();
1217 CString StatAdd;
1218 CString StatDel;
1219 CString file1;
1220 CString file2;
1222 tabstart=log.find('\t',pos);
1223 if(tabstart >=0)
1225 log[tabstart]=0;
1226 g_Git.StringAppend(&StatAdd,&log[pos],CP_UTF8);
1227 pos=tabstart+1;
1230 tabstart=log.find('\t',pos);
1231 if(tabstart >=0)
1233 log[tabstart]=0;
1235 g_Git.StringAppend(&StatDel,&log[pos],CP_UTF8);
1236 pos=tabstart+1;
1239 if(log[pos] == 0) //rename
1241 pos++;
1242 g_Git.StringAppend(&file2,&log[pos],CP_ACP);
1243 int sec=log.find(0,pos);
1244 if(sec>=0)
1246 sec++;
1247 g_Git.StringAppend(&file1,&log[sec],CP_ACP);
1249 pos=sec;
1252 else
1254 g_Git.StringAppend(&file1,&log[pos],CP_ACP);
1256 path.SetFromGit(file1,&file2);
1258 CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());
1259 if(GitPath)
1261 GitPath->m_StatAdd=StatAdd;
1262 GitPath->m_StatDel=StatDel;
1264 else
1266 //path.SetFromGit(pathname);
1267 if (parseDeletes)
1269 path.m_StatAdd=_T("0");
1270 path.m_StatDel=_T("0");
1271 path.m_Action |= CTGitPath::LOGACTIONS_DELETED;
1273 else
1275 path.m_StatAdd=StatAdd;
1276 path.m_StatDel=StatDel;
1277 path.m_Action |= CTGitPath::LOGACTIONS_FORWORD;
1279 AddPath(path);
1283 pos=log.findNextString(pos);
1285 return pos;
1288 void CTGitPathList::AddPath(const CTGitPath& newPath)
1290 m_paths.push_back(newPath);
1291 m_commonBaseDirectory.Reset();
1293 int CTGitPathList::GetCount() const
1295 return (int)m_paths.size();
1297 void CTGitPathList::Clear()
1299 m_paths.clear();
1300 m_commonBaseDirectory.Reset();
1303 const CTGitPath& CTGitPathList::operator[](INT_PTR index) const
1305 ATLASSERT(index >= 0 && index < (INT_PTR)m_paths.size());
1306 return m_paths[index];
1309 bool CTGitPathList::AreAllPathsFiles() const
1311 // Look through the vector for any directories - if we find them, return false
1312 return std::find_if(m_paths.begin(), m_paths.end(), std::mem_fun_ref(&CTGitPath::IsDirectory)) == m_paths.end();
1316 #if defined(_MFC_VER)
1318 bool CTGitPathList::LoadFromFile(const CTGitPath& filename)
1320 Clear();
1323 CString strLine;
1324 CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);
1326 // for every selected file/folder
1327 CTGitPath path;
1328 while (file.ReadString(strLine))
1330 path.SetFromUnknown(strLine);
1331 AddPath(path);
1333 file.Close();
1335 catch (CFileException* pE)
1337 TRACE("CFileException loading target file list\n");
1338 TCHAR error[10000] = {0};
1339 pE->GetErrorMessage(error, 10000);
1340 // CMessageBox::Show(NULL, error, _T("TortoiseGit"), MB_ICONERROR);
1341 pE->Delete();
1342 return false;
1344 return true;
1347 bool CTGitPathList::WriteToFile(const CString& sFilename, bool bANSI /* = false */) const
1351 if (bANSI)
1353 CStdioFile file(sFilename, CFile::typeText | CFile::modeReadWrite | CFile::modeCreate);
1354 PathVector::const_iterator it;
1355 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1357 CStringA line = CStringA(it->GetGitPathString()) + '\n';
1358 file.Write(line, line.GetLength());
1360 file.Close();
1362 else
1364 CStdioFile file(sFilename, CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate);
1365 PathVector::const_iterator it;
1366 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1368 file.WriteString(it->GetGitPathString()+_T("\n"));
1370 file.Close();
1373 catch (CFileException* pE)
1375 TRACE("CFileException in writing temp file\n");
1376 pE->Delete();
1377 return false;
1379 return true;
1383 void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
1385 int pos = 0;
1386 CString temp;
1387 for(;;)
1389 temp = sPathString.Tokenize(_T("*"),pos);
1390 if(temp.IsEmpty())
1392 break;
1394 AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
1398 CString CTGitPathList::CreateAsteriskSeparatedString() const
1400 CString sRet;
1401 PathVector::const_iterator it;
1402 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1404 if (!sRet.IsEmpty())
1405 sRet += _T("*");
1406 sRet += it->GetWinPathString();
1408 return sRet;
1410 #endif // _MFC_VER
1412 bool
1413 CTGitPathList::AreAllPathsFilesInOneDirectory() const
1415 // Check if all the paths are files and in the same directory
1416 PathVector::const_iterator it;
1417 m_commonBaseDirectory.Reset();
1418 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1420 if(it->IsDirectory())
1422 return false;
1424 const CTGitPath& baseDirectory = it->GetDirectory();
1425 if(m_commonBaseDirectory.IsEmpty())
1427 m_commonBaseDirectory = baseDirectory;
1429 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1431 // Different path
1432 m_commonBaseDirectory.Reset();
1433 return false;
1436 return true;
1439 CTGitPath CTGitPathList::GetCommonDirectory() const
1441 if (m_commonBaseDirectory.IsEmpty())
1443 PathVector::const_iterator it;
1444 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1446 const CTGitPath& baseDirectory = it->GetDirectory();
1447 if(m_commonBaseDirectory.IsEmpty())
1449 m_commonBaseDirectory = baseDirectory;
1451 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1453 // Different path
1454 m_commonBaseDirectory.Reset();
1455 break;
1459 // since we only checked strings, not paths,
1460 // we have to make sure now that we really return a *path* here
1461 PathVector::const_iterator iter;
1462 for(iter = m_paths.begin(); iter != m_paths.end(); ++iter)
1464 if (!m_commonBaseDirectory.IsAncestorOf(*iter))
1466 m_commonBaseDirectory = m_commonBaseDirectory.GetContainingDirectory();
1467 break;
1470 return m_commonBaseDirectory;
1473 CTGitPath CTGitPathList::GetCommonRoot() const
1475 PathVector::const_iterator it;
1476 CString sRoot, sTempRoot;
1477 bool bEqual = true;
1479 if (GetCount() == 1)
1480 return m_paths[0];
1482 int backSlashPos = 0;
1483 int searchStartPos = 0;
1484 while (bEqual)
1486 if(m_paths.empty())
1487 break;
1489 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1491 if (backSlashPos == 0)
1493 backSlashPos = it->GetWinPathString().Find('\\', searchStartPos+1);
1494 if ((backSlashPos < 0)&&(searchStartPos != it->GetWinPathString().GetLength()))
1495 backSlashPos = it->GetWinPathString().GetLength();
1496 sTempRoot = it->GetWinPathString().Left(backSlashPos+1);
1498 else if (it->GetWinPathString().Find('\\', searchStartPos+1) != backSlashPos || it->GetWinPathString().Left(backSlashPos+1) != sTempRoot.Left(backSlashPos+1))
1500 if (it->GetWinPathString().Find('\\', searchStartPos+1) < 0)
1502 if (it->GetWinPathString().GetLength() != backSlashPos || it->GetWinPathString().Left(backSlashPos+1) != sTempRoot.Left(backSlashPos+1))
1504 bEqual = false;
1505 break;
1508 else
1510 bEqual = false;
1511 break;
1514 if (backSlashPos < 0)
1516 bEqual = false;
1517 break;
1520 if (bEqual == false)
1522 if (searchStartPos)
1523 sRoot = m_paths[0].GetWinPathString().Left(searchStartPos+1);
1525 else
1527 searchStartPos = backSlashPos;
1529 backSlashPos = 0;
1532 return CTGitPath(sRoot.TrimRight('\\'));
1535 void CTGitPathList::SortByPathname(bool bReverse /*= false*/)
1537 std::sort(m_paths.begin(), m_paths.end());
1538 if (bReverse)
1539 std::reverse(m_paths.begin(), m_paths.end());
1542 void CTGitPathList::DeleteAllFiles(bool bTrash)
1544 PathVector::const_iterator it;
1545 if (bTrash)
1547 SortByPathname();
1548 CString sPaths;
1549 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1551 if ((it->Exists())&&(!it->IsDirectory()))
1553 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1554 sPaths += it->GetWinPath();
1555 sPaths += '\0';
1558 sPaths += '\0';
1559 sPaths += '\0';
1560 SHFILEOPSTRUCT shop = {0};
1561 shop.wFunc = FO_DELETE;
1562 shop.pFrom = (LPCTSTR)sPaths;
1563 shop.fFlags = FOF_ALLOWUNDO|FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT;
1564 SHFileOperation(&shop);
1566 else
1568 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1570 if (!it->IsDirectory())
1572 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1573 ::DeleteFile(it->GetWinPath());
1577 Clear();
1580 void CTGitPathList::RemoveDuplicates()
1582 SortByPathname();
1583 // Remove the duplicates
1584 // (Unique moves them to the end of the vector, then erase chops them off)
1585 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::PredLeftEquivalentToRight), m_paths.end());
1588 void CTGitPathList::RemoveAdminPaths()
1590 PathVector::iterator it;
1591 for(it = m_paths.begin(); it != m_paths.end(); )
1593 if (it->IsAdminDir())
1595 m_paths.erase(it);
1596 it = m_paths.begin();
1598 else
1599 ++it;
1603 void CTGitPathList::RemovePath(const CTGitPath& path)
1605 PathVector::iterator it;
1606 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1608 if (it->IsEquivalentTo(path))
1610 m_paths.erase(it);
1611 return;
1616 void CTGitPathList::RemoveItem(CTGitPath & path)
1618 PathVector::iterator it;
1619 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1621 if (it->GetGitPathString()==path.GetGitPathString())
1623 m_paths.erase(it);
1624 return;
1628 void CTGitPathList::RemoveChildren()
1630 SortByPathname();
1631 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::CheckChild), m_paths.end());
1634 bool CTGitPathList::IsEqual(const CTGitPathList& list)
1636 if (list.GetCount() != GetCount())
1637 return false;
1638 for (int i=0; i<list.GetCount(); ++i)
1640 if (!list[i].IsEquivalentTo(m_paths[i]))
1641 return false;
1643 return true;
1646 //////////////////////////////////////////////////////////////////////////
1647 #if 0
1648 apr_array_header_t * CTGitPathList::MakePathArray (apr_pool_t *pool) const
1650 apr_array_header_t *targets = apr_array_make (pool, GetCount(), sizeof(const char *));
1652 for(int nItem = 0; nItem < GetCount(); nItem++)
1654 const char * target = m_paths[nItem].GetGitApiPath(pool);
1655 (*((const char **) apr_array_push (targets))) = target;
1658 return targets;
1660 #endif
1661 //////////////////////////////////////////////////////////////////////////
1663 #if 0
1664 #if defined(_DEBUG)
1665 // Some test cases for these classes
1666 static class CTGitPathTests
1668 public:
1669 CTGitPathTests()
1671 apr_initialize();
1672 pool = svn_pool_create(NULL);
1673 GetDirectoryTest();
1674 AdminDirTest();
1675 SortTest();
1676 RawAppendTest();
1677 PathAppendTest();
1678 RemoveDuplicatesTest();
1679 RemoveChildrenTest();
1680 ContainingDirectoryTest();
1681 AncestorTest();
1682 SubversionPathTest();
1683 GetCommonRootTest();
1684 #if defined(_MFC_VER)
1685 ValidPathAndUrlTest();
1686 ListLoadingTest();
1687 #endif
1688 apr_terminate();
1691 private:
1692 // apr_pool_t * pool;
1693 void GetDirectoryTest()
1695 // Bit tricky, this test, because we need to know something about the file
1696 // layout on the machine which is running the test
1697 TCHAR winDir[MAX_PATH+1];
1698 GetWindowsDirectory(winDir, MAX_PATH);
1699 CString sWinDir(winDir);
1701 CTGitPath testPath;
1702 // This is a file which we know will always be there
1703 testPath.SetFromUnknown(sWinDir + _T("\\win.ini"));
1704 ATLASSERT(!testPath.IsDirectory());
1705 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1706 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() == sWinDir);
1708 // Now do the test on the win directory itself - It's hard to be sure about the containing directory
1709 // but we know it must be different to the directory itself
1710 testPath.SetFromUnknown(sWinDir);
1711 ATLASSERT(testPath.IsDirectory());
1712 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1713 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() != sWinDir);
1714 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString().GetLength() < sWinDir.GetLength());
1716 // Try a root path
1717 testPath.SetFromUnknown(_T("C:\\"));
1718 ATLASSERT(testPath.IsDirectory());
1719 ATLASSERT(testPath.GetDirectory().GetWinPathString().CompareNoCase(_T("C:\\"))==0);
1720 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1721 // Try a root UNC path
1722 testPath.SetFromUnknown(_T("\\MYSTATION"));
1723 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1726 void AdminDirTest()
1728 CTGitPath testPath;
1729 testPath.SetFromUnknown(_T("c:\\.svndir"));
1730 ATLASSERT(!testPath.IsAdminDir());
1731 testPath.SetFromUnknown(_T("c:\\test.svn"));
1732 ATLASSERT(!testPath.IsAdminDir());
1733 testPath.SetFromUnknown(_T("c:\\.svn"));
1734 ATLASSERT(testPath.IsAdminDir());
1735 testPath.SetFromUnknown(_T("c:\\.svndir\\test"));
1736 ATLASSERT(!testPath.IsAdminDir());
1737 testPath.SetFromUnknown(_T("c:\\.svn\\test"));
1738 ATLASSERT(testPath.IsAdminDir());
1740 CTGitPathList pathList;
1741 pathList.AddPath(CTGitPath(_T("c:\\.svndir")));
1742 pathList.AddPath(CTGitPath(_T("c:\\.svn")));
1743 pathList.AddPath(CTGitPath(_T("c:\\.svn\\test")));
1744 pathList.AddPath(CTGitPath(_T("c:\\test")));
1745 pathList.RemoveAdminPaths();
1746 ATLASSERT(pathList.GetCount()==2);
1747 pathList.Clear();
1748 pathList.AddPath(CTGitPath(_T("c:\\test")));
1749 pathList.RemoveAdminPaths();
1750 ATLASSERT(pathList.GetCount()==1);
1753 void SortTest()
1755 CTGitPathList testList;
1756 CTGitPath testPath;
1757 testPath.SetFromUnknown(_T("c:/Z"));
1758 testList.AddPath(testPath);
1759 testPath.SetFromUnknown(_T("c:/B"));
1760 testList.AddPath(testPath);
1761 testPath.SetFromUnknown(_T("c:\\a"));
1762 testList.AddPath(testPath);
1763 testPath.SetFromUnknown(_T("c:/Test"));
1764 testList.AddPath(testPath);
1766 testList.SortByPathname();
1768 ATLASSERT(testList[0].GetWinPathString() == _T("c:\\a"));
1769 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\B"));
1770 ATLASSERT(testList[2].GetWinPathString() == _T("c:\\Test"));
1771 ATLASSERT(testList[3].GetWinPathString() == _T("c:\\Z"));
1774 void RawAppendTest()
1776 CTGitPath testPath(_T("c:/test/"));
1777 testPath.AppendRawString(_T("/Hello"));
1778 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1780 testPath.AppendRawString(_T("\\T2"));
1781 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1783 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1784 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1785 testBasePath.AppendRawString(testFilePath.GetFileExtension());
1786 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt.ini"));
1789 void PathAppendTest()
1791 CTGitPath testPath(_T("c:/test/"));
1792 testPath.AppendPathString(_T("/Hello"));
1793 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1795 testPath.AppendPathString(_T("T2"));
1796 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1798 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1799 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1800 // You wouldn't want to do this in real life - you'd use append-raw
1801 testBasePath.AppendPathString(testFilePath.GetFileExtension());
1802 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt\\.ini"));
1805 void RemoveDuplicatesTest()
1807 CTGitPathList list;
1808 list.AddPath(CTGitPath(_T("Z")));
1809 list.AddPath(CTGitPath(_T("A")));
1810 list.AddPath(CTGitPath(_T("E")));
1811 list.AddPath(CTGitPath(_T("E")));
1813 ATLASSERT(list[2].IsEquivalentTo(list[3]));
1814 ATLASSERT(list[2]==list[3]);
1816 ATLASSERT(list.GetCount() == 4);
1818 list.RemoveDuplicates();
1820 ATLASSERT(list.GetCount() == 3);
1822 ATLASSERT(list[0].GetWinPathString() == _T("A"));
1823 ATLASSERT(list[1].GetWinPathString().Compare(_T("E")) == 0);
1824 ATLASSERT(list[2].GetWinPathString() == _T("Z"));
1827 void RemoveChildrenTest()
1829 CTGitPathList list;
1830 list.AddPath(CTGitPath(_T("c:\\test")));
1831 list.AddPath(CTGitPath(_T("c:\\test\\file")));
1832 list.AddPath(CTGitPath(_T("c:\\testfile")));
1833 list.AddPath(CTGitPath(_T("c:\\parent")));
1834 list.AddPath(CTGitPath(_T("c:\\parent\\child")));
1835 list.AddPath(CTGitPath(_T("c:\\parent\\child1")));
1836 list.AddPath(CTGitPath(_T("c:\\parent\\child2")));
1838 ATLASSERT(list.GetCount() == 7);
1840 list.RemoveChildren();
1842 ATLTRACE("count = %d\n", list.GetCount());
1843 ATLASSERT(list.GetCount() == 3);
1845 list.SortByPathname();
1847 ATLASSERT(list[0].GetWinPathString().Compare(_T("c:\\parent")) == 0);
1848 ATLASSERT(list[1].GetWinPathString().Compare(_T("c:\\test")) == 0);
1849 ATLASSERT(list[2].GetWinPathString().Compare(_T("c:\\testfile")) == 0);
1852 #if defined(_MFC_VER)
1853 void ListLoadingTest()
1855 TCHAR buf[MAX_PATH];
1856 GetCurrentDirectory(MAX_PATH, buf);
1857 CString sPathList(_T("Path1*c:\\path2 with spaces and stuff*\\funnypath\\*"));
1858 CTGitPathList testList;
1859 testList.LoadFromAsteriskSeparatedString(sPathList);
1861 ATLASSERT(testList.GetCount() == 3);
1862 ATLASSERT(testList[0].GetWinPathString() == CString(buf) + _T("\\Path1"));
1863 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\path2 with spaces and stuff"));
1864 ATLASSERT(testList[2].GetWinPathString() == _T("\\funnypath"));
1866 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T(""));
1867 testList.Clear();
1868 sPathList = _T("c:\\path2 with spaces and stuff*c:\\funnypath\\*");
1869 testList.LoadFromAsteriskSeparatedString(sPathList);
1870 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T("c:\\"));
1872 #endif
1874 void ContainingDirectoryTest()
1877 CTGitPath testPath;
1878 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1879 CTGitPath dir;
1880 dir = testPath.GetContainingDirectory();
1881 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c\\d"));
1882 dir = dir.GetContainingDirectory();
1883 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c"));
1884 dir = dir.GetContainingDirectory();
1885 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b"));
1886 dir = dir.GetContainingDirectory();
1887 ATLASSERT(dir.GetWinPathString() == _T("c:\\a"));
1888 dir = dir.GetContainingDirectory();
1889 ATLASSERT(dir.GetWinPathString() == _T("c:\\"));
1890 dir = dir.GetContainingDirectory();
1891 ATLASSERT(dir.IsEmpty());
1892 ATLASSERT(dir.GetWinPathString() == _T(""));
1895 void AncestorTest()
1897 CTGitPath testPath;
1898 testPath.SetFromWin(_T("c:\\windows"));
1899 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\")))==false);
1900 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows"))));
1901 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windowsdummy")))==false);
1902 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\test.txt"))));
1903 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\system32\\test.txt"))));
1906 void SubversionPathTest()
1908 CTGitPath testPath;
1909 testPath.SetFromWin(_T("c:\\"));
1910 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:") == 0);
1911 testPath.SetFromWin(_T("c:\\folder"));
1912 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/folder") == 0);
1913 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1914 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/a/b/c/d/e") == 0);
1915 testPath.SetFromUnknown(_T("http://testing/"));
1916 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing") == 0);
1917 testPath.SetFromGit(NULL);
1918 ATLASSERT(strlen(testPath.GetGitApiPath(pool))==0);
1919 #if defined(_MFC_VER)
1920 testPath.SetFromUnknown(_T("http://testing again"));
1921 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1922 testPath.SetFromUnknown(_T("http://testing%20again"));
1923 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1924 testPath.SetFromUnknown(_T("http://testing special chars \344\366\374"));
1925 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20special%20chars%20%c3%a4%c3%b6%c3%bc") == 0);
1926 #endif
1929 void GetCommonRootTest()
1931 CTGitPath pathA (_T("C:\\Development\\LogDlg.cpp"));
1932 CTGitPath pathB (_T("C:\\Development\\LogDlg.h"));
1933 CTGitPath pathC (_T("C:\\Development\\SomeDir\\LogDlg.h"));
1935 CTGitPathList list;
1936 list.AddPath(pathA);
1937 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development\\LogDlg.cpp"))==0);
1938 list.AddPath(pathB);
1939 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1940 list.AddPath(pathC);
1941 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1942 #ifdef _MFC_VER
1943 list.Clear();
1944 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");
1945 list.LoadFromAsteriskSeparatedString(sPathList);
1946 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("D:\\Development\\StExBar"))==0);
1948 list.Clear();
1949 sPathList = _T("c:\\windows\\explorer.exe*c:\\windows");
1950 list.LoadFromAsteriskSeparatedString(sPathList);
1951 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1953 list.Clear();
1954 sPathList = _T("c:\\windows\\*c:\\windows");
1955 list.LoadFromAsteriskSeparatedString(sPathList);
1956 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1958 list.Clear();
1959 sPathList = _T("c:\\windows\\system32*c:\\windows\\system");
1960 list.LoadFromAsteriskSeparatedString(sPathList);
1961 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1963 list.Clear();
1964 sPathList = _T("c:\\windowsdummy*c:\\windows");
1965 list.LoadFromAsteriskSeparatedString(sPathList);
1966 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\"))==0);
1967 #endif
1970 void ValidPathAndUrlTest()
1972 CTGitPath testPath;
1973 testPath.SetFromWin(_T("c:\\a\\b\\c.test.txt"));
1974 ATLASSERT(testPath.IsValidOnWindows());
1975 testPath.SetFromWin(_T("c:\\"));
1976 ATLASSERT(testPath.IsValidOnWindows());
1977 testPath.SetFromWin(_T("D:\\.Net\\SpindleSearch\\"));
1978 ATLASSERT(testPath.IsValidOnWindows());
1979 testPath.SetFromWin(_T("c"));
1980 ATLASSERT(testPath.IsValidOnWindows());
1981 testPath.SetFromWin(_T("c:\\test folder\\file"));
1982 ATLASSERT(testPath.IsValidOnWindows());
1983 testPath.SetFromWin(_T("c:\\folder\\"));
1984 ATLASSERT(testPath.IsValidOnWindows());
1985 testPath.SetFromWin(_T("c:\\ext.ext.ext\\ext.ext.ext.ext"));
1986 ATLASSERT(testPath.IsValidOnWindows());
1987 testPath.SetFromWin(_T("c:\\.svn"));
1988 ATLASSERT(testPath.IsValidOnWindows());
1989 testPath.SetFromWin(_T("c:\\com\\file"));
1990 ATLASSERT(testPath.IsValidOnWindows());
1991 testPath.SetFromWin(_T("c:\\test\\conf"));
1992 ATLASSERT(testPath.IsValidOnWindows());
1993 testPath.SetFromWin(_T("c:\\LPT"));
1994 ATLASSERT(testPath.IsValidOnWindows());
1995 testPath.SetFromWin(_T("c:\\test\\LPT"));
1996 ATLASSERT(testPath.IsValidOnWindows());
1997 testPath.SetFromWin(_T("c:\\com1test"));
1998 ATLASSERT(testPath.IsValidOnWindows());
1999 testPath.SetFromWin(_T("\\\\?\\c:\\test\\com1test"));
2000 ATLASSERT(testPath.IsValidOnWindows());
2002 testPath.SetFromWin(_T("\\\\Share\\filename"));
2003 ATLASSERT(testPath.IsValidOnWindows());
2004 testPath.SetFromWin(_T("\\\\Share\\filename.extension"));
2005 ATLASSERT(testPath.IsValidOnWindows());
2006 testPath.SetFromWin(_T("\\\\Share\\.svn"));
2007 ATLASSERT(testPath.IsValidOnWindows());
2009 // now the negative tests
2010 testPath.SetFromWin(_T("c:\\test:folder"));
2011 ATLASSERT(!testPath.IsValidOnWindows());
2012 testPath.SetFromWin(_T("c:\\file<name"));
2013 ATLASSERT(!testPath.IsValidOnWindows());
2014 testPath.SetFromWin(_T("c:\\something*else"));
2015 ATLASSERT(!testPath.IsValidOnWindows());
2016 testPath.SetFromWin(_T("c:\\folder\\file?nofile"));
2017 ATLASSERT(!testPath.IsValidOnWindows());
2018 testPath.SetFromWin(_T("c:\\ext.>ension"));
2019 ATLASSERT(!testPath.IsValidOnWindows());
2020 testPath.SetFromWin(_T("c:\\com1\\filename"));
2021 ATLASSERT(!testPath.IsValidOnWindows());
2022 testPath.SetFromWin(_T("c:\\com1"));
2023 ATLASSERT(!testPath.IsValidOnWindows());
2024 testPath.SetFromWin(_T("c:\\com1\\AuX"));
2025 ATLASSERT(!testPath.IsValidOnWindows());
2027 testPath.SetFromWin(_T("\\\\Share\\lpt9\\filename"));
2028 ATLASSERT(!testPath.IsValidOnWindows());
2029 testPath.SetFromWin(_T("\\\\Share\\prn"));
2030 ATLASSERT(!testPath.IsValidOnWindows());
2031 testPath.SetFromWin(_T("\\\\Share\\NUL"));
2032 ATLASSERT(!testPath.IsValidOnWindows());
2034 // now come some URL tests
2035 testPath.SetFromGit(_T("http://myserver.com/repos/trunk"));
2036 ATLASSERT(testPath.IsValidOnWindows());
2037 testPath.SetFromGit(_T("https://myserver.com/repos/trunk/file%20with%20spaces"));
2038 ATLASSERT(testPath.IsValidOnWindows());
2039 testPath.SetFromGit(_T("svn://myserver.com/repos/trunk/file with spaces"));
2040 ATLASSERT(testPath.IsValidOnWindows());
2041 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk"));
2042 ATLASSERT(testPath.IsValidOnWindows());
2043 testPath.SetFromGit(_T("http://localhost:90/repos/trunk"));
2044 ATLASSERT(testPath.IsValidOnWindows());
2045 testPath.SetFromGit(_T("file:///C:/GitRepos/Tester/Proj1/tags/t2"));
2046 ATLASSERT(testPath.IsValidOnWindows());
2047 // and some negative URL tests
2048 testPath.SetFromGit(_T("httpp://myserver.com/repos/trunk"));
2049 ATLASSERT(!testPath.IsValidOnWindows());
2050 testPath.SetFromGit(_T("https://myserver.com/rep:os/trunk/file%20with%20spaces"));
2051 ATLASSERT(!testPath.IsValidOnWindows());
2052 testPath.SetFromGit(_T("svn://myserver.com/rep<os/trunk/file with spaces"));
2053 ATLASSERT(!testPath.IsValidOnWindows());
2054 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk/prn/"));
2055 ATLASSERT(!testPath.IsValidOnWindows());
2056 testPath.SetFromGit(_T("http://localhost:90/repos/trunk/com1"));
2057 ATLASSERT(!testPath.IsValidOnWindows());
2061 } TGitPathTestobject;
2062 #endif
2063 #endif
2065 CTGitPath * CTGitPathList::LookForGitPath(CString path)
2067 int i=0;
2068 for(i=0;i<this->GetCount();i++)
2070 if((*this)[i].GetGitPathString() == path )
2071 return (CTGitPath*)&(*this)[i];
2073 return NULL;
2075 CString CTGitPath::GetActionName(int action)
2077 if(action & CTGitPath::LOGACTIONS_UNMERGED)
2078 return _T("Conflict");
2079 if(action & CTGitPath::LOGACTIONS_ADDED)
2080 return _T("Added");
2081 if(action & CTGitPath::LOGACTIONS_DELETED)
2082 return _T("Deleted");
2083 if(action & CTGitPath::LOGACTIONS_MERGED )
2084 return _T("Merged");
2086 if(action & CTGitPath::LOGACTIONS_MODIFIED)
2087 return _T("Modified");
2088 if(action & CTGitPath::LOGACTIONS_REPLACED)
2089 return _T("Rename");
2090 if(action & CTGitPath::LOGACTIONS_COPY)
2091 return _T("Copy");
2093 if(action & CTGitPath::LOGACTIONS_FORWORD )
2094 return _T("Forward");
2096 if(action & CTGitPath::LOGACTIONS_REBASE_EDIT)
2097 return _T("Edit");
2098 if(action & CTGitPath::LOGACTIONS_REBASE_SQUASH)
2099 return _T("Squash");
2100 if(action & CTGitPath::LOGACTIONS_REBASE_PICK)
2101 return _T("Pick");
2102 if(action & CTGitPath::LOGACTIONS_REBASE_SKIP)
2103 return _T("Skip");
2105 return _T("Unknown");
2107 CString CTGitPath::GetActionName()
2109 return GetActionName(m_Action);
2112 int CTGitPathList::GetAction()
2114 return m_Action;