Fix broken build by moving implementations to cpp files
[TortoiseGit.git] / src / Git / TGitPath.cpp
blob2cd29f47f7378fbbdf6a310a2411ce7c41561db7
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - TortoiseGit
4 // Copyright (C) 2010-2014 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"
31 #include <memory>
33 #ifndef ASSERT
34 #define ASSERT()
35 #endif
36 extern CGit g_Git;
38 CTGitPath::CTGitPath(void)
39 : m_bDirectoryKnown(false)
40 , m_bIsDirectory(false)
41 , m_bURLKnown(false)
42 , m_bHasAdminDirKnown(false)
43 , m_bHasAdminDir(false)
44 , m_bIsValidOnWindowsKnown(false)
45 , m_bIsValidOnWindows(false)
46 , m_bIsReadOnly(false)
47 , m_bIsAdminDirKnown(false)
48 , m_bIsAdminDir(false)
49 , m_bExists(false)
50 , m_bExistsKnown(false)
51 , m_bLastWriteTimeKnown(0)
52 , m_lastWriteTime(0)
53 , m_customData(NULL)
54 , m_bIsSpecialDirectoryKnown(false)
55 , m_bIsSpecialDirectory(false)
56 , m_bIsWCRootKnown(false)
57 , m_bIsWCRoot(false)
58 , m_fileSize(0)
59 , m_Checked(false)
61 m_Action=0;
62 m_ParentNo=0;
63 m_Stage = 0;
66 CTGitPath::~CTGitPath(void)
69 // Create a TGitPath object from an unknown path type (same as using SetFromUnknown)
70 CTGitPath::CTGitPath(const CString& sUnknownPath) :
71 m_bDirectoryKnown(false)
72 , m_bIsDirectory(false)
73 , m_bURLKnown(false)
74 , m_bHasAdminDirKnown(false)
75 , m_bHasAdminDir(false)
76 , m_bIsValidOnWindowsKnown(false)
77 , m_bIsValidOnWindows(false)
78 , m_bIsReadOnly(false)
79 , m_bIsAdminDirKnown(false)
80 , m_bIsAdminDir(false)
81 , m_bExists(false)
82 , m_bExistsKnown(false)
83 , m_bLastWriteTimeKnown(0)
84 , m_lastWriteTime(0)
85 , m_customData(NULL)
86 , m_bIsSpecialDirectoryKnown(false)
87 , m_bIsSpecialDirectory(false)
88 , m_bIsWCRootKnown(false)
89 , m_bIsWCRoot(false)
90 , m_fileSize(0)
91 , m_Checked(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;
119 if(action == 'T')
120 m_Action|= LOGACTIONS_MODIFIED;
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 m_sBackslashPath.Replace(L"\\\\?\\", L"");
171 SanitizeRootPath(m_sBackslashPath, false);
172 ATLASSERT(m_sBackslashPath.Find('/')<0);
174 void CTGitPath::SetFromWin(const CString& sPath)
176 Reset();
177 m_sBackslashPath = sPath;
178 m_sBackslashPath.Replace(L"\\\\?\\", L"");
179 SanitizeRootPath(m_sBackslashPath, false);
181 void CTGitPath::SetFromWin(LPCTSTR pPath, bool bIsDirectory)
183 Reset();
184 m_sBackslashPath = pPath;
185 m_bIsDirectory = bIsDirectory;
186 m_bDirectoryKnown = true;
187 SanitizeRootPath(m_sBackslashPath, false);
189 void CTGitPath::SetFromWin(const CString& sPath, bool bIsDirectory)
191 Reset();
192 m_sBackslashPath = sPath;
193 m_bIsDirectory = bIsDirectory;
194 m_bDirectoryKnown = true;
195 SanitizeRootPath(m_sBackslashPath, false);
197 void CTGitPath::SetFromUnknown(const CString& sPath)
199 Reset();
200 // Just set whichever path we think is most likely to be used
201 // GitAdminDir admin;
202 // CString p;
203 // if(admin.HasAdminDir(sPath,&p))
204 // SetFwdslashPath(sPath.Right(sPath.GetLength()-p.GetLength()));
205 // else
206 SetFwdslashPath(sPath);
209 LPCTSTR CTGitPath::GetWinPath() const
211 if(IsEmpty())
213 return _T("");
215 if(m_sBackslashPath.IsEmpty())
217 SetBackslashPath(m_sFwdslashPath);
219 return m_sBackslashPath;
221 // This is a temporary function, to be used during the migration to
222 // the path class. Ultimately, functions consuming paths should take a CTGitPath&, not a CString
223 const CString& CTGitPath::GetWinPathString() const
225 if(m_sBackslashPath.IsEmpty())
227 SetBackslashPath(m_sFwdslashPath);
229 return m_sBackslashPath;
232 const CString& CTGitPath::GetGitPathString() const
234 if(m_sFwdslashPath.IsEmpty())
236 SetFwdslashPath(m_sBackslashPath);
238 return m_sFwdslashPath;
241 const CString &CTGitPath::GetGitOldPathString() const
243 return m_sOldFwdslashPath;
246 const CString& CTGitPath::GetUIPathString() const
248 if (m_sUIPath.IsEmpty())
250 m_sUIPath = GetWinPathString();
252 return m_sUIPath;
255 void CTGitPath::SetFwdslashPath(const CString& sPath) const
257 CString path = sPath;
258 path.Replace('\\', '/');
260 // We don't leave a trailing /
261 path.TrimRight('/');
262 path.Replace(L"//?/", L"");
264 SanitizeRootPath(path, true);
266 path.Replace(_T("file:////"), _T("file://"));
267 m_sFwdslashPath = path;
269 m_sUTF8FwdslashPath.Empty();
272 void CTGitPath::SetBackslashPath(const CString& sPath) const
274 CString path = sPath;
275 path.Replace('/', '\\');
276 path.TrimRight('\\');
277 SanitizeRootPath(path, false);
278 m_sBackslashPath = path;
281 void CTGitPath::SetUTF8FwdslashPath(const CString& sPath) const
283 m_sUTF8FwdslashPath = CUnicodeUtils::GetUTF8(sPath);
286 void CTGitPath::SanitizeRootPath(CString& sPath, bool bIsForwardPath) const
288 // Make sure to add the trailing slash to root paths such as 'C:'
289 if (sPath.GetLength() == 2 && sPath[1] == ':')
291 sPath += (bIsForwardPath) ? _T("/") : _T("\\");
295 bool CTGitPath::IsDirectory() const
297 if(!m_bDirectoryKnown)
299 UpdateAttributes();
301 return m_bIsDirectory;
304 bool CTGitPath::Exists() const
306 if (!m_bExistsKnown)
308 UpdateAttributes();
310 return m_bExists;
313 bool CTGitPath::Delete(bool bTrash) const
315 EnsureBackslashPathSet();
316 ::SetFileAttributes(m_sBackslashPath, FILE_ATTRIBUTE_NORMAL);
317 bool bRet = false;
318 if (Exists())
320 if ((bTrash)||(IsDirectory()))
322 std::unique_ptr<TCHAR[]> buf(new TCHAR[m_sBackslashPath.GetLength() + 2]);
323 _tcscpy_s(buf.get(), m_sBackslashPath.GetLength() + 2, m_sBackslashPath);
324 buf[m_sBackslashPath.GetLength()] = 0;
325 buf[m_sBackslashPath.GetLength()+1] = 0;
326 bRet = CTGitPathList::DeleteViaShell(buf.get(), bTrash);
328 else
330 bRet = !!::DeleteFile(m_sBackslashPath);
333 m_bExists = false;
334 m_bExistsKnown = true;
335 return bRet;
338 __int64 CTGitPath::GetLastWriteTime() const
340 if(!m_bLastWriteTimeKnown)
342 UpdateAttributes();
344 return m_lastWriteTime;
347 __int64 CTGitPath::GetFileSize() const
349 if(!m_bDirectoryKnown)
351 UpdateAttributes();
353 return m_fileSize;
356 bool CTGitPath::IsReadOnly() const
358 if(!m_bLastWriteTimeKnown)
360 UpdateAttributes();
362 return m_bIsReadOnly;
365 void CTGitPath::UpdateAttributes() const
367 EnsureBackslashPathSet();
368 WIN32_FILE_ATTRIBUTE_DATA attribs;
369 if (m_sBackslashPath.GetLength() >= 248)
370 m_sLongBackslashPath = _T("\\\\?\\") + m_sBackslashPath;
371 if(GetFileAttributesEx(m_sBackslashPath.GetLength() >= 248 ? m_sLongBackslashPath : m_sBackslashPath, GetFileExInfoStandard, &attribs))
373 m_bIsDirectory = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
374 // don't cast directly to an __int64:
375 // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724284%28v=vs.85%29.aspx
376 // "Do not cast a pointer to a FILETIME structure to either a ULARGE_INTEGER* or __int64* value
377 // because it can cause alignment faults on 64-bit Windows."
378 m_lastWriteTime = static_cast<__int64>(attribs.ftLastWriteTime.dwHighDateTime) << 32 | attribs.ftLastWriteTime.dwLowDateTime;
379 if (m_bIsDirectory)
381 m_fileSize = 0;
383 else
385 m_fileSize = ((INT64)( (DWORD)(attribs.nFileSizeLow) ) | ( (INT64)( (DWORD)(attribs.nFileSizeHigh) )<<32 ));
387 m_bIsReadOnly = !!(attribs.dwFileAttributes & FILE_ATTRIBUTE_READONLY);
388 m_bExists = true;
390 else
392 m_bIsDirectory = false;
393 m_lastWriteTime = 0;
394 m_fileSize = 0;
395 DWORD err = GetLastError();
396 if ((err == ERROR_FILE_NOT_FOUND)||(err == ERROR_PATH_NOT_FOUND)||(err == ERROR_INVALID_NAME))
398 m_bExists = false;
400 else
402 m_bExists = true;
403 return;
406 m_bDirectoryKnown = true;
407 m_bLastWriteTimeKnown = true;
408 m_bExistsKnown = true;
411 CTGitPath CTGitPath::GetSubPath(const CTGitPath &root)
413 CTGitPath path;
415 if(GetWinPathString().Left(root.GetWinPathString().GetLength()) == root.GetWinPathString())
417 CString str=GetWinPathString();
418 path.SetFromWin(str.Right(str.GetLength()-root.GetWinPathString().GetLength()-1));
420 return path;
423 void CTGitPath::EnsureBackslashPathSet() const
425 if(m_sBackslashPath.IsEmpty())
427 SetBackslashPath(m_sFwdslashPath);
428 ATLASSERT(IsEmpty() || !m_sBackslashPath.IsEmpty());
431 void CTGitPath::EnsureFwdslashPathSet() const
433 if(m_sFwdslashPath.IsEmpty())
435 SetFwdslashPath(m_sBackslashPath);
436 ATLASSERT(IsEmpty() || !m_sFwdslashPath.IsEmpty());
441 // Reset all the caches
442 void CTGitPath::Reset()
444 m_bDirectoryKnown = false;
445 m_bURLKnown = false;
446 m_bLastWriteTimeKnown = false;
447 m_bHasAdminDirKnown = false;
448 m_bIsValidOnWindowsKnown = false;
449 m_bIsAdminDirKnown = false;
450 m_bExistsKnown = false;
451 m_bIsSpecialDirectoryKnown = false;
452 m_bIsSpecialDirectory = false;
454 m_sBackslashPath.Empty();
455 m_sFwdslashPath.Empty();
456 m_sUTF8FwdslashPath.Empty();
457 this->m_Action=0;
458 this->m_StatAdd=_T("");
459 this->m_StatDel=_T("");
460 m_ParentNo=0;
461 ATLASSERT(IsEmpty());
464 CTGitPath CTGitPath::GetDirectory() const
466 if ((IsDirectory())||(!Exists()))
468 return *this;
470 return GetContainingDirectory();
473 CTGitPath CTGitPath::GetContainingDirectory() const
475 EnsureBackslashPathSet();
477 CString sDirName = m_sBackslashPath.Left(m_sBackslashPath.ReverseFind('\\'));
478 if(sDirName.GetLength() == 2 && sDirName[1] == ':')
480 // This is a root directory, which needs a trailing slash
481 sDirName += '\\';
482 if(sDirName == m_sBackslashPath)
484 // We were clearly provided with a root path to start with - we should return nothing now
485 sDirName.Empty();
488 if(sDirName.GetLength() == 1 && sDirName[0] == '\\')
490 // We have an UNC path and we already are the root
491 sDirName.Empty();
493 CTGitPath retVal;
494 retVal.SetFromWin(sDirName);
495 return retVal;
498 CString CTGitPath::GetRootPathString() const
500 EnsureBackslashPathSet();
501 CString workingPath = m_sBackslashPath;
502 LPTSTR pPath = workingPath.GetBuffer(MAX_PATH); // MAX_PATH ok here.
503 ATLVERIFY(::PathStripToRoot(pPath));
504 workingPath.ReleaseBuffer();
505 return workingPath;
509 CString CTGitPath::GetFilename() const
511 //ATLASSERT(!IsDirectory());
512 return GetFileOrDirectoryName();
515 CString CTGitPath::GetFileOrDirectoryName() const
517 EnsureBackslashPathSet();
518 return m_sBackslashPath.Mid(m_sBackslashPath.ReverseFind('\\')+1);
521 CString CTGitPath::GetUIFileOrDirectoryName() const
523 GetUIPathString();
524 return m_sUIPath.Mid(m_sUIPath.ReverseFind('\\')+1);
527 CString CTGitPath::GetFileExtension() const
529 if(!IsDirectory())
531 EnsureBackslashPathSet();
532 int dotPos = m_sBackslashPath.ReverseFind('.');
533 int slashPos = m_sBackslashPath.ReverseFind('\\');
534 if (dotPos > slashPos)
535 return m_sBackslashPath.Mid(dotPos);
537 return CString();
539 CString CTGitPath::GetBaseFilename() const
541 int dot;
542 CString filename=GetFilename();
543 dot = filename.ReverseFind(_T('.'));
544 if(dot>0)
545 return filename.Left(dot);
546 else
547 return filename;
550 bool CTGitPath::ArePathStringsEqual(const CString& sP1, const CString& sP2)
552 int length = sP1.GetLength();
553 if(length != sP2.GetLength())
555 // Different lengths
556 return false;
558 // We work from the end of the strings, because path differences
559 // are more likely to occur at the far end of a string
560 LPCTSTR pP1Start = sP1;
561 LPCTSTR pP1 = pP1Start+(length-1);
562 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
563 while(length-- > 0)
565 if(_totlower(*pP1--) != _totlower(*pP2--))
567 return false;
570 return true;
573 bool CTGitPath::ArePathStringsEqualWithCase(const CString& sP1, const CString& sP2)
575 int length = sP1.GetLength();
576 if(length != sP2.GetLength())
578 // Different lengths
579 return false;
581 // We work from the end of the strings, because path differences
582 // are more likely to occur at the far end of a string
583 LPCTSTR pP1Start = sP1;
584 LPCTSTR pP1 = pP1Start+(length-1);
585 LPCTSTR pP2 = ((LPCTSTR)sP2)+(length-1);
586 while(length-- > 0)
588 if((*pP1--) != (*pP2--))
590 return false;
593 return true;
596 bool CTGitPath::IsEmpty() const
598 // Check the backward slash path first, since the chance that this
599 // one is set is higher. In case of a 'false' return value it's a little
600 // bit faster.
601 return m_sBackslashPath.IsEmpty() && m_sFwdslashPath.IsEmpty();
604 // Test if both paths refer to the same item
605 // Ignores case and slash direction
606 bool CTGitPath::IsEquivalentTo(const CTGitPath& rhs) const
608 // Try and find a slash direction which avoids having to convert
609 // both filenames
610 if(!m_sBackslashPath.IsEmpty())
612 // *We've* got a \ path - make sure that the RHS also has a \ path
613 rhs.EnsureBackslashPathSet();
614 return ArePathStringsEqualWithCase(m_sBackslashPath, rhs.m_sBackslashPath);
616 else
618 // Assume we've got a fwdslash path and make sure that the RHS has one
619 rhs.EnsureFwdslashPathSet();
620 return ArePathStringsEqualWithCase(m_sFwdslashPath, rhs.m_sFwdslashPath);
624 bool CTGitPath::IsEquivalentToWithoutCase(const CTGitPath& rhs) const
626 // Try and find a slash direction which avoids having to convert
627 // both filenames
628 if(!m_sBackslashPath.IsEmpty())
630 // *We've* got a \ path - make sure that the RHS also has a \ path
631 rhs.EnsureBackslashPathSet();
632 return ArePathStringsEqual(m_sBackslashPath, rhs.m_sBackslashPath);
634 else
636 // Assume we've got a fwdslash path and make sure that the RHS has one
637 rhs.EnsureFwdslashPathSet();
638 return ArePathStringsEqual(m_sFwdslashPath, rhs.m_sFwdslashPath);
642 bool CTGitPath::IsAncestorOf(const CTGitPath& possibleDescendant) const
644 possibleDescendant.EnsureBackslashPathSet();
645 EnsureBackslashPathSet();
647 bool bPathStringsEqual = ArePathStringsEqual(m_sBackslashPath, possibleDescendant.m_sBackslashPath.Left(m_sBackslashPath.GetLength()));
648 if (m_sBackslashPath.GetLength() >= possibleDescendant.GetWinPathString().GetLength())
650 return bPathStringsEqual;
653 return (bPathStringsEqual &&
654 ((possibleDescendant.m_sBackslashPath[m_sBackslashPath.GetLength()] == '\\')||
655 (m_sBackslashPath.GetLength()==3 && m_sBackslashPath[1]==':')));
658 // Get a string representing the file path, optionally with a base
659 // section stripped off the front.
660 CString CTGitPath::GetDisplayString(const CTGitPath* pOptionalBasePath /* = NULL*/) const
662 EnsureFwdslashPathSet();
663 if(pOptionalBasePath != NULL)
665 // Find the length of the base-path without having to do an 'ensure' on it
666 int baseLength = max(pOptionalBasePath->m_sBackslashPath.GetLength(), pOptionalBasePath->m_sFwdslashPath.GetLength());
668 // Now, chop that baseLength of the front of the path
669 return m_sFwdslashPath.Mid(baseLength).TrimLeft('/');
671 return m_sFwdslashPath;
674 int CTGitPath::Compare(const CTGitPath& left, const CTGitPath& right)
676 left.EnsureBackslashPathSet();
677 right.EnsureBackslashPathSet();
678 return left.m_sBackslashPath.CompareNoCase(right.m_sBackslashPath);
681 bool operator<(const CTGitPath& left, const CTGitPath& right)
683 return CTGitPath::Compare(left, right) < 0;
686 bool CTGitPath::PredLeftEquivalentToRight(const CTGitPath& left, const CTGitPath& right)
688 return left.IsEquivalentTo(right);
691 bool CTGitPath::PredLeftSameWCPathAsRight(const CTGitPath& left, const CTGitPath& right)
693 if (left.IsAdminDir() && right.IsAdminDir())
695 CTGitPath l = left;
696 CTGitPath r = right;
699 l = l.GetContainingDirectory();
700 } while(l.HasAdminDir());
703 r = r.GetContainingDirectory();
704 } while(r.HasAdminDir());
705 return l.GetContainingDirectory().IsEquivalentTo(r.GetContainingDirectory());
707 return left.GetDirectory().IsEquivalentTo(right.GetDirectory());
710 bool CTGitPath::CheckChild(const CTGitPath &parent, const CTGitPath& child)
712 return parent.IsAncestorOf(child);
715 void CTGitPath::AppendRawString(const CString& sAppend)
717 EnsureFwdslashPathSet();
718 CString strCopy = m_sFwdslashPath += sAppend;
719 SetFromUnknown(strCopy);
722 void CTGitPath::AppendPathString(const CString& sAppend)
724 EnsureBackslashPathSet();
725 CString cleanAppend(sAppend);
726 cleanAppend.Replace('/', '\\');
727 cleanAppend.TrimLeft('\\');
728 m_sBackslashPath.TrimRight('\\');
729 CString strCopy = m_sBackslashPath + _T("\\") + cleanAppend;
730 SetFromWin(strCopy);
733 bool CTGitPath::IsWCRoot() const
735 if (m_bIsWCRootKnown)
736 return m_bIsWCRoot;
738 m_bIsWCRootKnown = true;
739 m_bIsWCRoot = false;
741 CString topDirectory;
742 if (!IsDirectory() || !HasAdminDir(&topDirectory))
744 return m_bIsWCRoot;
747 if (IsEquivalentToWithoutCase(topDirectory))
749 m_bIsWCRoot = true;
752 return m_bIsWCRoot;
755 bool CTGitPath::HasAdminDir() const
757 if (m_bHasAdminDirKnown)
758 return m_bHasAdminDir;
760 EnsureBackslashPathSet();
761 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
762 m_bHasAdminDirKnown = true;
763 return m_bHasAdminDir;
766 bool CTGitPath::HasSubmodules() const
768 if (HasAdminDir())
770 CString path = m_sProjectRoot;
771 path += _T("\\.gitmodules");
772 if( PathFileExists(path) )
773 return true;
775 return false;
778 int CTGitPath::GetAdminDirMask() const
780 int status = 0;
781 CString topdir;
782 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
784 return status;
787 // ITEMIS_INGIT will be revoked if necessary in TortoiseShell/ContextMenu.cpp
788 status |= ITEMIS_INGIT|ITEMIS_INVERSIONEDFOLDER;
790 if (IsDirectory())
792 status |= ITEMIS_FOLDERINGIT;
793 if (IsWCRoot())
795 status |= ITEMIS_WCROOT;
797 CString topProjectDir;
798 if (g_GitAdminDir.HasAdminDir(GetWinPathString(), false, &topProjectDir))
800 if (PathFileExists(topProjectDir + _T("\\.gitmodules")))
802 CAutoConfig config(true);
803 git_config_add_file_ondisk(config, CGit::GetGitPathStringA(topProjectDir + _T("\\.gitmodules")), GIT_CONFIG_LEVEL_APP, FALSE);
804 CString relativePath = GetWinPathString().Mid(topProjectDir.GetLength());
805 relativePath.Replace(_T("\\"), _T("/"));
806 relativePath.Trim(_T("/"));
807 CStringA submodulePath = CUnicodeUtils::GetUTF8(relativePath);
808 if (git_config_foreach_match(config, "submodule\\..*\\.path",
809 [](const git_config_entry *entry, void *data) { return entry->value == *(CStringA *)data ? GIT_EUSER : 0; }, &submodulePath) == GIT_EUSER)
810 status |= ITEMIS_SUBMODULE;
816 CString dotGitPath;
817 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
819 if (PathFileExists(dotGitPath + _T("BISECT_START")))
820 status |= ITEMIS_BISECT;
822 if (PathFileExists(dotGitPath + _T("MERGE_HEAD")))
823 status |= ITEMIS_MERGEACTIVE;
825 if (PathFileExists(dotGitPath + _T("refs\\stash")))
826 status |= ITEMIS_STASH;
828 if (PathFileExists(dotGitPath + _T("svn")))
829 status |= ITEMIS_GITSVN;
831 if (PathFileExists(topdir + _T("\\.gitmodules")))
832 status |= ITEMIS_SUBMODULECONTAINER;
834 return status;
837 bool CTGitPath::HasStashDir() const
839 CString topdir;
840 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
842 return false;
845 CString dotGitPath;
846 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
848 return !!PathFileExists(dotGitPath + _T("\\refs\\stash"));
850 bool CTGitPath::HasGitSVNDir() const
852 CString topdir;
853 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
855 return false;
858 CString dotGitPath;
859 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
861 return !!PathFileExists(dotGitPath + _T("svn"));
863 bool CTGitPath::IsBisectActive() const
865 CString topdir;
866 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
868 return false;
871 CString dotGitPath;
872 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
874 return !!PathFileExists(dotGitPath + _T("BISECT_START"));
876 bool CTGitPath::IsMergeActive() const
878 CString topdir;
879 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
881 return false;
884 CString dotGitPath;
885 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
887 return !!PathFileExists(dotGitPath + _T("MERGE_HEAD"));
889 bool CTGitPath::HasRebaseApply() const
891 CString topdir;
892 if(!g_GitAdminDir.HasAdminDir(GetWinPathString(),&topdir))
894 return false;
897 CString dotGitPath;
898 g_GitAdminDir.GetAdminDirPath(topdir, dotGitPath);
900 return !!PathFileExists(dotGitPath + _T("rebase-apply"));
903 bool CTGitPath::HasAdminDir(CString *ProjectTopDir) const
905 if (m_bHasAdminDirKnown)
907 if (ProjectTopDir)
908 *ProjectTopDir = m_sProjectRoot;
909 return m_bHasAdminDir;
912 EnsureBackslashPathSet();
913 m_bHasAdminDir = g_GitAdminDir.HasAdminDir(m_sBackslashPath, IsDirectory(), &m_sProjectRoot);
914 m_bHasAdminDirKnown = true;
915 if (ProjectTopDir)
916 *ProjectTopDir = m_sProjectRoot;
917 return m_bHasAdminDir;
920 bool CTGitPath::IsAdminDir() const
922 if (m_bIsAdminDirKnown)
923 return m_bIsAdminDir;
925 EnsureBackslashPathSet();
926 m_bIsAdminDir = g_GitAdminDir.IsAdminDirPath(m_sBackslashPath);
927 m_bIsAdminDirKnown = true;
928 return m_bIsAdminDir;
931 bool CTGitPath::IsValidOnWindows() const
933 if (m_bIsValidOnWindowsKnown)
934 return m_bIsValidOnWindows;
936 m_bIsValidOnWindows = false;
937 EnsureBackslashPathSet();
938 CString sMatch = m_sBackslashPath + _T("\r\n");
939 std::wstring sPattern;
940 // the 'file://' URL is just a normal windows path:
941 if (sMatch.Left(7).CompareNoCase(_T("file:\\\\"))==0)
943 sMatch = sMatch.Mid(7);
944 sMatch.TrimLeft(_T("\\"));
945 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
947 else
949 sPattern = _T("^(\\\\\\\\\\?\\\\)?(([a-zA-Z]:|\\\\)\\\\)?(((\\.)|(\\.\\.)|([^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?))\\\\)*[^\\\\/:\\*\\?\"\\|<> ](([^\\\\/:\\*\\?\"\\|<>\\. ])|([^\\\\/:\\*\\?\"\\|<>]*[^\\\\/:\\*\\?\"\\|<>\\. ]))?$");
954 std::tr1::wregex rx(sPattern, std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
955 std::tr1::wsmatch match;
957 std::wstring rmatch = std::wstring((LPCTSTR)sMatch);
958 if (std::tr1::regex_match(rmatch, match, rx))
960 if (std::wstring(match[0]).compare(sMatch)==0)
961 m_bIsValidOnWindows = true;
963 if (m_bIsValidOnWindows)
965 // now check for illegal filenames
966 std::tr1::wregex rx2(_T("\\\\(lpt\\d|com\\d|aux|nul|prn|con)(\\\\|$)"), std::tr1::regex_constants::icase | std::tr1::regex_constants::ECMAScript);
967 rmatch = m_sBackslashPath;
968 if (std::tr1::regex_search(rmatch, rx2, std::tr1::regex_constants::match_default))
969 m_bIsValidOnWindows = false;
972 catch (std::exception) {}
974 m_bIsValidOnWindowsKnown = true;
975 return m_bIsValidOnWindows;
978 //////////////////////////////////////////////////////////////////////////
980 CTGitPathList::CTGitPathList()
982 m_Action = 0;
985 // A constructor which allows a path list to be easily built which one initial entry in
986 CTGitPathList::CTGitPathList(const CTGitPath& firstEntry)
988 m_Action = 0;
989 AddPath(firstEntry);
991 int CTGitPathList::ParserFromLsFile(BYTE_VECTOR &out,bool /*staged*/)
993 unsigned int pos=0;
994 CString one;
995 CTGitPath path;
996 CString part;
997 this->Clear();
999 while(pos>=0 && pos<out.size())
1001 one.Empty();
1002 path.Reset();
1004 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1005 int tabstart=0;
1006 path.m_Action=path.ParserAction(out[pos]);
1007 one.Tokenize(_T("\t"),tabstart);
1009 if(tabstart>=0)
1010 path.SetFromGit(one.Right(one.GetLength()-tabstart));
1011 else
1012 return -1;
1014 tabstart=0;
1016 part=one.Tokenize(_T(" "),tabstart); //Tag
1017 if (tabstart < 0)
1018 return -1;
1020 part=one.Tokenize(_T(" "),tabstart); //Mode
1021 if (tabstart < 0)
1022 return -1;
1024 part=one.Tokenize(_T(" "),tabstart); //Hash
1025 if (tabstart < 0)
1026 return -1;
1028 part=one.Tokenize(_T("\t"),tabstart); //Stage
1029 if (tabstart < 0)
1030 return -1;
1032 path.m_Stage=_ttol(part);
1034 this->AddPath(path);
1036 pos=out.findNextString(pos);
1038 return 0;
1040 int CTGitPathList::FillUnRev(unsigned int action, CTGitPathList *list, CString *err)
1042 this->Clear();
1043 CTGitPath path;
1045 int count;
1046 if(list==NULL)
1047 count=1;
1048 else
1049 count=list->GetCount();
1050 for (int i = 0; i < count; ++i)
1052 CString cmd;
1053 int pos = 0;
1055 CString ignored;
1056 if(action & CTGitPath::LOGACTIONS_IGNORE)
1057 ignored= _T(" -i");
1059 if(list==NULL)
1061 cmd=_T("git.exe ls-files --exclude-standard --full-name --others -z");
1062 cmd+=ignored;
1065 else
1066 { cmd.Format(_T("git.exe ls-files --exclude-standard --full-name --others -z%s -- \"%s\""),
1067 ignored,
1068 (*list)[i].GetWinPathString());
1071 BYTE_VECTOR out, errb;
1072 out.clear();
1073 if (g_Git.Run(cmd, &out, &errb))
1075 if (err != nullptr)
1076 g_Git.StringAppend(err, &errb[0], CP_UTF8, (int)errb.size());
1077 return -1;
1080 pos=0;
1081 CString one;
1082 while (pos >= 0 && pos < (int)out.size())
1084 one.Empty();
1085 g_Git.StringAppend(&one, &out[pos], CP_UTF8);
1086 if(!one.IsEmpty())
1088 //SetFromGit will clear all status
1089 path.SetFromGit(one);
1090 path.m_Action=action;
1091 AddPath(path);
1093 pos=out.findNextString(pos);
1097 return 0;
1099 int CTGitPathList::FillBasedOnIndexFlags(unsigned short flag, CTGitPathList* list /*nullptr*/)
1101 Clear();
1102 CTGitPath path;
1103 CString one;
1105 CAutoRepository repository(g_Git.GetGitRepository());
1106 if (!repository)
1107 return -1;
1109 CAutoIndex index;
1110 if (git_repository_index(index.GetPointer(), repository))
1111 return -1;
1113 int count;
1114 if (list == nullptr)
1115 count = 1;
1116 else
1117 count = list->GetCount();
1118 for (int j = 0; j < count; ++j)
1120 for (size_t i = 0, ecount = git_index_entrycount(index); i < ecount; ++i)
1122 const git_index_entry *e = git_index_get_byindex(index, i);
1124 if (!e || !((e->flags | e->flags_extended) & flag) || !e->path)
1125 continue;
1127 one.Empty();
1128 g_Git.StringAppend(&one, (BYTE*)e->path, CP_UTF8);
1130 if (!(!list || (*list)[j].GetWinPathString().IsEmpty() || one == (*list)[j].GetGitPathString() || (PathIsDirectory(g_Git.m_CurrentDir + L"\\" + (*list)[j].GetWinPathString()) && one.Find((*list)[j].GetGitPathString() + _T("/")) == 0)))
1131 continue;
1133 //SetFromGit will clear all status
1134 path.SetFromGit(one);
1135 if ((e->flags | e->flags_extended) & GIT_IDXENTRY_SKIP_WORKTREE)
1136 path.m_Action = CTGitPath::LOGACTIONS_SKIPWORKTREE;
1137 else if ((e->flags | e->flags_extended) & GIT_IDXENTRY_VALID)
1138 path.m_Action = CTGitPath::LOGACTIONS_ASSUMEVALID;
1139 AddPath(path);
1142 RemoveDuplicates();
1143 return 0;
1145 int CTGitPathList::ParserFromLog(BYTE_VECTOR &log, bool parseDeletes /*false*/)
1147 this->Clear();
1148 int pos=0;
1149 //BYTE *p=&log[0];
1150 //CString one;
1151 CTGitPath path;
1152 m_Action=0;
1153 while (pos >= 0 && pos < (int)log.size())
1155 //one=log.Tokenize(_T("\n"),pos);
1156 path.Reset();
1157 if(log[pos]=='\n')
1158 ++pos;
1160 if(log[pos]==':')
1162 bool merged=false;
1163 if(log[pos+1] ==':')
1165 merged=true;
1167 int end=log.find(0,pos);
1168 int actionstart=-1;
1169 int file1=-1,file2=-1;
1170 if( end>0 )
1172 actionstart=log.find(' ',end-6);
1173 pos=actionstart;
1175 if( actionstart>0 )
1177 ++actionstart;
1179 file1 = log.find(0,actionstart);
1180 if( file1>=0 )
1182 ++file1;
1183 pos=file1;
1185 if( log[actionstart] == 'C' || log[actionstart] == 'R' )
1187 file2=file1;
1188 file1 = log.find(0,file1);
1189 if(file1>=0 )
1191 ++file1;
1192 pos=file1;
1198 CString pathname1;
1199 CString pathname2;
1201 if( file1>=0 )
1202 g_Git.StringAppend(&pathname1, &log[file1], CP_UTF8);
1203 if( file2>=0 )
1204 g_Git.StringAppend(&pathname2, &log[file2], CP_UTF8);
1206 CTGitPath *GitPath=LookForGitPath(pathname1);
1208 if(GitPath)
1210 GitPath->ParserAction( log[actionstart] );
1212 if(merged)
1214 GitPath->m_Action |= CTGitPath::LOGACTIONS_MERGED;
1215 GitPath->m_Action &= ~CTGitPath::LOGACTIONS_FORWORD;
1217 m_Action |=GitPath->m_Action;
1220 else
1222 int ac=path.ParserAction(log[actionstart] );
1223 ac |= merged?CTGitPath::LOGACTIONS_MERGED:0;
1225 path.SetFromGit(pathname1,&pathname2);
1226 path.m_Action=ac;
1227 //action must be set after setfromgit. SetFromGit will clear all status.
1228 this->m_Action|=ac;
1230 AddPath(path);
1235 else
1237 int tabstart=0;
1238 path.Reset();
1239 CString StatAdd;
1240 CString StatDel;
1241 CString file1;
1242 CString file2;
1244 tabstart=log.find('\t',pos);
1245 if(tabstart >=0)
1247 log[tabstart]=0;
1248 g_Git.StringAppend(&StatAdd,&log[pos],CP_UTF8);
1249 pos=tabstart+1;
1252 tabstart=log.find('\t',pos);
1253 if(tabstart >=0)
1255 log[tabstart]=0;
1257 g_Git.StringAppend(&StatDel,&log[pos],CP_UTF8);
1258 pos=tabstart+1;
1261 if(log[pos] == 0) //rename
1263 ++pos;
1264 g_Git.StringAppend(&file2, &log[pos], CP_UTF8);
1265 int sec=log.find(0,pos);
1266 if(sec>=0)
1268 ++sec;
1269 g_Git.StringAppend(&file1, &log[sec], CP_UTF8);
1271 pos=sec;
1274 else
1276 g_Git.StringAppend(&file1, &log[pos], CP_UTF8);
1278 path.SetFromGit(file1,&file2);
1280 CTGitPath *GitPath=LookForGitPath(path.GetGitPathString());
1281 if(GitPath)
1283 GitPath->m_StatAdd=StatAdd;
1284 GitPath->m_StatDel=StatDel;
1286 else
1288 //path.SetFromGit(pathname);
1289 if (parseDeletes)
1291 path.m_StatAdd=_T("0");
1292 path.m_StatDel=_T("0");
1293 path.m_Action |= CTGitPath::LOGACTIONS_DELETED;
1295 else
1297 path.m_StatAdd=StatAdd;
1298 path.m_StatDel=StatDel;
1299 path.m_Action |= CTGitPath::LOGACTIONS_FORWORD;
1301 AddPath(path);
1305 pos=log.findNextString(pos);
1307 return pos;
1310 void CTGitPathList::AddPath(const CTGitPath& newPath)
1312 m_paths.push_back(newPath);
1313 m_commonBaseDirectory.Reset();
1315 int CTGitPathList::GetCount() const
1317 return (int)m_paths.size();
1319 bool CTGitPathList::IsEmpty() const
1321 return m_paths.empty();
1323 void CTGitPathList::Clear()
1325 m_paths.clear();
1326 m_commonBaseDirectory.Reset();
1329 const CTGitPath& CTGitPathList::operator[](INT_PTR index) const
1331 ATLASSERT(index >= 0 && index < (INT_PTR)m_paths.size());
1332 return m_paths[index];
1335 bool CTGitPathList::AreAllPathsFiles() const
1337 // Look through the vector for any directories - if we find them, return false
1338 return std::find_if(m_paths.begin(), m_paths.end(), std::mem_fun_ref(&CTGitPath::IsDirectory)) == m_paths.end();
1342 #if defined(_MFC_VER)
1344 bool CTGitPathList::LoadFromFile(const CTGitPath& filename)
1346 Clear();
1349 CString strLine;
1350 CStdioFile file(filename.GetWinPath(), CFile::typeBinary | CFile::modeRead | CFile::shareDenyWrite);
1352 // for every selected file/folder
1353 CTGitPath path;
1354 while (file.ReadString(strLine))
1356 path.SetFromUnknown(strLine);
1357 AddPath(path);
1359 file.Close();
1361 catch (CFileException* pE)
1363 CTraceToOutputDebugString::Instance()(__FUNCTION__ ": CFileException loading target file list\n");
1364 TCHAR error[10000] = {0};
1365 pE->GetErrorMessage(error, 10000);
1366 // CMessageBox::Show(NULL, error, _T("TortoiseGit"), MB_ICONERROR);
1367 pE->Delete();
1368 return false;
1370 return true;
1373 bool CTGitPathList::WriteToFile(const CString& sFilename, bool bANSI /* = false */) const
1377 if (bANSI)
1379 CStdioFile file(sFilename, CFile::typeText | CFile::modeReadWrite | CFile::modeCreate);
1380 PathVector::const_iterator it;
1381 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1383 CStringA line = CStringA(it->GetGitPathString()) + '\n';
1384 file.Write(line, line.GetLength());
1386 file.Close();
1388 else
1390 CStdioFile file(sFilename, CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate);
1391 PathVector::const_iterator it;
1392 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1394 file.WriteString(it->GetGitPathString()+_T("\n"));
1396 file.Close();
1399 catch (CFileException* pE)
1401 CTraceToOutputDebugString::Instance()(__FUNCTION__ ": CFileException in writing temp file\n");
1402 pE->Delete();
1403 return false;
1405 return true;
1409 void CTGitPathList::LoadFromAsteriskSeparatedString(const CString& sPathString)
1411 int pos = 0;
1412 CString temp;
1413 for(;;)
1415 temp = sPathString.Tokenize(_T("*"),pos);
1416 if(temp.IsEmpty())
1418 break;
1420 AddPath(CTGitPath(CPathUtils::GetLongPathname(temp)));
1424 CString CTGitPathList::CreateAsteriskSeparatedString() const
1426 CString sRet;
1427 PathVector::const_iterator it;
1428 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1430 if (!sRet.IsEmpty())
1431 sRet += _T("*");
1432 sRet += it->GetWinPathString();
1434 return sRet;
1436 #endif // _MFC_VER
1438 bool
1439 CTGitPathList::AreAllPathsFilesInOneDirectory() const
1441 // Check if all the paths are files and in the same directory
1442 PathVector::const_iterator it;
1443 m_commonBaseDirectory.Reset();
1444 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1446 if(it->IsDirectory())
1448 return false;
1450 const CTGitPath& baseDirectory = it->GetDirectory();
1451 if(m_commonBaseDirectory.IsEmpty())
1453 m_commonBaseDirectory = baseDirectory;
1455 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1457 // Different path
1458 m_commonBaseDirectory.Reset();
1459 return false;
1462 return true;
1465 CTGitPath CTGitPathList::GetCommonDirectory() const
1467 if (m_commonBaseDirectory.IsEmpty())
1469 PathVector::const_iterator it;
1470 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1472 const CTGitPath& baseDirectory = it->GetDirectory();
1473 if(m_commonBaseDirectory.IsEmpty())
1475 m_commonBaseDirectory = baseDirectory;
1477 else if(!m_commonBaseDirectory.IsEquivalentTo(baseDirectory))
1479 // Different path
1480 m_commonBaseDirectory.Reset();
1481 break;
1485 // since we only checked strings, not paths,
1486 // we have to make sure now that we really return a *path* here
1487 PathVector::const_iterator iter;
1488 for(iter = m_paths.begin(); iter != m_paths.end(); ++iter)
1490 if (!m_commonBaseDirectory.IsAncestorOf(*iter))
1492 m_commonBaseDirectory = m_commonBaseDirectory.GetContainingDirectory();
1493 break;
1496 return m_commonBaseDirectory;
1499 CTGitPath CTGitPathList::GetCommonRoot() const
1501 if (IsEmpty())
1502 return CTGitPath();
1504 if (GetCount() == 1)
1505 return m_paths[0];
1507 // first entry is common root for itself
1508 // (add trailing '\\' to detect partial matches of the last path element)
1509 CString root = m_paths[0].GetWinPathString() + _T('\\');
1510 int rootLength = root.GetLength();
1512 // determine common path string prefix
1513 for (PathVector::const_iterator it = m_paths.begin() + 1; it != m_paths.end(); ++it)
1515 CString path = it->GetWinPathString() + _T('\\');
1517 int newLength = CStringUtils::GetMatchingLength(root, path);
1518 if (newLength != rootLength)
1520 root.Delete(newLength, rootLength);
1521 rootLength = newLength;
1525 // remove the last (partial) path element
1526 if (rootLength > 0)
1527 root.Delete(root.ReverseFind(_T('\\')), rootLength);
1529 // done
1530 return CTGitPath(root);
1533 void CTGitPathList::SortByPathname(bool bReverse /*= false*/)
1535 std::sort(m_paths.begin(), m_paths.end());
1536 if (bReverse)
1537 std::reverse(m_paths.begin(), m_paths.end());
1540 void CTGitPathList::DeleteAllFiles(bool bTrash, bool bFilesOnly)
1542 PathVector::const_iterator it;
1543 SortByPathname(true); // nested ones first
1545 CString sPaths;
1546 for (it = m_paths.begin(); it != m_paths.end(); ++it)
1548 if ((it->Exists()) && ((it->IsDirectory() != bFilesOnly) || !bFilesOnly))
1550 if (!it->IsDirectory())
1551 ::SetFileAttributes(it->GetWinPath(), FILE_ATTRIBUTE_NORMAL);
1553 sPaths += it->GetWinPath();
1554 sPaths += '\0';
1557 sPaths += '\0';
1558 sPaths += '\0';
1559 DeleteViaShell((LPCTSTR)sPaths, bTrash);
1560 Clear();
1563 bool CTGitPathList::DeleteViaShell(LPCTSTR path, bool bTrash)
1565 SHFILEOPSTRUCT shop = {0};
1566 shop.wFunc = FO_DELETE;
1567 shop.pFrom = path;
1568 shop.fFlags = FOF_NOCONFIRMATION|FOF_NOERRORUI|FOF_SILENT|FOF_NO_CONNECTED_ELEMENTS;
1569 if (bTrash)
1570 shop.fFlags |= FOF_ALLOWUNDO;
1571 const bool bRet = (SHFileOperation(&shop) == 0);
1572 return bRet;
1575 void CTGitPathList::RemoveDuplicates()
1577 SortByPathname();
1578 // Remove the duplicates
1579 // (Unique moves them to the end of the vector, then erase chops them off)
1580 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::PredLeftEquivalentToRight), m_paths.end());
1583 void CTGitPathList::RemoveAdminPaths()
1585 PathVector::iterator it;
1586 for(it = m_paths.begin(); it != m_paths.end(); )
1588 if (it->IsAdminDir())
1590 m_paths.erase(it);
1591 it = m_paths.begin();
1593 else
1594 ++it;
1598 void CTGitPathList::RemovePath(const CTGitPath& path)
1600 PathVector::iterator it;
1601 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1603 if (it->IsEquivalentTo(path))
1605 m_paths.erase(it);
1606 return;
1611 void CTGitPathList::RemoveItem(CTGitPath & path)
1613 PathVector::iterator it;
1614 for(it = m_paths.begin(); it != m_paths.end(); ++it)
1616 if (it->GetGitPathString()==path.GetGitPathString())
1618 m_paths.erase(it);
1619 return;
1623 void CTGitPathList::RemoveChildren()
1625 SortByPathname();
1626 m_paths.erase(std::unique(m_paths.begin(), m_paths.end(), &CTGitPath::CheckChild), m_paths.end());
1629 bool CTGitPathList::IsEqual(const CTGitPathList& list)
1631 if (list.GetCount() != GetCount())
1632 return false;
1633 for (int i=0; i<list.GetCount(); ++i)
1635 if (!list[i].IsEquivalentTo(m_paths[i]))
1636 return false;
1638 return true;
1641 #if 0
1642 #if defined(_DEBUG)
1643 // Some test cases for these classes
1644 static class CTGitPathTests
1646 public:
1647 CTGitPathTests()
1649 GetDirectoryTest();
1650 AdminDirTest();
1651 SortTest();
1652 RawAppendTest();
1653 PathAppendTest();
1654 RemoveDuplicatesTest();
1655 RemoveChildrenTest();
1656 ContainingDirectoryTest();
1657 AncestorTest();
1658 SubversionPathTest();
1659 GetCommonRootTest();
1660 #if defined(_MFC_VER)
1661 ValidPathAndUrlTest();
1662 ListLoadingTest();
1663 #endif
1666 private:
1667 void GetDirectoryTest()
1669 // Bit tricky, this test, because we need to know something about the file
1670 // layout on the machine which is running the test
1671 TCHAR winDir[MAX_PATH+1] = {0};
1672 GetWindowsDirectory(winDir, MAX_PATH);
1673 CString sWinDir(winDir);
1675 CTGitPath testPath;
1676 // This is a file which we know will always be there
1677 testPath.SetFromUnknown(sWinDir + _T("\\win.ini"));
1678 ATLASSERT(!testPath.IsDirectory());
1679 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1680 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() == sWinDir);
1682 // Now do the test on the win directory itself - It's hard to be sure about the containing directory
1683 // but we know it must be different to the directory itself
1684 testPath.SetFromUnknown(sWinDir);
1685 ATLASSERT(testPath.IsDirectory());
1686 ATLASSERT(testPath.GetDirectory().GetWinPathString() == sWinDir);
1687 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString() != sWinDir);
1688 ATLASSERT(testPath.GetContainingDirectory().GetWinPathString().GetLength() < sWinDir.GetLength());
1690 // Try a root path
1691 testPath.SetFromUnknown(_T("C:\\"));
1692 ATLASSERT(testPath.IsDirectory());
1693 ATLASSERT(testPath.GetDirectory().GetWinPathString().CompareNoCase(_T("C:\\"))==0);
1694 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1695 // Try a root UNC path
1696 testPath.SetFromUnknown(_T("\\MYSTATION"));
1697 ATLASSERT(testPath.GetContainingDirectory().IsEmpty());
1700 void AdminDirTest()
1702 CTGitPath testPath;
1703 testPath.SetFromUnknown(_T("c:\\.svndir"));
1704 ATLASSERT(!testPath.IsAdminDir());
1705 testPath.SetFromUnknown(_T("c:\\test.svn"));
1706 ATLASSERT(!testPath.IsAdminDir());
1707 testPath.SetFromUnknown(_T("c:\\.svn"));
1708 ATLASSERT(testPath.IsAdminDir());
1709 testPath.SetFromUnknown(_T("c:\\.svndir\\test"));
1710 ATLASSERT(!testPath.IsAdminDir());
1711 testPath.SetFromUnknown(_T("c:\\.svn\\test"));
1712 ATLASSERT(testPath.IsAdminDir());
1714 CTGitPathList pathList;
1715 pathList.AddPath(CTGitPath(_T("c:\\.svndir")));
1716 pathList.AddPath(CTGitPath(_T("c:\\.svn")));
1717 pathList.AddPath(CTGitPath(_T("c:\\.svn\\test")));
1718 pathList.AddPath(CTGitPath(_T("c:\\test")));
1719 pathList.RemoveAdminPaths();
1720 ATLASSERT(pathList.GetCount()==2);
1721 pathList.Clear();
1722 pathList.AddPath(CTGitPath(_T("c:\\test")));
1723 pathList.RemoveAdminPaths();
1724 ATLASSERT(pathList.GetCount()==1);
1727 void SortTest()
1729 CTGitPathList testList;
1730 CTGitPath testPath;
1731 testPath.SetFromUnknown(_T("c:/Z"));
1732 testList.AddPath(testPath);
1733 testPath.SetFromUnknown(_T("c:/B"));
1734 testList.AddPath(testPath);
1735 testPath.SetFromUnknown(_T("c:\\a"));
1736 testList.AddPath(testPath);
1737 testPath.SetFromUnknown(_T("c:/Test"));
1738 testList.AddPath(testPath);
1740 testList.SortByPathname();
1742 ATLASSERT(testList[0].GetWinPathString() == _T("c:\\a"));
1743 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\B"));
1744 ATLASSERT(testList[2].GetWinPathString() == _T("c:\\Test"));
1745 ATLASSERT(testList[3].GetWinPathString() == _T("c:\\Z"));
1748 void RawAppendTest()
1750 CTGitPath testPath(_T("c:/test/"));
1751 testPath.AppendRawString(_T("/Hello"));
1752 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1754 testPath.AppendRawString(_T("\\T2"));
1755 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1757 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1758 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1759 testBasePath.AppendRawString(testFilePath.GetFileExtension());
1760 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt.ini"));
1763 void PathAppendTest()
1765 CTGitPath testPath(_T("c:/test/"));
1766 testPath.AppendPathString(_T("/Hello"));
1767 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello"));
1769 testPath.AppendPathString(_T("T2"));
1770 ATLASSERT(testPath.GetWinPathString() == _T("c:\\test\\Hello\\T2"));
1772 CTGitPath testFilePath(_T("C:\\windows\\win.ini"));
1773 CTGitPath testBasePath(_T("c:/temp/myfile.txt"));
1774 // You wouldn't want to do this in real life - you'd use append-raw
1775 testBasePath.AppendPathString(testFilePath.GetFileExtension());
1776 ATLASSERT(testBasePath.GetWinPathString() == _T("c:\\temp\\myfile.txt\\.ini"));
1779 void RemoveDuplicatesTest()
1781 CTGitPathList list;
1782 list.AddPath(CTGitPath(_T("Z")));
1783 list.AddPath(CTGitPath(_T("A")));
1784 list.AddPath(CTGitPath(_T("E")));
1785 list.AddPath(CTGitPath(_T("E")));
1787 ATLASSERT(list[2].IsEquivalentTo(list[3]));
1788 ATLASSERT(list[2]==list[3]);
1790 ATLASSERT(list.GetCount() == 4);
1792 list.RemoveDuplicates();
1794 ATLASSERT(list.GetCount() == 3);
1796 ATLASSERT(list[0].GetWinPathString() == _T("A"));
1797 ATLASSERT(list[1].GetWinPathString().Compare(_T("E")) == 0);
1798 ATLASSERT(list[2].GetWinPathString() == _T("Z"));
1801 void RemoveChildrenTest()
1803 CTGitPathList list;
1804 list.AddPath(CTGitPath(_T("c:\\test")));
1805 list.AddPath(CTGitPath(_T("c:\\test\\file")));
1806 list.AddPath(CTGitPath(_T("c:\\testfile")));
1807 list.AddPath(CTGitPath(_T("c:\\parent")));
1808 list.AddPath(CTGitPath(_T("c:\\parent\\child")));
1809 list.AddPath(CTGitPath(_T("c:\\parent\\child1")));
1810 list.AddPath(CTGitPath(_T("c:\\parent\\child2")));
1812 ATLASSERT(list.GetCount() == 7);
1814 list.RemoveChildren();
1816 ATLTRACE("count = %d\n", list.GetCount());
1817 ATLASSERT(list.GetCount() == 3);
1819 list.SortByPathname();
1821 ATLASSERT(list[0].GetWinPathString().Compare(_T("c:\\parent")) == 0);
1822 ATLASSERT(list[1].GetWinPathString().Compare(_T("c:\\test")) == 0);
1823 ATLASSERT(list[2].GetWinPathString().Compare(_T("c:\\testfile")) == 0);
1826 #if defined(_MFC_VER)
1827 void ListLoadingTest()
1829 TCHAR buf[MAX_PATH] = {0};
1830 GetCurrentDirectory(MAX_PATH, buf);
1831 CString sPathList(_T("Path1*c:\\path2 with spaces and stuff*\\funnypath\\*"));
1832 CTGitPathList testList;
1833 testList.LoadFromAsteriskSeparatedString(sPathList);
1835 ATLASSERT(testList.GetCount() == 3);
1836 ATLASSERT(testList[0].GetWinPathString() == CString(buf) + _T("\\Path1"));
1837 ATLASSERT(testList[1].GetWinPathString() == _T("c:\\path2 with spaces and stuff"));
1838 ATLASSERT(testList[2].GetWinPathString() == _T("\\funnypath"));
1840 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T(""));
1841 testList.Clear();
1842 sPathList = _T("c:\\path2 with spaces and stuff*c:\\funnypath\\*");
1843 testList.LoadFromAsteriskSeparatedString(sPathList);
1844 ATLASSERT(testList.GetCommonRoot().GetWinPathString() == _T("c:\\"));
1846 #endif
1848 void ContainingDirectoryTest()
1851 CTGitPath testPath;
1852 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1853 CTGitPath dir;
1854 dir = testPath.GetContainingDirectory();
1855 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c\\d"));
1856 dir = dir.GetContainingDirectory();
1857 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b\\c"));
1858 dir = dir.GetContainingDirectory();
1859 ATLASSERT(dir.GetWinPathString() == _T("c:\\a\\b"));
1860 dir = dir.GetContainingDirectory();
1861 ATLASSERT(dir.GetWinPathString() == _T("c:\\a"));
1862 dir = dir.GetContainingDirectory();
1863 ATLASSERT(dir.GetWinPathString() == _T("c:\\"));
1864 dir = dir.GetContainingDirectory();
1865 ATLASSERT(dir.IsEmpty());
1866 ATLASSERT(dir.GetWinPathString() == _T(""));
1869 void AncestorTest()
1871 CTGitPath testPath;
1872 testPath.SetFromWin(_T("c:\\windows"));
1873 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\")))==false);
1874 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows"))));
1875 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windowsdummy")))==false);
1876 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\test.txt"))));
1877 ATLASSERT(testPath.IsAncestorOf(CTGitPath(_T("c:\\windows\\system32\\test.txt"))));
1880 void SubversionPathTest()
1882 CTGitPath testPath;
1883 testPath.SetFromWin(_T("c:\\"));
1884 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:") == 0);
1885 testPath.SetFromWin(_T("c:\\folder"));
1886 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/folder") == 0);
1887 testPath.SetFromWin(_T("c:\\a\\b\\c\\d\\e"));
1888 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "c:/a/b/c/d/e") == 0);
1889 testPath.SetFromUnknown(_T("http://testing/"));
1890 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing") == 0);
1891 testPath.SetFromGit(NULL);
1892 ATLASSERT(strlen(testPath.GetGitApiPath(pool))==0);
1893 #if defined(_MFC_VER)
1894 testPath.SetFromUnknown(_T("http://testing again"));
1895 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1896 testPath.SetFromUnknown(_T("http://testing%20again"));
1897 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20again") == 0);
1898 testPath.SetFromUnknown(_T("http://testing special chars \344\366\374"));
1899 ATLASSERT(strcmp(testPath.GetGitApiPath(pool), "http://testing%20special%20chars%20%c3%a4%c3%b6%c3%bc") == 0);
1900 #endif
1903 void GetCommonRootTest()
1905 CTGitPath pathA (_T("C:\\Development\\LogDlg.cpp"));
1906 CTGitPath pathB (_T("C:\\Development\\LogDlg.h"));
1907 CTGitPath pathC (_T("C:\\Development\\SomeDir\\LogDlg.h"));
1909 CTGitPathList list;
1910 list.AddPath(pathA);
1911 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development\\LogDlg.cpp"))==0);
1912 list.AddPath(pathB);
1913 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1914 list.AddPath(pathC);
1915 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("C:\\Development"))==0);
1916 #ifdef _MFC_VER
1917 list.Clear();
1918 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");
1919 list.LoadFromAsteriskSeparatedString(sPathList);
1920 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("D:\\Development\\StExBar"))==0);
1922 list.Clear();
1923 sPathList = _T("c:\\windows\\explorer.exe*c:\\windows");
1924 list.LoadFromAsteriskSeparatedString(sPathList);
1925 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1927 list.Clear();
1928 sPathList = _T("c:\\windows\\*c:\\windows");
1929 list.LoadFromAsteriskSeparatedString(sPathList);
1930 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1932 list.Clear();
1933 sPathList = _T("c:\\windows\\system32*c:\\windows\\system");
1934 list.LoadFromAsteriskSeparatedString(sPathList);
1935 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\windows"))==0);
1937 list.Clear();
1938 sPathList = _T("c:\\windowsdummy*c:\\windows");
1939 list.LoadFromAsteriskSeparatedString(sPathList);
1940 ATLASSERT(list.GetCommonRoot().GetWinPathString().CompareNoCase(_T("c:\\"))==0);
1941 #endif
1944 void ValidPathAndUrlTest()
1946 CTGitPath testPath;
1947 testPath.SetFromWin(_T("c:\\a\\b\\c.test.txt"));
1948 ATLASSERT(testPath.IsValidOnWindows());
1949 testPath.SetFromWin(_T("c:\\"));
1950 ATLASSERT(testPath.IsValidOnWindows());
1951 testPath.SetFromWin(_T("D:\\.Net\\SpindleSearch\\"));
1952 ATLASSERT(testPath.IsValidOnWindows());
1953 testPath.SetFromWin(_T("c"));
1954 ATLASSERT(testPath.IsValidOnWindows());
1955 testPath.SetFromWin(_T("c:\\test folder\\file"));
1956 ATLASSERT(testPath.IsValidOnWindows());
1957 testPath.SetFromWin(_T("c:\\folder\\"));
1958 ATLASSERT(testPath.IsValidOnWindows());
1959 testPath.SetFromWin(_T("c:\\ext.ext.ext\\ext.ext.ext.ext"));
1960 ATLASSERT(testPath.IsValidOnWindows());
1961 testPath.SetFromWin(_T("c:\\.svn"));
1962 ATLASSERT(testPath.IsValidOnWindows());
1963 testPath.SetFromWin(_T("c:\\com\\file"));
1964 ATLASSERT(testPath.IsValidOnWindows());
1965 testPath.SetFromWin(_T("c:\\test\\conf"));
1966 ATLASSERT(testPath.IsValidOnWindows());
1967 testPath.SetFromWin(_T("c:\\LPT"));
1968 ATLASSERT(testPath.IsValidOnWindows());
1969 testPath.SetFromWin(_T("c:\\test\\LPT"));
1970 ATLASSERT(testPath.IsValidOnWindows());
1971 testPath.SetFromWin(_T("c:\\com1test"));
1972 ATLASSERT(testPath.IsValidOnWindows());
1973 testPath.SetFromWin(_T("\\\\?\\c:\\test\\com1test"));
1974 ATLASSERT(testPath.IsValidOnWindows());
1976 testPath.SetFromWin(_T("\\\\Share\\filename"));
1977 ATLASSERT(testPath.IsValidOnWindows());
1978 testPath.SetFromWin(_T("\\\\Share\\filename.extension"));
1979 ATLASSERT(testPath.IsValidOnWindows());
1980 testPath.SetFromWin(_T("\\\\Share\\.svn"));
1981 ATLASSERT(testPath.IsValidOnWindows());
1983 // now the negative tests
1984 testPath.SetFromWin(_T("c:\\test:folder"));
1985 ATLASSERT(!testPath.IsValidOnWindows());
1986 testPath.SetFromWin(_T("c:\\file<name"));
1987 ATLASSERT(!testPath.IsValidOnWindows());
1988 testPath.SetFromWin(_T("c:\\something*else"));
1989 ATLASSERT(!testPath.IsValidOnWindows());
1990 testPath.SetFromWin(_T("c:\\folder\\file?nofile"));
1991 ATLASSERT(!testPath.IsValidOnWindows());
1992 testPath.SetFromWin(_T("c:\\ext.>ension"));
1993 ATLASSERT(!testPath.IsValidOnWindows());
1994 testPath.SetFromWin(_T("c:\\com1\\filename"));
1995 ATLASSERT(!testPath.IsValidOnWindows());
1996 testPath.SetFromWin(_T("c:\\com1"));
1997 ATLASSERT(!testPath.IsValidOnWindows());
1998 testPath.SetFromWin(_T("c:\\com1\\AuX"));
1999 ATLASSERT(!testPath.IsValidOnWindows());
2001 testPath.SetFromWin(_T("\\\\Share\\lpt9\\filename"));
2002 ATLASSERT(!testPath.IsValidOnWindows());
2003 testPath.SetFromWin(_T("\\\\Share\\prn"));
2004 ATLASSERT(!testPath.IsValidOnWindows());
2005 testPath.SetFromWin(_T("\\\\Share\\NUL"));
2006 ATLASSERT(!testPath.IsValidOnWindows());
2008 // now come some URL tests
2009 testPath.SetFromGit(_T("http://myserver.com/repos/trunk"));
2010 ATLASSERT(testPath.IsValidOnWindows());
2011 testPath.SetFromGit(_T("https://myserver.com/repos/trunk/file%20with%20spaces"));
2012 ATLASSERT(testPath.IsValidOnWindows());
2013 testPath.SetFromGit(_T("svn://myserver.com/repos/trunk/file with spaces"));
2014 ATLASSERT(testPath.IsValidOnWindows());
2015 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk"));
2016 ATLASSERT(testPath.IsValidOnWindows());
2017 testPath.SetFromGit(_T("http://localhost:90/repos/trunk"));
2018 ATLASSERT(testPath.IsValidOnWindows());
2019 testPath.SetFromGit(_T("file:///C:/GitRepos/Tester/Proj1/tags/t2"));
2020 ATLASSERT(testPath.IsValidOnWindows());
2021 // and some negative URL tests
2022 testPath.SetFromGit(_T("httpp://myserver.com/repos/trunk"));
2023 ATLASSERT(!testPath.IsValidOnWindows());
2024 testPath.SetFromGit(_T("https://myserver.com/rep:os/trunk/file%20with%20spaces"));
2025 ATLASSERT(!testPath.IsValidOnWindows());
2026 testPath.SetFromGit(_T("svn://myserver.com/rep<os/trunk/file with spaces"));
2027 ATLASSERT(!testPath.IsValidOnWindows());
2028 testPath.SetFromGit(_T("svn+ssh://www.myserver.com/repos/trunk/prn/"));
2029 ATLASSERT(!testPath.IsValidOnWindows());
2030 testPath.SetFromGit(_T("http://localhost:90/repos/trunk/com1"));
2031 ATLASSERT(!testPath.IsValidOnWindows());
2035 } TGitPathTestobject;
2036 #endif
2037 #endif
2039 CTGitPath * CTGitPathList::LookForGitPath(CString path)
2041 int i=0;
2042 for (i = 0; i < this->GetCount(); ++i)
2044 if((*this)[i].GetGitPathString() == path )
2045 return (CTGitPath*)&(*this)[i];
2047 return NULL;
2049 CString CTGitPath::GetActionName(int action)
2051 if(action & CTGitPath::LOGACTIONS_UNMERGED)
2052 return MAKEINTRESOURCE(IDS_PATHACTIONS_CONFLICT);
2053 if(action & CTGitPath::LOGACTIONS_ADDED)
2054 return MAKEINTRESOURCE(IDS_PATHACTIONS_ADD);
2055 if(action & CTGitPath::LOGACTIONS_DELETED)
2056 return MAKEINTRESOURCE(IDS_PATHACTIONS_DELETE);
2057 if(action & CTGitPath::LOGACTIONS_MERGED )
2058 return MAKEINTRESOURCE(IDS_PATHACTIONS_MERGED);
2060 if(action & CTGitPath::LOGACTIONS_MODIFIED)
2061 return MAKEINTRESOURCE(IDS_PATHACTIONS_MODIFIED);
2062 if(action & CTGitPath::LOGACTIONS_REPLACED)
2063 return MAKEINTRESOURCE(IDS_PATHACTIONS_RENAME);
2064 if(action & CTGitPath::LOGACTIONS_COPY)
2065 return MAKEINTRESOURCE(IDS_PATHACTIONS_COPY);
2067 if(action & CTGitPath::LOGACTIONS_FORWORD )
2068 return MAKEINTRESOURCE(IDS_PATHACTIONS_FORWARD);
2070 if (action & CTGitPath::LOGACTIONS_ASSUMEVALID)
2071 return MAKEINTRESOURCE(IDS_PATHACTIONS_ASSUMEUNCHANGED);
2072 if (action & CTGitPath::LOGACTIONS_SKIPWORKTREE)
2073 return MAKEINTRESOURCE(IDS_PATHACTIONS_SKIPWORKTREE);
2075 return MAKEINTRESOURCE(IDS_PATHACTIONS_UNKNOWN);
2077 CString CTGitPath::GetActionName()
2079 return GetActionName(m_Action);
2082 int CTGitPathList::GetAction()
2084 return m_Action;