MCPcopy Create free account
hub / github.com/TortoiseGit/TortoiseGit / GetCommonRoot

Method GetCommonRoot

src/Git/TGitPath.cpp:1617–1649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1615}
1616
1617CTGitPath CTGitPathList::GetCommonRoot() const
1618{
1619 if (IsEmpty())
1620 return CTGitPath();
1621
1622 if (GetCount() == 1)
1623 return m_paths[0];
1624
1625 // first entry is common root for itself
1626 // (add trailing '\\' to detect partial matches of the last path element)
1627 CString root = m_paths[0].GetWinPathString() + L'\\';
1628 int rootLength = root.GetLength();
1629
1630 // determine common path string prefix
1631 for (auto it = m_paths.cbegin() + 1; it != m_paths.cend(); ++it)
1632 {
1633 CString path = it->GetWinPathString() + L'\\';
1634
1635 int newLength = CStringUtils::GetMatchingLength(root, path);
1636 if (newLength != rootLength)
1637 {
1638 root.Delete(newLength, rootLength);
1639 rootLength = newLength;
1640 }
1641 }
1642
1643 // remove the last (partial) path element
1644 if (rootLength > 0)
1645 root.Delete(root.ReverseFind(L'\\'), rootLength);
1646
1647 // done
1648 return CTGitPath(root);
1649}
1650
1651void CTGitPathList::SortByPathname(bool bReverse /*= false*/)
1652{

Callers 15

TESTFunction · 0.80
GetCommonDirectoryMethod · 0.80
OnInitDialogMethod · 0.80
OnBnClickedCommitMethod · 0.80
OnInitDialogMethod · 0.80
OnOKMethod · 0.80
OnInitDialogMethod · 0.80
SetDlgTitleMethod · 0.80
RunMethod · 0.80
RunMethod · 0.80

Calls 5

cbeginMethod · 0.80
cendMethod · 0.80
CTGitPathClass · 0.70
GetLengthMethod · 0.45
DeleteMethod · 0.45

Tested by 1

TESTFunction · 0.64