DeleteRemoteTagDlg: Allow to delete multiple tags at once
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.cpp
blob4f0fa68a42d4f48da3cf3e51b1a00f2e310a94ae
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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.
20 // SyncDlg.cpp : implementation file
23 #include "stdafx.h"
24 #include "TortoiseProc.h"
25 #include "SyncDlg.h"
26 #include "AppUtils.h"
27 #include "progressdlg.h"
28 #include "MessageBox.h"
29 #include "ImportPatchDlg.h"
30 #include "RebaseDlg.h"
31 #include "hooks.h"
32 #include "SmartHandle.h"
34 // CSyncDlg dialog
36 IMPLEMENT_DYNAMIC(CSyncDlg, CResizableStandAloneDialog)
38 CSyncDlg::CSyncDlg(CWnd* pParent /*=NULL*/)
39 : CResizableStandAloneDialog(CSyncDlg::IDD, pParent)
41 m_pTooltip=&this->m_tooltips;
42 m_bInited=false;
43 m_CmdOutCurrentPos=0;
44 m_bAutoLoadPuttyKey = CAppUtils::IsSSHPutty();
45 m_bForce=false;
46 m_bBlock = false;
49 CSyncDlg::~CSyncDlg()
53 void CSyncDlg::DoDataExchange(CDataExchange* pDX)
55 CDialog::DoDataExchange(pDX);
56 DDX_Check(pDX, IDC_CHECK_PUTTY_KEY, m_bAutoLoadPuttyKey);
57 DDX_Check(pDX, IDC_CHECK_FORCE,m_bForce);
58 DDX_Control(pDX, IDC_COMBOBOXEX_URL, m_ctrlURL);
59 DDX_Control(pDX, IDC_BUTTON_TABCTRL, m_ctrlDumyButton);
60 DDX_Control(pDX, IDC_BUTTON_PULL, m_ctrlPull);
61 DDX_Control(pDX, IDC_BUTTON_PUSH, m_ctrlPush);
62 DDX_Control(pDX, IDC_STATIC_STATUS, m_ctrlStatus);
63 DDX_Control(pDX, IDC_PROGRESS_SYNC, m_ctrlProgress);
64 DDX_Control(pDX, IDC_ANIMATE_SYNC, m_ctrlAnimate);
65 DDX_Control(pDX, IDC_BUTTON_SUBMODULE,m_ctrlSubmodule);
66 BRANCH_COMBOX_DDX;
70 BEGIN_MESSAGE_MAP(CSyncDlg, CResizableStandAloneDialog)
71 ON_BN_CLICKED(IDC_BUTTON_PULL, &CSyncDlg::OnBnClickedButtonPull)
72 ON_BN_CLICKED(IDC_BUTTON_PUSH, &CSyncDlg::OnBnClickedButtonPush)
73 ON_BN_CLICKED(IDC_BUTTON_APPLY, &CSyncDlg::OnBnClickedButtonApply)
74 ON_BN_CLICKED(IDC_BUTTON_EMAIL, &CSyncDlg::OnBnClickedButtonEmail)
75 ON_BN_CLICKED(IDC_BUTTON_MANAGE, &CSyncDlg::OnBnClickedButtonManage)
76 BRANCH_COMBOX_EVENT
77 ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_URL, &CSyncDlg::OnCbnEditchangeComboboxex)
78 ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_REMOTE_BRANCH, &CSyncDlg::OnCbnEditchangeComboboxex)
79 ON_MESSAGE(MSG_PROGRESSDLG_UPDATE_UI, OnProgressUpdateUI)
80 ON_NOTIFY(LVN_COLUMNCLICK, IDC_IN_LOGLIST, OnLvnInLogListColumnClick)
81 ON_BN_CLICKED(IDC_BUTTON_COMMIT, &CSyncDlg::OnBnClickedButtonCommit)
82 ON_BN_CLICKED(IDC_BUTTON_SUBMODULE, &CSyncDlg::OnBnClickedButtonSubmodule)
83 ON_WM_TIMER()
84 ON_REGISTERED_MESSAGE(WM_TASKBARBTNCREATED, OnTaskbarBtnCreated)
85 ON_BN_CLICKED(IDC_CHECK_FORCE, &CSyncDlg::OnBnClickedCheckForce)
86 ON_BN_CLICKED(IDC_LOG, &CSyncDlg::OnBnClickedLog)
87 END_MESSAGE_MAP()
90 void CSyncDlg::EnableControlButton(bool bEnabled)
92 GetDlgItem(IDC_BUTTON_PULL)->EnableWindow(bEnabled);
93 GetDlgItem(IDC_BUTTON_PUSH)->EnableWindow(bEnabled);
94 GetDlgItem(IDC_BUTTON_APPLY)->EnableWindow(bEnabled);
95 GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(bEnabled);
96 GetDlgItem(IDOK)->EnableWindow(bEnabled);
97 GetDlgItem(IDC_BUTTON_SUBMODULE)->EnableWindow(bEnabled);
99 // CSyncDlg message handlers
101 void CSyncDlg::OnBnClickedButtonPull()
103 int CurrentEntry;
104 CurrentEntry = (int)this->m_ctrlPull.GetCurrentEntry();
105 this->m_regPullButton = CurrentEntry;
107 this->m_bAbort=false;
108 this->m_GitCmdList.clear();
110 this->UpdateData();
111 UpdateCombox();
113 m_oldHash = g_Git.GetHash(_T("HEAD"));
115 if( CurrentEntry == 0)
117 if( g_Git.GetHash(this->m_strLocalBranch) != m_oldHash)
119 CMessageBox::Show(NULL, IDS_PROC_SYNC_PULLWRONGBRANCH, IDS_APPNAME, MB_OK | MB_ICONERROR);
120 return;
124 if(this->m_strURL.IsEmpty())
126 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
127 return;
130 if(this->m_bAutoLoadPuttyKey)
132 CAppUtils::LaunchPAgent(NULL,&this->m_strURL);
135 this->SwitchToRun();
137 CString force;
138 if(this->m_bForce)
139 force = _T(" --force ");
141 CString cmd;
143 ShowTab(IDC_CMD_LOG);
145 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
146 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
147 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
149 ///Pull
150 if(CurrentEntry == 0) //Pull
152 CString remotebranch;
153 remotebranch = m_strRemoteBranch;
155 if(!IsURL())
157 CString configName;
158 configName.Format(L"branch.%s.merge", this->m_strLocalBranch);
159 CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
161 configName.Format(L"branch.%s.remote", m_strLocalBranch);
162 CString pullRemote = g_Git.GetConfigValue(configName);
164 if(pullBranch == remotebranch && pullRemote == this->m_strURL)
165 remotebranch.Empty();
168 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
169 force += _T("--progress ");
171 cmd.Format(_T("git.exe pull -v %s \"%s\" %s"),
172 force,
173 m_strURL,
174 remotebranch);
176 m_CurrentCmd = GIT_COMMAND_PULL;
177 m_GitCmdList.push_back(cmd);
179 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
180 if (m_pThread==NULL)
182 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
184 else
186 m_pThread->m_bAutoDelete = TRUE;
187 m_pThread->ResumeThread();
192 ///Fetch
193 if(CurrentEntry == 1 || CurrentEntry ==2 ) //Fetch
195 CString remotebranch;
196 if(this->IsURL() || m_strRemoteBranch.IsEmpty())
198 remotebranch=this->m_strRemoteBranch;
201 else
203 remotebranch.Format(_T("remotes/%s/%s"),
204 m_strURL,m_strRemoteBranch);
205 if(g_Git.GetHash(remotebranch).IsEmpty())
206 remotebranch=m_strRemoteBranch;
207 else
208 remotebranch=m_strRemoteBranch+_T(":")+remotebranch;
211 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
212 force += _T("--progress ");
214 cmd.Format(_T("git.exe fetch -v %s \"%s\" %s"),
215 force,
216 m_strURL,
217 remotebranch);
219 if(CurrentEntry == 1)
220 m_CurrentCmd = GIT_COMMAND_FETCH;
221 else
222 m_CurrentCmd = GIT_COMMAND_FETCHANDREBASE;
223 m_GitCmdList.push_back(cmd);
225 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
226 if (m_pThread==NULL)
228 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
230 else
232 m_pThread->m_bAutoDelete = TRUE;
233 m_pThread->ResumeThread();
237 ///Remote Update
238 if(CurrentEntry == 3)
240 m_CurrentCmd = GIT_COMMAND_REMOTE;
241 cmd=_T("git.exe remote update");
242 m_GitCmdList.push_back(cmd);
244 InterlockedExchange(&m_bBlock, TRUE);
246 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
247 if (m_pThread==NULL)
249 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
250 InterlockedExchange(&m_bBlock, FALSE);
252 else
254 m_pThread->m_bAutoDelete = TRUE;
255 m_pThread->ResumeThread();
259 ///Cleanup stale remote banches
260 if(CurrentEntry == 4)
262 m_CurrentCmd = GIT_COMMAND_REMOTE;
263 cmd.Format(_T("git.exe remote prune \"%s\""), m_strURL);
264 m_GitCmdList.push_back(cmd);
266 InterlockedExchange(&m_bBlock, TRUE);
268 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
269 if (m_pThread==NULL)
271 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
272 InterlockedExchange(&m_bBlock, FALSE);
274 else
276 m_pThread->m_bAutoDelete = TRUE;
277 m_pThread->ResumeThread();
282 void CSyncDlg::PullComplete()
284 EnableControlButton(true);
285 SwitchToInput();
286 this->FetchOutList(true);
288 CString newhash;
289 newhash = g_Git.GetHash(_T("HEAD"));
291 if( this ->m_GitCmdStatus )
293 CTGitPathList list;
294 if(g_Git.ListConflictFile(list))
296 this->m_ctrlCmdOut.SetSel(-1,-1);
297 this->m_ctrlCmdOut.ReplaceSel(_T("Get conflict files fail\n"));
299 this->ShowTab(IDC_CMD_LOG);
300 return;
303 if(list.GetCount()>0)
305 this->m_ConflictFileList.Clear();
306 CTGitPathList list;
307 CTGitPath path;
308 list.AddPath(path);
310 this->m_ConflictFileList.GetStatus(&list,true);
311 this->m_ConflictFileList.Show(CTGitPath::LOGACTIONS_UNMERGED,
312 CTGitPath::LOGACTIONS_UNMERGED);
314 this->ShowTab(IDC_IN_CONFLICT);
316 else
317 this->ShowTab(IDC_CMD_LOG);
320 else
322 if(newhash == this->m_oldHash)
324 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
325 this->m_InLogList.ShowText(CString(MAKEINTRESOURCE(IDS_UPTODATE)));
326 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
328 else
330 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true);
331 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
333 CString oldhash=m_oldHash.ToString();
334 this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash);
336 m_InLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
337 &oldhash,&newhash);
339 this->ShowTab(IDC_IN_LOGLIST);
343 void CSyncDlg::FetchComplete()
345 EnableControlButton(true);
346 SwitchToInput();
347 this->FetchOutList(true);
349 ShowTab(IDC_CMD_LOG);
350 if( (!this->m_GitCmdStatus) && this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
352 CRebaseDlg dlg;
353 dlg.m_PostButtonTexts.Add(_T("Email &Patch..."));
354 INT_PTR response = dlg.DoModal();
355 if(response == IDOK)
357 return ;
360 if(response == IDC_REBASE_POST_BUTTON)
362 CString cmd, out, err;
363 cmd.Format(_T("git.exe format-patch -o \"%s\" %s..%s"),
364 g_Git.m_CurrentDir,
365 g_Git.FixBranchName(dlg.m_Upstream),
366 g_Git.FixBranchName(dlg.m_Branch));
367 if (g_Git.Run(cmd, &out, &err, CP_UTF8))
369 CMessageBox::Show(NULL, out + L"\n" + err, _T("TortoiseGit"), MB_OK|MB_ICONERROR);
370 return ;
373 CAppUtils::SendPatchMail(cmd,out);
378 void CSyncDlg::OnBnClickedButtonPush()
380 this->UpdateData();
381 UpdateCombox();
383 if(this->m_strURL.IsEmpty())
385 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
386 return;
389 this->m_regPushButton=(DWORD)this->m_ctrlPush.GetCurrentEntry();
390 this->SwitchToRun();
391 this->m_bAbort=false;
392 this->m_GitCmdList.clear();
394 ShowTab(IDC_CMD_LOG);
396 CString cmd;
397 CString arg;
399 CString error;
400 DWORD exitcode;
401 CTGitPathList list;
402 list.AddPath(CTGitPath(g_Git.m_CurrentDir));
404 if (CHooks::Instance().PrePush(list,exitcode, error))
406 if (exitcode)
408 CString temp;
409 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
410 //ReportError(temp);
411 CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
412 return ;
416 switch (m_ctrlPush.GetCurrentEntry())
418 case 1:
419 arg += _T(" --tags ");
420 break;
421 case 2:
422 arg += _T(" --all ");
423 break;
426 if(this->m_bForce)
427 arg += _T(" --force ");
429 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
430 arg += _T("--progress ");
432 cmd.Format(_T("git.exe push -v %s \"%s\" %s"),
433 arg,
434 m_strURL,
435 g_Git.FixBranchName(m_strLocalBranch));
437 if (!m_strRemoteBranch.IsEmpty())
439 cmd += _T(":") + m_strRemoteBranch;
442 m_GitCmdList.push_back(cmd);
444 m_CurrentCmd = GIT_COMMAND_PUSH;
446 if(this->m_bAutoLoadPuttyKey)
448 CAppUtils::LaunchPAgent(NULL,&this->m_strURL);
451 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
452 if (m_pThread==NULL)
454 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
456 else
458 m_pThread->m_bAutoDelete = TRUE;
459 m_pThread->ResumeThread();
463 void CSyncDlg::OnBnClickedButtonApply()
465 CString oldhash;
466 oldhash=g_Git.GetHash(_T("HEAD"));
468 CImportPatchDlg dlg;
469 CString cmd,output;
471 if(dlg.DoModal() == IDOK)
473 int err=0;
474 for(int i=0;i<dlg.m_PathList.GetCount();i++)
476 cmd.Format(_T("git.exe am \"%s\""),dlg.m_PathList[i].GetGitPathString());
478 if (g_Git.Run(cmd, &output, CP_UTF8))
480 CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK);
482 err=1;
483 break;
485 this->m_ctrlCmdOut.SetSel(-1,-1);
486 this->m_ctrlCmdOut.ReplaceSel(cmd+_T("\n"));
487 this->m_ctrlCmdOut.SetSel(-1,-1);
488 this->m_ctrlCmdOut.ReplaceSel(output);
491 CString newhash=g_Git.GetHash(_T("HEAD"));
493 this->m_InLogList.Clear();
494 this->m_InChangeFileList.Clear();
496 if(newhash == oldhash)
498 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
499 this->m_InLogList.ShowText(_T("No commits get from patch"));
500 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
503 else
505 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true);
506 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
508 this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash);
509 m_InLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
510 &oldhash,&newhash);
512 this->FetchOutList(true);
515 this->m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,true);
517 if(err)
519 this->ShowTab(IDC_CMD_LOG);
521 else
523 this->ShowTab(IDC_IN_LOGLIST);
528 void CSyncDlg::OnBnClickedButtonEmail()
530 CString cmd, out, err;
532 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
533 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
534 this->m_ctrlURL.GetWindowText(this->m_strURL);
535 m_strURL=m_strURL.Trim();
536 m_strRemoteBranch=m_strRemoteBranch.Trim();
538 cmd.Format(_T("git.exe format-patch -o \"%s\" %s..%s"),
539 g_Git.m_CurrentDir,
540 m_strURL+_T('/')+m_strRemoteBranch,g_Git.FixBranchName(m_strLocalBranch));
542 if (g_Git.Run(cmd, &out, &err, CP_UTF8))
544 CMessageBox::Show(NULL, out + L"\n" + err, _T("TortoiseGit"), MB_OK|MB_ICONERROR);
545 return ;
548 CAppUtils::SendPatchMail(cmd,out);
551 void CSyncDlg::ShowProgressCtrl(bool bShow)
553 int b=bShow?SW_NORMAL:SW_HIDE;
554 this->m_ctrlAnimate.ShowWindow(b);
555 this->m_ctrlProgress.ShowWindow(b);
556 this->m_ctrlAnimate.Open(IDR_DOWNLOAD);
557 if(b == SW_NORMAL)
558 this->m_ctrlAnimate.Play(0, UINT_MAX, UINT_MAX);
559 else
560 this->m_ctrlAnimate.Stop();
562 void CSyncDlg::ShowInputCtrl(bool bShow)
564 int b=bShow?SW_NORMAL:SW_HIDE;
565 this->m_ctrlURL.ShowWindow(b);
566 this->m_ctrlLocalBranch.ShowWindow(b);
567 this->m_ctrlRemoteBranch.ShowWindow(b);
568 this->GetDlgItem(IDC_BUTTON_LOCAL_BRANCH)->ShowWindow(b);
569 this->GetDlgItem(IDC_BUTTON_REMOTE_BRANCH)->ShowWindow(b);
570 this->GetDlgItem(IDC_STATIC_LOCAL_BRANCH)->ShowWindow(b);
571 this->GetDlgItem(IDC_STATIC_REMOTE_BRANCH)->ShowWindow(b);
572 this->GetDlgItem(IDC_BUTTON_MANAGE)->ShowWindow(b);
573 this->GetDlgItem(IDC_CHECK_PUTTY_KEY)->ShowWindow(b);
574 this->GetDlgItem(IDC_CHECK_FORCE)->ShowWindow(b);
575 this->GetDlgItem(IDC_STATIC_REMOTE_URL)->ShowWindow(b);
577 BOOL CSyncDlg::OnInitDialog()
579 CResizableStandAloneDialog::OnInitDialog();
580 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
582 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
583 // do this, Explorer would be unable to send that message to our window if we
584 // were running elevated. It's OK to make the call all the time, since if we're
585 // not elevated, this is a no-op.
586 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
587 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
588 CAutoLibrary hUser = ::LoadLibrary(_T("user32.dll"));
589 if (hUser)
591 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
592 if (pfnChangeWindowMessageFilterEx)
594 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
597 m_pTaskbarList.Release();
598 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
600 this->GetDlgItem(IDC_CHECK_PUTTY_KEY)->EnableWindow(CAppUtils::IsSSHPutty());
603 this->m_ctrlAnimate.ShowWindow(SW_NORMAL);
604 this->m_ctrlAnimate.Open(IDR_DOWNLOAD);
605 this->m_ctrlAnimate.Play(0,-1,-1);
608 // ------------------ Create Tabctrl -----------
609 CWnd *pwnd=this->GetDlgItem(IDC_BUTTON_TABCTRL);
610 CRect rectDummy;
611 pwnd->GetWindowRect(&rectDummy);
612 this->ScreenToClient(rectDummy);
614 if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_SYNC_TAB))
616 TRACE0("Failed to create output tab window\n");
617 return FALSE; // fail to create
619 m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);
621 // -------------Create Command Log Ctrl ---------
622 DWORD dwStyle;
623 dwStyle= ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL |WS_VSCROLL ;
625 if( !m_ctrlCmdOut.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_CMD_LOG))
627 TRACE0("Failed to create Log commits window\n");
628 return FALSE; // fail to create
631 // set the font to use in the log message view, configured in the settings dialog
632 CFont m_logFont;
633 CAppUtils::CreateFontForLogs(m_logFont);
634 //GetDlgItem(IDC_CMD_LOG)->SetFont(&m_logFont);
635 m_ctrlCmdOut.SetFont(&m_logFont);
636 m_ctrlTabCtrl.InsertTab(&m_ctrlCmdOut, CString(MAKEINTRESOURCE(IDS_LOG)), -1);
638 //m_ctrlCmdOut.ReplaceSel(_T("Hello"));
640 //---------- Create in coming list ctrl -----------
641 dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;;
643 if( !m_InLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_LOGLIST))
645 TRACE0("Failed to create output commits window\n");
646 return FALSE; // fail to create
649 m_ctrlTabCtrl.InsertTab(&m_InLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCOMMITS)), -1);
651 m_InLogList.m_ColumnRegKey=_T("SyncIn");
652 m_InLogList.InsertGitColumn();
654 //----------- Create In Change file list -----------
655 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
657 if( !m_InChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CHANGELIST))
659 TRACE0("Failed to create output change files window\n");
660 return FALSE; // fail to create
662 m_ctrlTabCtrl.InsertTab(&m_InChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCHANGELIST)), -1);
664 m_InChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("InSyncDlg"),
665 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
666 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
669 //---------- Create Conflict List Ctrl -----------------
670 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
672 if( !m_ConflictFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CONFLICT))
674 TRACE0("Failed to create output change files window\n");
675 return FALSE; // fail to create
677 m_ctrlTabCtrl.InsertTab(&m_ConflictFileList,_T("Conflict"),-1);
679 m_ConflictFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("ConflictSyncDlg"),
680 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
681 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)|
682 GITSLC_POPCONFLICT|GITSLC_POPRESOLVE),false);
685 //---------- Create Commit Out List Ctrl---------------
687 dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;;
689 if( !m_OutLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_LOGLIST))
691 TRACE0("Failed to create output commits window\n");
692 return FALSE; // fail to create
696 m_ctrlTabCtrl.InsertTab(&m_OutLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCOMMITS)), -1);
698 m_OutLogList.m_ColumnRegKey = _T("SyncOut");
699 m_OutLogList.InsertGitColumn();
701 //------------- Create Change File List Control ----------------
703 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
705 if( !m_OutChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_CHANGELIST))
707 TRACE0("Failed to create output change files window\n");
708 return FALSE; // fail to create
710 m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCHANGELIST)), -1);
712 m_OutChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD | GITSLC_COLDEL, _T("OutSyncDlg"),
713 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
714 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
716 this->m_tooltips.Create(this);
718 AddAnchor(IDC_SYNC_TAB,TOP_LEFT,BOTTOM_RIGHT);
720 AddAnchor(IDC_GROUP_INFO,TOP_LEFT,TOP_RIGHT);
721 AddAnchor(IDC_COMBOBOXEX_URL,TOP_LEFT,TOP_RIGHT);
722 AddAnchor(IDC_BUTTON_MANAGE,TOP_RIGHT);
723 AddAnchor(IDC_BUTTON_PULL,BOTTOM_LEFT);
724 AddAnchor(IDC_BUTTON_PUSH,BOTTOM_LEFT);
725 AddAnchor(IDC_BUTTON_SUBMODULE,BOTTOM_LEFT);
726 AddAnchor(IDC_BUTTON_APPLY,BOTTOM_RIGHT);
727 AddAnchor(IDC_BUTTON_EMAIL,BOTTOM_RIGHT);
728 AddAnchor(IDC_PROGRESS_SYNC,TOP_LEFT,TOP_RIGHT);
729 AddAnchor(IDOK,BOTTOM_RIGHT);
730 AddAnchor(IDHELP,BOTTOM_RIGHT);
731 AddAnchor(IDC_STATIC_STATUS, BOTTOM_LEFT, BOTTOM_RIGHT);
732 AddAnchor(IDC_ANIMATE_SYNC,TOP_LEFT);
733 AddAnchor(IDC_BUTTON_COMMIT,BOTTOM_LEFT);
734 AddAnchor(IDC_LOG, BOTTOM_LEFT);
736 // do not use BRANCH_COMBOX_ADD_ANCHOR here, we want to have different stylings
737 AddAnchor(IDC_COMBOBOXEX_LOCAL_BRANCH, TOP_LEFT,TOP_CENTER);
738 AddAnchor(IDC_COMBOBOXEX_REMOTE_BRANCH, TOP_CENTER, TOP_RIGHT);
739 AddAnchor(IDC_BUTTON_LOCAL_BRANCH, TOP_CENTER);
740 AddAnchor(IDC_BUTTON_REMOTE_BRANCH, TOP_RIGHT);
741 AddAnchor(IDC_STATIC_REMOTE_BRANCH, TOP_CENTER);
743 AdjustControlSize(IDC_CHECK_PUTTY_KEY);
744 AdjustControlSize(IDC_CHECK_FORCE);
746 CString WorkingDir=g_Git.m_CurrentDir;
747 WorkingDir.Replace(_T(':'),_T('_'));
748 m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir;
751 this->AddOthersToAnchor();
753 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSH)));
754 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSHTAGS)));
755 ///this->m_ctrlPush.AddEntry(CString(_T("Push All")));
757 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PULL)));
758 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCH)));
759 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCHREBASE)));
760 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REMOTEUPDATE)));
761 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CLEANUPSTALEBRANCHES)));
763 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEUPDATE)));
764 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEINIT)));
765 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULESYNC)));
767 WorkingDir.Replace(_T(':'),_T('_'));
769 CString regkey ;
770 regkey.Format(_T("Software\\TortoiseGit\\TortoiseProc\\Sync\\%s"),WorkingDir);
772 this->m_regPullButton = CRegDWORD(regkey+_T("\\Pull"),0);
773 this->m_regPushButton = CRegDWORD(regkey+_T("\\Push"),0);
774 this->m_regSubmoduleButton = CRegDWORD(regkey+_T("\\Submodule"));
775 this->m_regAutoLoadPutty = CRegDWORD(regkey + _T("\\AutoLoadPutty"), CAppUtils::IsSSHPutty());
777 m_tooltips.Create(this);
778 this->UpdateData();
779 this->m_bAutoLoadPuttyKey = m_regAutoLoadPutty;
780 if(!CAppUtils::IsSSHPutty())
781 m_bAutoLoadPuttyKey = false;
782 this->UpdateData(FALSE);
784 this->m_ctrlPull.SetCurrentEntry(this->m_regPullButton);
785 this->m_ctrlPush.SetCurrentEntry(this->m_regPushButton);
786 this->m_ctrlSubmodule.SetCurrentEntry(this->m_regSubmoduleButton);
788 CString sWindowTitle;
789 GetWindowText(sWindowTitle);
790 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
792 EnableSaveRestore(_T("SyncDlg"));
794 this->m_ctrlURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\SyncURL\\"))+WorkingDir, _T("url"));
796 STRING_VECTOR list;
798 if(!g_Git.GetRemoteList(list))
800 for(unsigned int i=0;i<list.size();i++)
802 m_ctrlURL.AddString(list[i]);
805 m_ctrlURL.SetCurSel(0);
806 m_ctrlRemoteBranch.SetCurSel(0);
807 m_ctrlURL.SetURLHistory(true);
809 this->LoadBranchInfo();
811 this->m_bInited=true;
812 FetchOutList();
814 m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,false);
815 m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
816 m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
817 m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
819 m_ctrlRemoteBranch.m_bWantReturn = TRUE;
820 m_ctrlURL.m_bWantReturn = TRUE;
822 this->m_Gitverion = CAppUtils::GetMsysgitVersion();
824 return TRUE; // return TRUE unless you set the focus to a control
825 // EXCEPTION: OCX Property Pages should return FALSE
828 void CSyncDlg::OnBnClickedButtonManage()
830 CAppUtils::LaunchRemoteSetting();
831 Refresh();
834 void CSyncDlg::Refresh()
836 theApp.DoWaitCursor(1);
838 int lastSelected = m_ctrlURL.GetCurSel();
839 CString url;
840 this->m_ctrlURL.GetWindowText(url);
842 this->m_ctrlURL.Reset();
843 CString workingDir = g_Git.m_CurrentDir;
844 workingDir.Replace(_T(':'), _T('_'));
845 this->m_ctrlURL.LoadHistory(_T("Software\\TortoiseGit\\History\\SyncURL\\") + workingDir, _T("url"));
847 STRING_VECTOR list;
848 bool found = false;
849 if (!g_Git.GetRemoteList(list))
851 for (int i = 0; i < list.size(); i++)
853 m_ctrlURL.AddString(list[i]);
854 if (list[i] == url)
855 found = true;
858 if (lastSelected >= 0 && !found)
860 m_ctrlURL.SetCurSel(0);
861 m_ctrlURL.GetWindowText(url);
864 CString local;
865 CString remote;
866 this->m_ctrlLocalBranch.GetWindowText(local);
867 this->m_ctrlRemoteBranch.GetWindowText(remote);
869 this->LoadBranchInfo();
871 this->m_ctrlLocalBranch.AddString(local);
872 this->m_ctrlRemoteBranch.AddString(remote);
873 this->m_ctrlURL.AddString(url);
875 m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REFRESHING)));
876 this->FetchOutList(true);
877 theApp.DoWaitCursor(-1);
880 BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg)
882 if (pMsg->message == WM_KEYDOWN)
884 switch (pMsg->wParam)
887 case VK_F5:
889 if (m_bBlock)
890 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
891 Refresh();
893 break;
895 /* Avoid TAB control destroy but dialog exist*/
896 case VK_ESCAPE:
897 case VK_CANCEL:
899 TCHAR buff[128];
900 ::GetClassName(pMsg->hwnd,buff,128);
902 if(_tcsnicmp(buff,_T("RichEdit20W"),128)==0)
904 this->PostMessage(WM_KEYDOWN,VK_ESCAPE,0);
905 return TRUE;
910 m_tooltips.RelayEvent(pMsg);
911 return __super::PreTranslateMessage(pMsg);
913 void CSyncDlg::FetchOutList(bool force)
915 if(!m_bInited)
916 return;
917 m_OutChangeFileList.Clear();
918 this->m_OutLogList.Clear();
920 CString remote;
921 this->m_ctrlURL.GetWindowText(remote);
922 CString remotebranch;
923 this->m_ctrlRemoteBranch.GetWindowText(remotebranch);
924 remotebranch=remote+_T("/")+remotebranch;
926 if(IsURL())
928 CString str;
929 str.LoadString(IDS_PROC_SYNC_PUSH_UNKNOWN);
930 m_OutLogList.ShowText(str);
931 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
932 m_OutLocalBranch.Empty();
933 m_OutRemoteBranch.Empty();
935 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
936 return ;
939 else if(g_Git.GetHash(remotebranch).IsEmpty())
941 CString str;
942 str.Format(IDS_PROC_SYNC_PUSH_UNKNOWNBRANCH, remotebranch);
943 m_OutLogList.ShowText(str);
944 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
945 m_OutLocalBranch.Empty();
946 m_OutRemoteBranch.Empty();
948 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
949 return ;
951 else
953 CString localbranch;
954 localbranch=this->m_ctrlLocalBranch.GetString();
956 if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force)
958 m_OutLogList.ClearText();
960 CGitHash base, remotehash;
961 CString cmd, basestr, err;
962 cmd.Format(_T("git.exe merge-base %s %s"), g_Git.FixBranchName(remotebranch), g_Git.FixBranchName(localbranch));
963 g_Git.Run(cmd, &basestr, &err, CP_UTF8);
964 base = basestr;
966 remotehash = g_Git.GetHash(remotebranch);
967 if (remotehash == g_Git.GetHash(localbranch))
969 CString str;
970 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, 0, remotebranch);
971 m_OutLogList.ShowText(str);
972 this->m_ctrlStatus.SetWindowText(str);
973 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
974 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
976 else if (remotehash == base || m_bForce)
978 //fast forward
979 m_OutLogList.FillGitLog(NULL, CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, &remotebranch, &localbranch);
980 CString str;
981 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, m_OutLogList.GetItemCount(), remotebranch);
982 this->m_ctrlStatus.SetWindowText(str);
984 if (remotehash == base)
985 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, remotebranch);
986 else
988 CString baseString = base.ToString();
989 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, baseString);
992 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE);
993 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE);
995 else
997 CString str;
998 str.Format(IDS_PROC_SYNC_NOFASTFORWARD, localbranch, remotebranch);
999 m_OutLogList.ShowText(str);
1000 this->m_ctrlStatus.SetWindowText(str);
1001 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID() - 1, FALSE);
1002 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
1005 this->m_OutLocalBranch=localbranch;
1006 this->m_OutRemoteBranch=remotebranch;
1011 bool CSyncDlg::IsURL()
1013 CString str;
1014 this->m_ctrlURL.GetWindowText(str);
1015 if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)
1016 return true;
1017 else
1018 return false;
1020 void CSyncDlg::OnCbnEditchangeComboboxex()
1022 SetTimer(IDT_INPUT, 1000, NULL);
1023 this->m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_WAINTINPUT)));
1025 //this->FetchOutList();
1028 UINT CSyncDlg::ProgressThread()
1030 m_GitCmdStatus=CProgressDlg::RunCmdList(this,m_GitCmdList,true,NULL,&this->m_bAbort);
1031 InterlockedExchange(&m_bBlock, FALSE);
1032 return 0;
1036 LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
1038 if(wParam == MSG_PROGRESSDLG_START)
1040 m_ctrlAnimate.Play(0, UINT_MAX, UINT_MAX);
1041 this->m_ctrlProgress.SetPos(0);
1042 if (m_pTaskbarList)
1044 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
1045 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
1049 if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
1051 //m_bDone = true;
1052 m_ctrlAnimate.Stop();
1053 m_ctrlProgress.SetPos(100);
1054 //this->DialogEnableWindow(IDOK,TRUE);
1055 if (m_pTaskbarList)
1056 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
1058 //if(wParam == MSG_PROGRESSDLG_END)
1059 if(this->m_CurrentCmd == GIT_COMMAND_PUSH )
1061 if(!m_GitCmdStatus)
1063 CTGitPathList list;
1064 list.AddPath(CTGitPath(g_Git.m_CurrentDir));
1065 DWORD exitcode;
1066 CString error;
1067 if (CHooks::Instance().PostPush(list,exitcode, error))
1069 if (exitcode)
1071 CString temp;
1072 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
1073 //ReportError(temp);
1074 CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1075 return false;
1080 EnableControlButton(true);
1081 SwitchToInput();
1082 this->FetchOutList(true);
1084 if(this->m_CurrentCmd == GIT_COMMAND_PULL )
1086 PullComplete();
1088 if(this->m_CurrentCmd == GIT_COMMAND_FETCH || this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
1090 FetchComplete();
1092 if(this->m_CurrentCmd == GIT_COMMAND_SUBMODULE)
1094 //this->m_ctrlCmdOut.SetSel(-1,-1);
1095 //this->m_ctrlCmdOut.ReplaceSel(_T("Done\r\n"));
1096 //this->m_ctrlCmdOut.SetSel(-1,-1);
1097 EnableControlButton(true);
1098 SwitchToInput();
1100 if(this->m_CurrentCmd == GIT_COMMAND_REMOTE)
1102 this->FetchOutList(true);
1103 EnableControlButton(true);
1104 SwitchToInput();
1108 if(lParam != 0)
1109 ParserCmdOutput((char)lParam);
1111 return 0;
1115 void CSyncDlg::ParserCmdOutput(char ch)
1117 CProgressDlg::ParserCmdOutput(m_ctrlCmdOut,m_ctrlProgress,m_hWnd,m_pTaskbarList,m_LogText,ch);
1119 void CSyncDlg::OnBnClickedButtonCommit()
1121 CString cmd = _T("/command:commit");
1122 cmd += _T(" /path:\"");
1123 cmd += g_Git.m_CurrentDir;
1124 cmd += _T("\"");
1126 CAppUtils::RunTortoiseProc(cmd);
1129 void CSyncDlg::OnOK()
1131 UpdateCombox();
1132 this->UpdateData();
1133 m_ctrlURL.SaveHistory();
1134 SaveHistory();
1135 m_regAutoLoadPutty = this->m_bAutoLoadPuttyKey;
1136 __super::OnOK();
1139 void CSyncDlg::OnBnClickedButtonSubmodule()
1141 this->UpdateData();
1142 UpdateCombox();
1144 this->m_regSubmoduleButton = (DWORD)this->m_ctrlSubmodule.GetCurrentEntry();
1146 this->SwitchToRun();
1148 this->m_bAbort=false;
1149 this->m_GitCmdList.clear();
1151 ShowTab(IDC_CMD_LOG);
1153 CString cmd;
1155 switch (m_ctrlSubmodule.GetCurrentEntry())
1157 case 0:
1158 cmd=_T("git.exe submodule update --init");
1159 break;
1160 case 1:
1161 cmd=_T("git.exe submodule init");
1162 break;
1163 case 2:
1164 cmd=_T("git.exe submodule sync");
1165 break;
1168 m_GitCmdList.push_back(cmd);
1170 m_CurrentCmd = GIT_COMMAND_SUBMODULE;
1172 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
1173 if (m_pThread==NULL)
1175 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
1177 else
1179 m_pThread->m_bAutoDelete = TRUE;
1180 m_pThread->ResumeThread();
1184 void CSyncDlg::OnTimer(UINT_PTR nIDEvent)
1186 if( nIDEvent == IDT_INPUT)
1188 KillTimer(IDT_INPUT);
1189 this->FetchOutList(true);
1194 void CSyncDlg::OnLvnInLogListColumnClick(NMHDR * /* pNMHDR */, LRESULT *pResult)
1196 *pResult = 0;
1199 LRESULT CSyncDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
1201 m_pTaskbarList.Release();
1202 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
1203 return 0;
1206 void CSyncDlg::OnBnClickedCheckForce()
1208 UpdateData();
1211 void CSyncDlg::OnBnClickedLog()
1213 CString cmd = _T("/command:log");
1214 cmd += _T(" /path:\"");
1215 cmd += g_Git.m_CurrentDir;
1216 cmd += _T("\"");
1218 CAppUtils::RunTortoiseProc(cmd);