1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2008-2009 - 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
20 #include "SubmoduleCommand.h"
\r
22 #include "MessageBox.h"
\r
23 #include "RenameDlg.h"
\r
24 #include "InputLogDlg.h"
\r
26 #include "DirFileEnum.h"
\r
27 #include "ShellUpdater.h"
\r
28 #include "SubmoduleAddDlg.h"
\r
29 #include "ProgressDlg.h"
\r
31 bool SubmoduleAddCommand::Execute()
\r
34 CSubmoduleAddDlg dlg;
\r
35 dlg.m_strPath = cmdLinePath.GetDirectory().GetWinPathString();
\r
36 dlg.m_strProject = g_Git.m_CurrentDir;
\r
37 if( dlg.DoModal() == IDOK )
\r
40 if(dlg.m_strPath.Left(g_Git.m_CurrentDir.GetLength()) == g_Git.m_CurrentDir)
\r
41 dlg.m_strPath = dlg.m_strPath.Right(dlg.m_strPath.GetLength()-g_Git.m_CurrentDir.GetLength()-1);
\r
45 branch.Format(_T(" -b %s "), dlg.m_strBranch);
\r
47 dlg.m_strPath.Replace(_T('\\'),_T('/'));
\r
48 dlg.m_strRepos.Replace(_T('\\'),_T('/'));
\r
50 cmd.Format(_T("git.exe submodule add %s -- \"%s\" \"%s\""),
\r
52 dlg.m_strRepos, dlg.m_strPath);
\r
54 CProgressDlg progress;
\r
55 progress.m_GitCmd=cmd;
\r
63 bool SubmoduleCommand::Execute(CString cmd, CString arg)
\r
66 CProgressDlg progress;
\r
69 if(parser.HasKey(_T("bkpath")))
\r
71 bkpath=parser.GetVal(_T("bkpath"));
\r
75 bkpath=this->orgPathList[0].GetWinPathString();
\r
76 bkpath=bkpath.Left(bkpath.ReverseFind(_T('\\')));
\r
79 CString super=g_GitAdminDir.GetSuperProjectRoot( bkpath );
\r
82 CMessageBox::Show(NULL,_T("Can't found Super project"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
83 //change current project root to super project
\r
87 g_Git.m_CurrentDir=super;
\r
89 progress.m_Title.Format(_T("Submodule %s - %s"),cmd,super);
\r
91 //progress.m_GitCmd.Format(_T("git.exe submodule update --init "));
\r
94 for(int i=0;i<this->orgPathList.GetCount();i++)
\r
96 if(orgPathList[i].IsDirectory())
\r
98 str.Format(_T("git.exe submodule %s %s \"%s\""),cmd,arg, ((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());
\r
99 progress.m_GitCmdList.push_back(str);
\r
103 progress.DoModal();
\r
105 return !progress.m_GitStatus;
\r