1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2008 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "CloneCommand.h"
22 //#include "SVNProgressDlg.h"
23 #include "StringUtils.h"
25 #include "MessageBox.h"
28 #include "ProgressDlg.h"
31 bool CloneCommand::Execute()
34 dlg
.m_Directory
=this->orgCmdLinePath
.GetWinPathString();
35 if(dlg
.DoModal()==IDOK
)
39 BareStr
= _T("--bare");
43 if(dlg
.m_bAutoloadPuttyKeyFile
)
45 CAppUtils::LaunchPAgent(&dlg
.m_strPuttyKeyFile
);
48 CAppUtils::RemoveTrailSlash(dlg
.m_Directory
);
49 CAppUtils::RemoveTrailSlash(dlg
.m_URL
);
51 CString dir
=dlg
.m_Directory
;
52 CString url
=dlg
.m_URL
;
54 // is this a windows format UNC path, ie starts with \\
55 if (url
.Find(_T("\\\\")) == 0)
57 // yes, change all \ to /
58 // this should not be necessary but msysgit does not support the use \ here yet
59 url
.Replace( _T('\\'), _T('/'));
66 depth
.Format(_T(" --depth %d"),dlg
.m_nDepth
);
72 int ver
= CAppUtils::GetMsysgitVersion();
74 if(ver
>= 0x01070002) //above 1.7.0.2
75 progressarg
= _T("--progress");
78 cmd
.Format(_T("git.exe clone %s %s -v %s \"%s\" \"%s\""),
86 // Handle Git SVN-clone
90 //g_Git.m_CurrentDir=dlg.m_Directory;
91 cmd
.Format(_T("git.exe svn clone \"%s\" \"%s\""),
95 cmd
+=_T(" -T ")+dlg
.m_strSVNTrunk
;
98 cmd
+=_T(" -b ")+dlg
.m_strSVNBranchs
;
101 cmd
+=_T(" -t ")+dlg
.m_strSVNTags
;
106 str
.Format(_T("%d:HEAD"),dlg
.m_nSVNFrom
);
110 if(dlg
.m_bSVNUserName
)
112 cmd
+= _T(" --username ");
113 cmd
+=dlg
.m_strUserName
;
116 CProgressDlg progress
;
117 progress
.m_GitCmd
=cmd
;
118 int ret
= progress
.DoModal();
120 if( progress
.m_GitStatus
== 0)
122 if(dlg
.m_bAutoloadPuttyKeyFile
)
124 g_Git
.m_CurrentDir
= dlg
.m_Directory
;
126 if(g_Git
.SetConfigValue(_T("remote.origin.puttykeyfile"),dlg
.m_strPuttyKeyFile
, CONFIG_LOCAL
,CP_ACP
,&dlg
.m_Directory
))
128 CMessageBox::Show(NULL
,_T("Fail set config remote.origin.puttykeyfile"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);