1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseGit
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
19 #include "UnicodeUtils.h"
\r
20 #include "GitAdminDir.h"
\r
22 GitAdminDir g_GitAdminDir;
\r
24 GitAdminDir::GitAdminDir()
\r
26 // , m_bVSNETHack(false)
\r
31 GitAdminDir::~GitAdminDir()
\r
37 bool GitAdminDir::Init()
\r
42 m_bVSNETHack = false;
\r
43 m_pool = svn_pool_create(NULL);
\r
45 getenv_s(&ret, NULL, 0, "GIT_ASP_DOT_NET_HACK");
\r
48 svn_error_clear(svn_wc_set_adm_dir("_git", m_pool));
\r
49 m_bVSNETHack = true;
\r
57 bool GitAdminDir::Close()
\r
63 svn_pool_destroy(m_pool);
\r
68 bool GitAdminDir::IsAdminDirName(const CString& name) const
\r
71 CStringA nameA = CUnicodeUtils::GetUTF8(name).MakeLower();
\r
72 return !!svn_wc_is_adm_dir(nameA, m_pool);
\r
74 return name == ".git";
\r
76 CString GitAdminDir::GetGitTopDir(const CString& path)
\r
80 HasAdminDir(path,!!PathIsDirectory(path),&str);
\r
84 bool GitAdminDir::HasAdminDir(const CString& path) const
\r
86 return HasAdminDir(path, !!PathIsDirectory(path));
\r
89 bool GitAdminDir::HasAdminDir(const CString& path,CString *ProjectTopDir) const
\r
91 return HasAdminDir(path, !!PathIsDirectory(path),ProjectTopDir);
\r
94 bool GitAdminDir::HasAdminDir(const CString& path, bool bDir,CString *ProjectTopDir) const
\r
98 bool bHasAdminDir = false;
\r
99 CString sDirName = path;
\r
102 sDirName = path.Left(path.ReverseFind('\\'));
\r
107 if(PathFileExists(sDirName + _T("\\.git")))
\r
110 *ProjectTopDir=sDirName;
\r
113 sDirName = sDirName.Left(sDirName.ReverseFind('\\'));
\r
115 }while(sDirName.ReverseFind('\\')>0);
\r
121 bool GitAdminDir::IsAdminDirPath(const CString& path) const
\r
123 if (path.IsEmpty())
\r
125 bool bIsAdminDir = false;
\r
126 CString lowerpath = path;
\r
127 lowerpath.MakeLower();
\r
130 while ((ind1 = lowerpath.Find(_T("\\.git"), ind1))>=0)
\r
133 if (ind == (lowerpath.GetLength() - 5))
\r
135 bIsAdminDir = true;
\r
138 else if (lowerpath.Find(_T("\\.git\\"), ind)>=0)
\r
140 bIsAdminDir = true;
\r
145 return bIsAdminDir;
\r