Extend static functions in CAppUtils with a window handle parameter
[TortoiseGit.git] / src / TortoiseProc / Commands / ImportPatchCommand.cpp
blob29e9110f352691398dbb46421ef91def8e3abdc2
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2013, 2015-2018 - TortoiseGit
4 // Copyright (C) 2007-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "ImportPatchCommand.h"
22 #include "ImportPatchDlg.h"
23 #include "TGitPath.h"
24 #include "Git.h"
25 #include "AppUtils.h"
27 bool ImportPatchCommand::Execute()
29 CImportPatchDlg dlg;
30 CString cmd;
31 CString output;
33 CString droppath = parser.GetVal(L"droptarget");
34 if (!droppath.IsEmpty())
36 if (CTGitPath(droppath).IsAdminDir())
37 return FALSE;
39 if (!CTGitPath(droppath).HasAdminDir(&g_Git.m_CurrentDir))
41 CString err;
42 err.Format(IDS_ERR_NOT_REPOSITORY, (LPCTSTR)g_Git.m_CurrentDir);
43 MessageBox(hwndExplorer, err, L"TortoiseGit", MB_OK | MB_ICONERROR);
44 return FALSE;
47 else if (!orgPathList.IsEmpty() && !orgPathList[0].HasAdminDir())
49 CString str = CAppUtils::ChooseRepository(hwndExplorer, nullptr);
50 if(str.IsEmpty())
51 return FALSE;
53 CTGitPath path;
54 path.SetFromWin(str);
56 if(!path.HasAdminDir())
58 CString err;
59 err.Format(IDS_ERR_NOT_REPOSITORY, (LPCTSTR)str);
60 MessageBox(hwndExplorer, err, L"TortoiseGit", MB_OK | MB_ICONERROR);
61 return FALSE;
63 g_Git.m_CurrentDir=str;
66 for(int i = 0 ; i < this->orgPathList.GetCount(); ++i)
68 if(!orgPathList[i].IsDirectory())
69 dlg.m_PathList.AddPath(orgPathList[i]);
72 if(dlg.DoModal()==IDOK)
73 return TRUE;
75 return FALSE;