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 SubmoduleUpdateCommand::Execute()
\r
66 CProgressDlg progress;
\r
67 CString bkpath=parser.GetVal(_T("bkpath"));
\r
69 CString super=g_GitAdminDir.GetSuperProjectRoot( bkpath );
\r
72 CMessageBox::Show(NULL,_T("Can't found Super project"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
\r
73 //change current project root to super project
\r
77 g_Git.m_CurrentDir=super;
\r
79 progress.m_Title.Format(_T("Submodule update - %s"),super);
\r
81 //progress.m_GitCmd.Format(_T("git.exe submodule update --init "));
\r
84 for(int i=0;i<this->orgPathList.GetCount();i++)
\r
86 str.Format(_T("git.exe submodule update --init \"%s\""),((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());
\r
87 progress.m_GitCmdList.push_back(str);
\r
92 return !progress.m_GitStatus;
\r