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
)
37 if(dlg
.m_bAutoloadPuttyKeyFile
)
39 CAppUtils::LaunchPAgent(&dlg
.m_strPuttyKeyFile
);
42 CAppUtils::RemoveTrailSlash(dlg
.m_Directory
);
43 CAppUtils::RemoveTrailSlash(dlg
.m_URL
);
45 CString dir
=dlg
.m_Directory
;
46 CString url
=dlg
.m_URL
;
48 // is this a windows format UNC path, ie starts with \\
49 if (url
.Find(_T("\\\\")) == 0)
51 // yes, change all \ to /
52 // this should not be necessary but msysgit does not support the use \ here yet
53 url
.Replace( _T('\\'), _T('/'));
60 depth
.Format(_T(" --depth %d"),dlg
.m_nDepth
);
66 cmd
= _T("git.exe --version");
67 if(g_Git
.Run(cmd
, &version
, CP_ACP
))
69 CMessageBox::Show(NULL
,_T("git have not installed"), _T("TortoiseGit"), MB_OK
|MB_ICONERROR
);
76 CString str
=version
.Tokenize(_T("."),start
);
77 int space
= str
.ReverseFind(_T(' '));
78 str
=str
.Mid(space
+1,start
);
81 version
= version
.Mid(start
);
83 str
= version
.Tokenize(_T("."),start
);
84 ver
|= _ttol(str
)&0xFFFF;
86 if(ver
>= 0x10007) //above 1.7.0.2
87 progressarg
= _T("--progress");
90 cmd
.Format(_T("git.exe clone %s -v %s \"%s\" \"%s\""),
97 // Handle Git SVN-clone
101 //g_Git.m_CurrentDir=dlg.m_Directory;
102 cmd
.Format(_T("git.exe svn clone \"%s\" \"%s\""),
103 url
,dlg
.m_Directory
);
106 cmd
+=_T(" -T ")+dlg
.m_strSVNTrunk
;
109 cmd
+=_T(" -b ")+dlg
.m_strSVNBranchs
;
112 cmd
+=_T(" -t ")+dlg
.m_strSVNTags
;
117 str
.Format(_T("%d:HEAD"),dlg
.m_nSVNFrom
);
122 CProgressDlg progress
;
123 progress
.m_GitCmd
=cmd
;
124 int ret
= progress
.DoModal();
126 if( progress
.m_GitStatus
== 0)
128 if(dlg
.m_bAutoloadPuttyKeyFile
)
130 g_Git
.m_CurrentDir
= dlg
.m_Directory
;
132 cmd
.Format(_T("git.exe config remote.origin.puttykeyfile \"%s\""),dlg
.m_strPuttyKeyFile
);
133 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
135 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);