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
21 #include "commonresource.h"
\r
23 #include "MessageBox.h"
\r
24 #include "RenameDlg.h"
\r
25 #include "InputLogDlg.h"
\r
27 #include "DirFileEnum.h"
\r
28 #include "ShellUpdater.h"
\r
29 #include "SubmoduleAddDlg.h"
\r
30 #include "ProgressDlg.h"
\r
32 bool SubmoduleAddCommand::Execute()
\r
35 CSubmoduleAddDlg dlg;
\r
36 dlg.m_strPath = cmdLinePath.GetDirectory().GetWinPathString();
\r
37 dlg.m_strProject = g_Git.m_CurrentDir;
\r
38 if( dlg.DoModal() == IDOK )
\r
41 if(dlg.m_strPath.Left(g_Git.m_CurrentDir.GetLength()) == g_Git.m_CurrentDir)
\r
42 dlg.m_strPath = dlg.m_strPath.Right(dlg.m_strPath.GetLength()-g_Git.m_CurrentDir.GetLength()-1);
\r
46 branch.Format(_T(" -b %s "), dlg.m_strBranch);
\r
48 dlg.m_strPath.Replace(_T('\\'),_T('/'));
\r
49 dlg.m_strRepos.Replace(_T('\\'),_T('/'));
\r
51 cmd.Format(_T("git.exe submodule add %s -- \"%s\" \"%s\""),
\r
53 dlg.m_strRepos, dlg.m_strPath);
\r
55 CProgressDlg progress;
\r
56 progress.m_GitCmd=cmd;
\r
64 bool SubmoduleCommand::Execute(CString cmd, CString arg)
\r
67 CProgressDlg progress;
\r
70 if(parser.HasKey(_T("bkpath")))
\r
72 bkpath=parser.GetVal(_T("bkpath"));
\r
76 bkpath=this->orgPathList[0].GetWinPathString();
\r
77 bkpath=bkpath.Left(bkpath.ReverseFind(_T('\\')));
\r
80 CString super=g_GitAdminDir.GetSuperProjectRoot( bkpath );
\r
83 CMessageBox::Show(NULL,IDS_ERR_NOTFOUND_SUPER_PRJECT,IDS_APPNAME,MB_OK|MB_ICONERROR);
\r
84 //change current project root to super project
\r
88 g_Git.m_CurrentDir=super;
\r
90 progress.m_Title.Format(_T("Submodule %s - %s"),cmd,super);
\r
92 //progress.m_GitCmd.Format(_T("git.exe submodule update --init "));
\r
95 for(int i=0;i<this->orgPathList.GetCount();i++)
\r
97 if(orgPathList[i].IsDirectory())
\r
99 str.Format(_T("git.exe submodule %s %s \"%s\""),cmd,arg, ((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());
\r
100 progress.m_GitCmdList.push_back(str);
\r
104 progress.DoModal();
\r
106 return !progress.m_GitStatus;
\r