Fixed issue #626: add "show log" in Git Sync dialog
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.cpp
blob0ca62619a0a6b38122e65a283b97e0281777184b
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 = 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 this->GetDlgItem(IDC_BUTTON_COMMIT)->ShowWindow(SW_HIDE);
151 ///Pull
152 if(CurrentEntry == 0) //Pull
154 CString remotebranch;
155 remotebranch = m_strRemoteBranch;
157 if(!IsURL())
159 CString configName;
160 configName.Format(L"branch.%s.merge", this->m_strLocalBranch);
161 CString pullBranch = CGit::StripRefName(g_Git.GetConfigValue(configName));
163 configName.Format(L"branch.%s.remote", m_strLocalBranch);
164 CString pullRemote = g_Git.GetConfigValue(configName);
166 if(pullBranch == remotebranch && pullRemote == this->m_strURL)
167 remotebranch.Empty();
170 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
171 force += _T("--progress ");
173 cmd.Format(_T("git.exe pull -v %s \"%s\" %s"),
174 force,
175 m_strURL,
176 remotebranch);
178 m_CurrentCmd = GIT_COMMAND_PULL;
179 m_GitCmdList.push_back(cmd);
181 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
182 if (m_pThread==NULL)
184 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
186 else
188 m_pThread->m_bAutoDelete = TRUE;
189 m_pThread->ResumeThread();
194 ///Fetch
195 if(CurrentEntry == 1 || CurrentEntry ==2 ) //Fetch
197 CString remotebranch;
198 if(this->IsURL() || m_strRemoteBranch.IsEmpty())
200 remotebranch=this->m_strRemoteBranch;
203 else
205 remotebranch.Format(_T("remotes/%s/%s"),
206 m_strURL,m_strRemoteBranch);
207 if(g_Git.GetHash(remotebranch).IsEmpty())
208 remotebranch=m_strRemoteBranch;
209 else
210 remotebranch=m_strRemoteBranch+_T(":")+remotebranch;
213 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
214 force += _T("--progress ");
216 cmd.Format(_T("git.exe fetch -v %s \"%s\" %s"),
217 force,
218 m_strURL,
219 remotebranch);
221 if(CurrentEntry == 1)
222 m_CurrentCmd = GIT_COMMAND_FETCH;
223 else
224 m_CurrentCmd = GIT_COMMAND_FETCHANDREBASE;
225 m_GitCmdList.push_back(cmd);
227 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
228 if (m_pThread==NULL)
230 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
232 else
234 m_pThread->m_bAutoDelete = TRUE;
235 m_pThread->ResumeThread();
239 ///Remote Update
240 if(CurrentEntry == 3)
242 m_CurrentCmd = GIT_COMMAND_REMOTE;
243 cmd=_T("git.exe remote update");
244 m_GitCmdList.push_back(cmd);
246 InterlockedExchange(&m_bBlock, TRUE);
248 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
249 if (m_pThread==NULL)
251 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
252 InterlockedExchange(&m_bBlock, FALSE);
254 else
256 m_pThread->m_bAutoDelete = TRUE;
257 m_pThread->ResumeThread();
261 ///Cleanup stale remote banches
262 if(CurrentEntry == 4)
264 m_CurrentCmd = GIT_COMMAND_REMOTE;
265 cmd.Format(_T("git.exe remote prune \"%s\""), m_strURL);
266 m_GitCmdList.push_back(cmd);
268 InterlockedExchange(&m_bBlock, TRUE);
270 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
271 if (m_pThread==NULL)
273 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
274 InterlockedExchange(&m_bBlock, FALSE);
276 else
278 m_pThread->m_bAutoDelete = TRUE;
279 m_pThread->ResumeThread();
284 void CSyncDlg::PullComplete()
286 EnableControlButton(true);
287 SwitchToInput();
288 this->FetchOutList(true);
290 CString newhash;
291 newhash = g_Git.GetHash(_T("HEAD"));
293 if( this ->m_GitCmdStatus )
295 CTGitPathList list;
296 if(g_Git.ListConflictFile(list))
298 this->m_ctrlCmdOut.SetSel(-1,-1);
299 this->m_ctrlCmdOut.ReplaceSel(_T("Get conflict files fail\n"));
301 this->ShowTab(IDC_CMD_LOG);
302 return;
305 if(list.GetCount()>0)
307 this->m_ConflictFileList.Clear();
308 CTGitPathList list;
309 CTGitPath path;
310 list.AddPath(path);
312 this->m_ConflictFileList.GetStatus(&list,true);
313 this->m_ConflictFileList.Show(CTGitPath::LOGACTIONS_UNMERGED,
314 CTGitPath::LOGACTIONS_UNMERGED);
316 this->ShowTab(IDC_IN_CONFLICT);
318 this->GetDlgItem(IDC_BUTTON_COMMIT)->ShowWindow(SW_NORMAL);
320 else
321 this->ShowTab(IDC_CMD_LOG);
324 else
326 if(newhash == this->m_oldHash)
328 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
329 this->m_InLogList.ShowText(CString(MAKEINTRESOURCE(IDS_UPTODATE)));
330 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
332 else
334 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true);
335 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
337 CString oldhash=m_oldHash.ToString();
338 this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash);
340 m_InLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
341 &oldhash,&newhash);
343 this->ShowTab(IDC_IN_LOGLIST);
347 void CSyncDlg::FetchComplete()
349 EnableControlButton(true);
350 SwitchToInput();
351 this->FetchOutList(true);
353 ShowTab(IDC_CMD_LOG);
354 if( (!this->m_GitCmdStatus) && this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
356 CRebaseDlg dlg;
357 dlg.m_PostButtonTexts.Add(_T("Email &Patch..."));
358 int response = dlg.DoModal();
359 if(response == IDOK)
361 return ;
364 if(response == IDC_REBASE_POST_BUTTON)
366 CString cmd, out, err;
367 cmd.Format(_T("git.exe format-patch -o \"%s\" %s..%s"),
368 g_Git.m_CurrentDir,
369 g_Git.FixBranchName(dlg.m_Upstream),
370 g_Git.FixBranchName(dlg.m_Branch));
371 if (g_Git.Run(cmd, &out, &err, CP_UTF8))
373 CMessageBox::Show(NULL, out + L"\n" + err, _T("TortoiseGit"), MB_OK|MB_ICONERROR);
374 return ;
377 CAppUtils::SendPatchMail(cmd,out);
382 void CSyncDlg::OnBnClickedButtonPush()
384 this->UpdateData();
385 UpdateCombox();
387 if(this->m_strURL.IsEmpty())
389 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
390 return;
393 this->m_regPushButton=this->m_ctrlPush.GetCurrentEntry();
394 this->SwitchToRun();
395 this->m_bAbort=false;
396 this->m_GitCmdList.clear();
398 ShowTab(IDC_CMD_LOG);
400 CString cmd;
401 CString arg;
403 CString error;
404 DWORD exitcode;
405 CTGitPathList list;
406 list.AddPath(CTGitPath(g_Git.m_CurrentDir));
408 if (CHooks::Instance().PrePush(list,exitcode, error))
410 if (exitcode)
412 CString temp;
413 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
414 //ReportError(temp);
415 CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
416 return ;
420 switch (m_ctrlPush.GetCurrentEntry())
422 case 1:
423 arg += _T(" --tags ");
424 break;
425 case 2:
426 arg += _T(" --all ");
427 break;
430 if(this->m_bForce)
431 arg += _T(" --force ");
433 if(m_Gitverion >= 0x01070203) //above 1.7.0.2
434 arg += _T("--progress ");
436 cmd.Format(_T("git.exe push -v %s \"%s\" %s"),
437 arg,
438 m_strURL,
439 g_Git.FixBranchName(m_strLocalBranch));
441 if (!m_strRemoteBranch.IsEmpty())
443 cmd += _T(":") + m_strRemoteBranch;
446 m_GitCmdList.push_back(cmd);
448 m_CurrentCmd = GIT_COMMAND_PUSH;
450 if(this->m_bAutoLoadPuttyKey)
452 CAppUtils::LaunchPAgent(NULL,&this->m_strURL);
455 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
456 if (m_pThread==NULL)
458 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
460 else
462 m_pThread->m_bAutoDelete = TRUE;
463 m_pThread->ResumeThread();
467 void CSyncDlg::OnBnClickedButtonApply()
469 CString oldhash;
470 oldhash=g_Git.GetHash(_T("HEAD"));
472 CImportPatchDlg dlg;
473 CString cmd,output;
475 if(dlg.DoModal() == IDOK)
477 int err=0;
478 for(int i=0;i<dlg.m_PathList.GetCount();i++)
480 cmd.Format(_T("git.exe am \"%s\""),dlg.m_PathList[i].GetGitPathString());
482 if (g_Git.Run(cmd, &output, CP_UTF8))
484 CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK);
486 err=1;
487 break;
489 this->m_ctrlCmdOut.SetSel(-1,-1);
490 this->m_ctrlCmdOut.ReplaceSel(cmd+_T("\n"));
491 this->m_ctrlCmdOut.SetSel(-1,-1);
492 this->m_ctrlCmdOut.ReplaceSel(output);
495 CString newhash=g_Git.GetHash(_T("HEAD"));
497 this->m_InLogList.Clear();
498 this->m_InChangeFileList.Clear();
500 if(newhash == oldhash)
502 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
503 this->m_InLogList.ShowText(_T("No commits get from patch"));
504 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
507 else
509 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true);
510 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
512 this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash);
513 m_InLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
514 &oldhash,&newhash);
516 this->FetchOutList(true);
519 this->m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,true);
521 if(err)
523 this->ShowTab(IDC_CMD_LOG);
525 else
527 this->ShowTab(IDC_IN_LOGLIST);
532 void CSyncDlg::OnBnClickedButtonEmail()
534 CString cmd, out, err;
536 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();
537 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);
538 this->m_ctrlURL.GetWindowText(this->m_strURL);
539 m_strURL=m_strURL.Trim();
540 m_strRemoteBranch=m_strRemoteBranch.Trim();
542 cmd.Format(_T("git.exe format-patch -o \"%s\" %s..%s"),
543 g_Git.m_CurrentDir,
544 m_strURL+_T('/')+m_strRemoteBranch,g_Git.FixBranchName(m_strLocalBranch));
546 if (g_Git.Run(cmd, &out, &err, CP_UTF8))
548 CMessageBox::Show(NULL, out + L"\n" + err, _T("TortoiseGit"), MB_OK|MB_ICONERROR);
549 return ;
552 CAppUtils::SendPatchMail(cmd,out);
555 void CSyncDlg::ShowProgressCtrl(bool bShow)
557 int b=bShow?SW_NORMAL:SW_HIDE;
558 this->m_ctrlAnimate.ShowWindow(b);
559 this->m_ctrlProgress.ShowWindow(b);
560 this->m_ctrlAnimate.Open(IDR_DOWNLOAD);
561 if(b == SW_NORMAL)
562 this->m_ctrlAnimate.Play(0,-1,-1);
563 else
564 this->m_ctrlAnimate.Stop();
566 void CSyncDlg::ShowInputCtrl(bool bShow)
568 int b=bShow?SW_NORMAL:SW_HIDE;
569 this->m_ctrlURL.ShowWindow(b);
570 this->m_ctrlLocalBranch.ShowWindow(b);
571 this->m_ctrlRemoteBranch.ShowWindow(b);
572 this->GetDlgItem(IDC_BUTTON_LOCAL_BRANCH)->ShowWindow(b);
573 this->GetDlgItem(IDC_BUTTON_REMOTE_BRANCH)->ShowWindow(b);
574 this->GetDlgItem(IDC_STATIC_LOCAL_BRANCH)->ShowWindow(b);
575 this->GetDlgItem(IDC_STATIC_REMOTE_BRANCH)->ShowWindow(b);
576 this->GetDlgItem(IDC_BUTTON_MANAGE)->ShowWindow(b);
577 this->GetDlgItem(IDC_CHECK_PUTTY_KEY)->ShowWindow(b);
578 this->GetDlgItem(IDC_CHECK_FORCE)->ShowWindow(b);
579 this->GetDlgItem(IDC_STATIC_REMOTE_URL)->ShowWindow(b);
581 BOOL CSyncDlg::OnInitDialog()
583 CResizableStandAloneDialog::OnInitDialog();
584 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
586 // Let the TaskbarButtonCreated message through the UIPI filter. If we don't
587 // do this, Explorer would be unable to send that message to our window if we
588 // were running elevated. It's OK to make the call all the time, since if we're
589 // not elevated, this is a no-op.
590 CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
591 typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
592 CAutoLibrary hUser = ::LoadLibrary(_T("user32.dll"));
593 if (hUser)
595 ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
596 if (pfnChangeWindowMessageFilterEx)
598 pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
601 m_pTaskbarList.Release();
602 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
604 this->GetDlgItem(IDC_CHECK_PUTTY_KEY)->EnableWindow(CAppUtils::IsSSHPutty());
607 this->m_ctrlAnimate.ShowWindow(SW_NORMAL);
608 this->m_ctrlAnimate.Open(IDR_DOWNLOAD);
609 this->m_ctrlAnimate.Play(0,-1,-1);
612 // ------------------ Create Tabctrl -----------
613 CWnd *pwnd=this->GetDlgItem(IDC_BUTTON_TABCTRL);
614 CRect rectDummy;
615 pwnd->GetWindowRect(&rectDummy);
616 this->ScreenToClient(rectDummy);
618 if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_SYNC_TAB))
620 TRACE0("Failed to create output tab window\n");
621 return FALSE; // fail to create
623 m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);
625 // -------------Create Command Log Ctrl ---------
626 DWORD dwStyle;
627 dwStyle= ES_MULTILINE | ES_READONLY | WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL |WS_VSCROLL ;
629 if( !m_ctrlCmdOut.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_CMD_LOG))
631 TRACE0("Failed to create Log commits window\n");
632 return FALSE; // fail to create
635 // set the font to use in the log message view, configured in the settings dialog
636 CFont m_logFont;
637 CAppUtils::CreateFontForLogs(m_logFont);
638 //GetDlgItem(IDC_CMD_LOG)->SetFont(&m_logFont);
639 m_ctrlCmdOut.SetFont(&m_logFont);
640 m_ctrlTabCtrl.InsertTab(&m_ctrlCmdOut, CString(MAKEINTRESOURCE(IDS_LOG)), -1);
642 //m_ctrlCmdOut.ReplaceSel(_T("Hello"));
644 //---------- Create in coming list ctrl -----------
645 dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;;
647 if( !m_InLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_LOGLIST))
649 TRACE0("Failed to create output commits window\n");
650 return FALSE; // fail to create
653 m_ctrlTabCtrl.InsertTab(&m_InLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCOMMITS)), -1);
655 m_InLogList.m_ColumnRegKey=_T("SyncIn");
656 m_InLogList.InsertGitColumn();
658 //----------- Create In Change file list -----------
659 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
661 if( !m_InChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CHANGELIST))
663 TRACE0("Failed to create output change files window\n");
664 return FALSE; // fail to create
666 m_ctrlTabCtrl.InsertTab(&m_InChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_INCHANGELIST)), -1);
668 m_InChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("InSyncDlg"),
669 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
670 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
673 //---------- Create Conflict List Ctrl -----------------
674 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
676 if( !m_ConflictFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_IN_CONFLICT))
678 TRACE0("Failed to create output change files window\n");
679 return FALSE; // fail to create
681 m_ctrlTabCtrl.InsertTab(&m_ConflictFileList,_T("Conflict"),-1);
683 m_ConflictFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS |GITSLC_COLADD|GITSLC_COLDEL , _T("ConflictSyncDlg"),
684 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
685 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)|
686 GITSLC_POPCONFLICT|GITSLC_POPRESOLVE),false);
689 //---------- Create Commit Out List Ctrl---------------
691 dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE;;
693 if( !m_OutLogList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_LOGLIST))
695 TRACE0("Failed to create output commits window\n");
696 return FALSE; // fail to create
700 m_ctrlTabCtrl.InsertTab(&m_OutLogList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCOMMITS)), -1);
702 m_OutLogList.m_ColumnRegKey = _T("SyncOut");
703 m_OutLogList.InsertGitColumn();
705 //------------- Create Change File List Control ----------------
707 dwStyle = LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;
709 if( !m_OutChangeFileList.Create(dwStyle,rectDummy,&m_ctrlTabCtrl,IDC_OUT_CHANGELIST))
711 TRACE0("Failed to create output change files window\n");
712 return FALSE; // fail to create
714 m_ctrlTabCtrl.InsertTab(&m_OutChangeFileList, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_OUTCHANGELIST)), -1);
716 m_OutChangeFileList.Init(GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD | GITSLC_COLDEL, _T("OutSyncDlg"),
717 (CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_COMPARETWO)|
718 CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDGITLC_GNUDIFF2)), false, true, GITSLC_COLEXT | GITSLC_COLSTATUS | GITSLC_COLADD| GITSLC_COLDEL);
720 this->m_tooltips.Create(this);
722 AddAnchor(IDC_SYNC_TAB,TOP_LEFT,BOTTOM_RIGHT);
724 AddAnchor(IDC_GROUP_INFO,TOP_LEFT,TOP_RIGHT);
725 AddAnchor(IDC_COMBOBOXEX_URL,TOP_LEFT,TOP_RIGHT);
726 AddAnchor(IDC_BUTTON_MANAGE,TOP_RIGHT);
727 AddAnchor(IDC_BUTTON_PULL,BOTTOM_LEFT);
728 AddAnchor(IDC_BUTTON_PUSH,BOTTOM_LEFT);
729 AddAnchor(IDC_BUTTON_SUBMODULE,BOTTOM_LEFT);
730 AddAnchor(IDC_BUTTON_APPLY,BOTTOM_RIGHT);
731 AddAnchor(IDC_BUTTON_EMAIL,BOTTOM_RIGHT);
732 AddAnchor(IDC_PROGRESS_SYNC,TOP_LEFT,TOP_RIGHT);
733 AddAnchor(IDOK,BOTTOM_RIGHT);
734 AddAnchor(IDHELP,BOTTOM_RIGHT);
735 AddAnchor(IDC_STATIC_STATUS, BOTTOM_LEFT, BOTTOM_RIGHT);
736 AddAnchor(IDC_ANIMATE_SYNC,TOP_LEFT);
737 AddAnchor(IDC_BUTTON_COMMIT,BOTTOM_LEFT);
738 AddAnchor(IDC_BUTTON_LOG, BOTTOM_LEFT);
740 // do not use BRANCH_COMBOX_ADD_ANCHOR here, we want to have different stylings
741 AddAnchor(IDC_COMBOBOXEX_LOCAL_BRANCH, TOP_LEFT,TOP_CENTER);
742 AddAnchor(IDC_COMBOBOXEX_REMOTE_BRANCH, TOP_CENTER, TOP_RIGHT);
743 AddAnchor(IDC_BUTTON_LOCAL_BRANCH, TOP_CENTER);
744 AddAnchor(IDC_BUTTON_REMOTE_BRANCH, TOP_RIGHT);
745 AddAnchor(IDC_STATIC_REMOTE_BRANCH, TOP_CENTER);
747 this->GetDlgItem(IDC_BUTTON_COMMIT)->ShowWindow(SW_HIDE);
749 AdjustControlSize(IDC_CHECK_PUTTY_KEY);
750 AdjustControlSize(IDC_CHECK_FORCE);
752 CString WorkingDir=g_Git.m_CurrentDir;
753 WorkingDir.Replace(_T(':'),_T('_'));
754 m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir;
757 this->AddOthersToAnchor();
759 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSH)));
760 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSHTAGS)));
761 ///this->m_ctrlPush.AddEntry(CString(_T("Push All")));
763 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PULL)));
764 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCH)));
765 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCHREBASE)));
766 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REMOTEUPDATE)));
767 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CLEANUPSTALEBRANCHES)));
769 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEUPDATE)));
770 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEINIT)));
771 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULESYNC)));
773 WorkingDir.Replace(_T(':'),_T('_'));
775 CString regkey ;
776 regkey.Format(_T("Software\\TortoiseGit\\TortoiseProc\\Sync\\%s"),WorkingDir);
778 this->m_regPullButton = CRegDWORD(regkey+_T("\\Pull"),0);
779 this->m_regPushButton = CRegDWORD(regkey+_T("\\Push"),0);
780 this->m_regSubmoduleButton = CRegDWORD(regkey+_T("\\Submodule"));
781 this->m_regAutoLoadPutty = CRegDWORD(regkey + _T("\\AutoLoadPutty"), CAppUtils::IsSSHPutty());
783 m_tooltips.Create(this);
784 this->UpdateData();
785 this->m_bAutoLoadPuttyKey = m_regAutoLoadPutty;
786 if(!CAppUtils::IsSSHPutty())
787 m_bAutoLoadPuttyKey = false;
788 this->UpdateData(FALSE);
790 this->m_ctrlPull.SetCurrentEntry(this->m_regPullButton);
791 this->m_ctrlPush.SetCurrentEntry(this->m_regPushButton);
792 this->m_ctrlSubmodule.SetCurrentEntry(this->m_regSubmoduleButton);
794 CString sWindowTitle;
795 GetWindowText(sWindowTitle);
796 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
798 EnableSaveRestore(_T("SyncDlg"));
800 this->m_ctrlURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\SyncURL\\"))+WorkingDir, _T("url"));
802 STRING_VECTOR list;
804 if(!g_Git.GetRemoteList(list))
806 for(unsigned int i=0;i<list.size();i++)
808 m_ctrlURL.AddString(list[i]);
811 m_ctrlURL.SetCurSel(0);
812 m_ctrlRemoteBranch.SetCurSel(0);
813 m_ctrlURL.SetURLHistory(true);
815 this->LoadBranchInfo();
817 this->m_bInited=true;
818 FetchOutList();
820 m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,false);
821 m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
822 m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
823 m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
825 m_ctrlRemoteBranch.m_bWantReturn = TRUE;
826 m_ctrlURL.m_bWantReturn = TRUE;
828 this->m_Gitverion = CAppUtils::GetMsysgitVersion();
830 return TRUE; // return TRUE unless you set the focus to a control
831 // EXCEPTION: OCX Property Pages should return FALSE
834 void CSyncDlg::OnBnClickedButtonManage()
836 CAppUtils::LaunchRemoteSetting();
837 Refresh();
840 void CSyncDlg::Refresh()
842 theApp.DoWaitCursor(1);
844 int lastSelected = m_ctrlURL.GetCurSel();
845 CString url;
846 this->m_ctrlURL.GetWindowText(url);
848 this->m_ctrlURL.Reset();
849 CString workingDir = g_Git.m_CurrentDir;
850 workingDir.Replace(_T(':'), _T('_'));
851 this->m_ctrlURL.LoadHistory(_T("Software\\TortoiseGit\\History\\SyncURL\\") + workingDir, _T("url"));
853 STRING_VECTOR list;
854 bool found = false;
855 if (!g_Git.GetRemoteList(list))
857 for (int i = 0; i < list.size(); i++)
859 m_ctrlURL.AddString(list[i]);
860 if (list[i] == url)
861 found = true;
864 if (lastSelected >= 0 && !found)
866 m_ctrlURL.SetCurSel(0);
867 m_ctrlURL.GetWindowText(url);
870 CString local;
871 CString remote;
872 this->m_ctrlLocalBranch.GetWindowText(local);
873 this->m_ctrlRemoteBranch.GetWindowText(remote);
875 this->LoadBranchInfo();
877 this->m_ctrlLocalBranch.AddString(local);
878 this->m_ctrlRemoteBranch.AddString(remote);
879 this->m_ctrlURL.AddString(url);
881 m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REFRESHING)));
882 this->FetchOutList(true);
883 theApp.DoWaitCursor(-1);
886 BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg)
888 if (pMsg->message == WM_KEYDOWN)
890 switch (pMsg->wParam)
893 case VK_F5:
895 if (m_bBlock)
896 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
897 Refresh();
899 break;
901 /* Avoid TAB control destroy but dialog exist*/
902 case VK_ESCAPE:
903 case VK_CANCEL:
905 TCHAR buff[128];
906 ::GetClassName(pMsg->hwnd,buff,128);
908 if(_tcsnicmp(buff,_T("RichEdit20W"),128)==0)
910 this->PostMessage(WM_KEYDOWN,VK_ESCAPE,0);
911 return TRUE;
916 m_tooltips.RelayEvent(pMsg);
917 return __super::PreTranslateMessage(pMsg);
919 void CSyncDlg::FetchOutList(bool force)
921 if(!m_bInited)
922 return;
923 m_OutChangeFileList.Clear();
924 this->m_OutLogList.Clear();
926 CString remote;
927 this->m_ctrlURL.GetWindowText(remote);
928 CString remotebranch;
929 this->m_ctrlRemoteBranch.GetWindowText(remotebranch);
930 remotebranch=remote+_T("/")+remotebranch;
932 if(IsURL())
934 CString str;
935 str.LoadString(IDS_PROC_SYNC_PUSH_UNKNOWN);
936 m_OutLogList.ShowText(str);
937 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
938 m_OutLocalBranch.Empty();
939 m_OutRemoteBranch.Empty();
941 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
942 return ;
945 else if(g_Git.GetHash(remotebranch).IsEmpty())
947 CString str;
948 str.Format(IDS_PROC_SYNC_PUSH_UNKNOWNBRANCH, remotebranch);
949 m_OutLogList.ShowText(str);
950 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
951 m_OutLocalBranch.Empty();
952 m_OutRemoteBranch.Empty();
954 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
955 return ;
957 else
959 CString localbranch;
960 localbranch=this->m_ctrlLocalBranch.GetString();
962 if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force)
964 m_OutLogList.ClearText();
966 CGitHash base, remotehash;
967 CString cmd, basestr, err;
968 cmd.Format(_T("git.exe merge-base %s %s"), g_Git.FixBranchName(remotebranch), g_Git.FixBranchName(localbranch));
969 g_Git.Run(cmd, &basestr, &err, CP_UTF8);
970 base = basestr;
972 remotehash = g_Git.GetHash(remotebranch);
973 if (remotehash == g_Git.GetHash(localbranch))
975 CString str;
976 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, 0, remotebranch);
977 m_OutLogList.ShowText(str);
978 this->m_ctrlStatus.SetWindowText(str);
979 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
980 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
982 else if (remotehash == base || m_bForce)
984 //fast forward
985 m_OutLogList.FillGitLog(NULL, CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, &remotebranch, &localbranch);
986 CString str;
987 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, m_OutLogList.GetItemCount(), remotebranch);
988 this->m_ctrlStatus.SetWindowText(str);
990 if (remotehash == base)
991 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, remotebranch);
992 else
993 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, base.ToString());
995 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE);
996 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE);
998 else
1000 CString str;
1001 str.Format(IDS_PROC_SYNC_NOFASTFORWARD, localbranch, remotebranch);
1002 m_OutLogList.ShowText(str);
1003 this->m_ctrlStatus.SetWindowText(str);
1004 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID() - 1, FALSE);
1005 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
1008 this->m_OutLocalBranch=localbranch;
1009 this->m_OutRemoteBranch=remotebranch;
1014 bool CSyncDlg::IsURL()
1016 CString str;
1017 this->m_ctrlURL.GetWindowText(str);
1018 if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)
1019 return true;
1020 else
1021 return false;
1023 void CSyncDlg::OnCbnEditchangeComboboxex()
1025 SetTimer(IDT_INPUT, 1000, NULL);
1026 this->m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_WAINTINPUT)));
1028 //this->FetchOutList();
1031 UINT CSyncDlg::ProgressThread()
1033 m_GitCmdStatus=CProgressDlg::RunCmdList(this,m_GitCmdList,true,NULL,&this->m_bAbort);
1034 InterlockedExchange(&m_bBlock, FALSE);
1035 return 0;
1039 LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
1041 if(wParam == MSG_PROGRESSDLG_START)
1043 m_ctrlAnimate.Play(0,-1,-1);
1044 this->m_ctrlProgress.SetPos(0);
1045 if (m_pTaskbarList)
1047 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
1048 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
1052 if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
1054 //m_bDone = true;
1055 m_ctrlAnimate.Stop();
1056 m_ctrlProgress.SetPos(100);
1057 //this->DialogEnableWindow(IDOK,TRUE);
1058 if (m_pTaskbarList)
1059 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
1061 //if(wParam == MSG_PROGRESSDLG_END)
1062 if(this->m_CurrentCmd == GIT_COMMAND_PUSH )
1064 if(!m_GitCmdStatus)
1066 CTGitPathList list;
1067 list.AddPath(CTGitPath(g_Git.m_CurrentDir));
1068 DWORD exitcode;
1069 CString error;
1070 if (CHooks::Instance().PostPush(list,exitcode, error))
1072 if (exitcode)
1074 CString temp;
1075 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
1076 //ReportError(temp);
1077 CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1078 return false;
1083 EnableControlButton(true);
1084 SwitchToInput();
1085 this->FetchOutList(true);
1087 if(this->m_CurrentCmd == GIT_COMMAND_PULL )
1089 PullComplete();
1091 if(this->m_CurrentCmd == GIT_COMMAND_FETCH || this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
1093 FetchComplete();
1095 if(this->m_CurrentCmd == GIT_COMMAND_SUBMODULE)
1097 //this->m_ctrlCmdOut.SetSel(-1,-1);
1098 //this->m_ctrlCmdOut.ReplaceSel(_T("Done\r\n"));
1099 //this->m_ctrlCmdOut.SetSel(-1,-1);
1100 EnableControlButton(true);
1101 SwitchToInput();
1103 if(this->m_CurrentCmd == GIT_COMMAND_REMOTE)
1105 this->FetchOutList(true);
1106 EnableControlButton(true);
1107 SwitchToInput();
1111 if(lParam != 0)
1112 ParserCmdOutput((char)lParam);
1114 return 0;
1118 void CSyncDlg::ParserCmdOutput(char ch)
1120 CProgressDlg::ParserCmdOutput(m_ctrlCmdOut,m_ctrlProgress,m_hWnd,m_pTaskbarList,m_LogText,ch);
1122 void CSyncDlg::OnBnClickedButtonCommit()
1124 CString cmd = _T("/command:commit");
1125 cmd += _T(" /path:\"");
1126 cmd += g_Git.m_CurrentDir;
1127 cmd += _T("\"");
1129 CAppUtils::RunTortoiseProc(cmd);
1132 void CSyncDlg::OnOK()
1134 UpdateCombox();
1135 this->UpdateData();
1136 m_ctrlURL.SaveHistory();
1137 SaveHistory();
1138 m_regAutoLoadPutty = this->m_bAutoLoadPuttyKey;
1139 __super::OnOK();
1142 void CSyncDlg::OnBnClickedButtonSubmodule()
1144 this->UpdateData();
1145 UpdateCombox();
1147 this->m_regSubmoduleButton = this->m_ctrlSubmodule.GetCurrentEntry();
1149 this->SwitchToRun();
1151 this->m_bAbort=false;
1152 this->m_GitCmdList.clear();
1154 ShowTab(IDC_CMD_LOG);
1156 CString cmd;
1158 switch (m_ctrlSubmodule.GetCurrentEntry())
1160 case 0:
1161 cmd=_T("git.exe submodule update --init");
1162 break;
1163 case 1:
1164 cmd=_T("git.exe submodule init");
1165 break;
1166 case 2:
1167 cmd=_T("git.exe submodule sync");
1168 break;
1171 m_GitCmdList.push_back(cmd);
1173 m_CurrentCmd = GIT_COMMAND_SUBMODULE;
1175 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
1176 if (m_pThread==NULL)
1178 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
1180 else
1182 m_pThread->m_bAutoDelete = TRUE;
1183 m_pThread->ResumeThread();
1187 void CSyncDlg::OnTimer(UINT_PTR nIDEvent)
1189 if( nIDEvent == IDT_INPUT)
1191 KillTimer(IDT_INPUT);
1192 this->FetchOutList(true);
1197 void CSyncDlg::OnLvnInLogListColumnClick(NMHDR *pNMHDR, LRESULT *pResult)
1199 *pResult = 0;
1202 LRESULT CSyncDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
1204 m_pTaskbarList.Release();
1205 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
1206 return 0;
1209 void CSyncDlg::OnBnClickedCheckForce()
1211 UpdateData();
1214 void CSyncDlg::OnBnClickedLog()
1216 CString cmd = _T("/command:log");
1217 cmd += _T(" /path:\"");
1218 cmd += g_Git.m_CurrentDir;
1219 cmd += _T("\"");
1221 CAppUtils::RunTortoiseProc(cmd);