Add PostCmdActions to GitProgressList
[TortoiseGit.git] / src / TortoiseProc / ProgressCommands / ResolveProgressCommand.cpp
blob0bb478257b40165cd3c1ab59395866b92264bddb
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2014 - TortoiseGit
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.
19 #include "stdafx.h"
20 #include "ResolveProgressCommand.h"
21 #include "ShellUpdater.h"
22 #include "AppUtils.h"
24 bool ResolveProgressCommand::Run(CGitProgressList* list, CString& sWindowTitle, int& m_itemCountTotal, int& m_itemCount)
26 ASSERT(m_targetPathList.GetCount() == 1);
27 list->SetWindowTitle(IDS_PROGRS_TITLE_RESOLVE, g_Git.CombinePath(m_targetPathList.GetCommonRoot().GetUIPathString()), sWindowTitle);
28 list->SetBackgroundImage(IDI_RESOLVE_BKG);
30 m_itemCountTotal = m_targetPathList.GetCount();
31 for (m_itemCount = 0; m_itemCount < m_itemCountTotal; ++m_itemCount)
33 CString cmd, out, tempmergefile;
34 cmd.Format(_T("git.exe add -f -- \"%s\""), m_targetPathList[m_itemCount].GetGitPathString());
35 if (g_Git.Run(cmd, &out, CP_UTF8))
37 list->ReportError(out);
38 return false;
41 CAppUtils::RemoveTempMergeFile((CTGitPath &)m_targetPathList[m_itemCount]);
43 list->AddNotify(new CGitProgressList::WC_File_NotificationData(m_targetPathList[m_itemCount], CGitProgressList::WC_File_NotificationData::git_wc_notify_resolved));
46 CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);
48 m_PostCmdCallback = [](DWORD status, PostCmdList& postCmdList)
50 if (status)
51 return;
53 postCmdList.push_back(PostCmd(IDI_COMMIT, IDS_MENUCOMMIT, []
55 CString sCmd;
56 sCmd.Format(_T("/command:commit /path:\"%s\""), g_Git.m_CurrentDir);
57 CAppUtils::RunTortoiseGitProc(sCmd);
58 }));
61 return true;
64 bool ResolveProgressCommand::ShowInfo(CString& info)
66 info = _T("You need commit your change after resolve conflict");
67 return true;