Fixed issue #1397: Sync Dialog Conflict tab name not translated
[TortoiseGit.git] / src / TortoiseProc / SyncDlg.cpp
blob3e9f3c1ef4e1246c7c29ff6ff7a48fe01c029221
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();
109 m_ctrlCmdOut.SetWindowTextW(_T(""));
110 m_LogText = "";
112 this->UpdateData();
113 UpdateCombox();
115 m_oldHash = g_Git.GetHash(_T("HEAD"));
117 if( CurrentEntry == 0)
119 if( g_Git.GetHash(this->m_strLocalBranch) != m_oldHash)
121 CMessageBox::Show(NULL, IDS_PROC_SYNC_PULLWRONGBRANCH, IDS_APPNAME, MB_OK | MB_ICONERROR);
122 return;
126 if(this->m_strURL.IsEmpty())
128 CMessageBox::Show(NULL, IDS_PROC_GITCONFIG_URLEMPTY, IDS_APPNAME, MB_OK | MB_ICONERROR);
129 return;
132 if(this->m_bAutoLoadPuttyKey)
134 CAppUtils::LaunchPAgent(NULL,&this->m_strURL);
137 this->SwitchToRun();
139 CString force;
140 if(this->m_bForce)
141 force = _T(" --force ");
143 CString cmd;
145 ShowTab(IDC_CMD_LOG);
147 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
148 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
149 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
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 else
319 this->ShowTab(IDC_CMD_LOG);
322 else
324 if(newhash == this->m_oldHash)
326 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
327 this->m_InLogList.ShowText(CString(MAKEINTRESOURCE(IDS_UPTODATE)));
328 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
330 else
332 this->m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,true);
333 this->m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,true);
335 CString oldhash=m_oldHash.ToString();
336 this->AddDiffFileList(&m_InChangeFileList,&m_arInChangeList,newhash,oldhash);
338 m_InLogList.FillGitLog(NULL,CGit:: LOG_INFO_STAT| CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE,
339 &oldhash,&newhash);
341 this->ShowTab(IDC_IN_LOGLIST);
345 void CSyncDlg::FetchComplete()
347 EnableControlButton(true);
348 SwitchToInput();
349 this->FetchOutList(true);
351 ShowTab(IDC_CMD_LOG);
352 if( (!this->m_GitCmdStatus) && this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
354 CRebaseDlg dlg;
355 dlg.m_PostButtonTexts.Add(_T("Email &Patch..."));
356 INT_PTR response = dlg.DoModal();
357 if(response == IDOK)
359 return ;
362 if(response == IDC_REBASE_POST_BUTTON)
364 CString cmd, out, err;
365 cmd.Format(_T("git.exe format-patch -o \"%s\" %s..%s"),
366 g_Git.m_CurrentDir,
367 g_Git.FixBranchName(dlg.m_Upstream),
368 g_Git.FixBranchName(dlg.m_Branch));
369 if (g_Git.Run(cmd, &out, &err, CP_UTF8))
371 CMessageBox::Show(NULL, out + L"\n" + err, _T("TortoiseGit"), MB_OK|MB_ICONERROR);
372 return ;
375 CAppUtils::SendPatchMail(cmd,out);
380 void CSyncDlg::OnBnClickedButtonPush()
382 this->UpdateData();
383 UpdateCombox();
384 m_ctrlCmdOut.SetWindowTextW(_T(""));
385 m_LogText = "";
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=(DWORD)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, UINT_MAX, UINT_MAX);
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, CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CONFLICTS)), -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_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 AdjustControlSize(IDC_CHECK_PUTTY_KEY);
748 AdjustControlSize(IDC_CHECK_FORCE);
750 CString WorkingDir=g_Git.m_CurrentDir;
751 WorkingDir.Replace(_T(':'),_T('_'));
752 m_RegKeyRemoteBranch = CString(_T("Software\\TortoiseGit\\History\\SyncBranch\\"))+WorkingDir;
755 this->AddOthersToAnchor();
757 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSH)));
758 this->m_ctrlPush.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PUSHTAGS)));
759 ///this->m_ctrlPush.AddEntry(CString(_T("Push All")));
761 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_PULL)));
762 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCH)));
763 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_FETCHREBASE)));
764 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REMOTEUPDATE)));
765 this->m_ctrlPull.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_CLEANUPSTALEBRANCHES)));
767 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEUPDATE)));
768 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULEINIT)));
769 this->m_ctrlSubmodule.AddEntry(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_SUBKODULESYNC)));
771 WorkingDir.Replace(_T(':'),_T('_'));
773 CString regkey ;
774 regkey.Format(_T("Software\\TortoiseGit\\TortoiseProc\\Sync\\%s"),WorkingDir);
776 this->m_regPullButton = CRegDWORD(regkey+_T("\\Pull"),0);
777 this->m_regPushButton = CRegDWORD(regkey+_T("\\Push"),0);
778 this->m_regSubmoduleButton = CRegDWORD(regkey+_T("\\Submodule"));
779 this->m_regAutoLoadPutty = CRegDWORD(regkey + _T("\\AutoLoadPutty"), CAppUtils::IsSSHPutty());
781 m_tooltips.Create(this);
782 this->UpdateData();
783 this->m_bAutoLoadPuttyKey = m_regAutoLoadPutty;
784 if(!CAppUtils::IsSSHPutty())
785 m_bAutoLoadPuttyKey = false;
786 this->UpdateData(FALSE);
788 this->m_ctrlPull.SetCurrentEntry(this->m_regPullButton);
789 this->m_ctrlPush.SetCurrentEntry(this->m_regPushButton);
790 this->m_ctrlSubmodule.SetCurrentEntry(this->m_regSubmoduleButton);
792 CString sWindowTitle;
793 GetWindowText(sWindowTitle);
794 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
796 EnableSaveRestore(_T("SyncDlg"));
798 this->m_ctrlURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\SyncURL\\"))+WorkingDir, _T("url"));
800 STRING_VECTOR list;
802 if(!g_Git.GetRemoteList(list))
804 for(unsigned int i=0;i<list.size();i++)
806 m_ctrlURL.AddString(list[i]);
809 m_ctrlURL.SetCurSel(0);
810 m_ctrlRemoteBranch.SetCurSel(0);
811 m_ctrlURL.SetURLHistory(true);
813 this->LoadBranchInfo();
815 this->m_bInited=true;
816 FetchOutList();
818 m_ctrlTabCtrl.ShowTab(IDC_CMD_LOG-1,false);
819 m_ctrlTabCtrl.ShowTab(IDC_IN_LOGLIST-1,false);
820 m_ctrlTabCtrl.ShowTab(IDC_IN_CHANGELIST-1,false);
821 m_ctrlTabCtrl.ShowTab(IDC_IN_CONFLICT-1,false);
823 m_ctrlRemoteBranch.m_bWantReturn = TRUE;
824 m_ctrlURL.m_bWantReturn = TRUE;
826 this->m_Gitverion = CAppUtils::GetMsysgitVersion();
828 return TRUE; // return TRUE unless you set the focus to a control
829 // EXCEPTION: OCX Property Pages should return FALSE
832 void CSyncDlg::OnBnClickedButtonManage()
834 CAppUtils::LaunchRemoteSetting();
835 Refresh();
838 void CSyncDlg::Refresh()
840 theApp.DoWaitCursor(1);
842 int lastSelected = m_ctrlURL.GetCurSel();
843 CString url;
844 this->m_ctrlURL.GetWindowText(url);
846 this->m_ctrlURL.Reset();
847 CString workingDir = g_Git.m_CurrentDir;
848 workingDir.Replace(_T(':'), _T('_'));
849 this->m_ctrlURL.LoadHistory(_T("Software\\TortoiseGit\\History\\SyncURL\\") + workingDir, _T("url"));
851 STRING_VECTOR list;
852 bool found = false;
853 if (!g_Git.GetRemoteList(list))
855 for (int i = 0; i < list.size(); i++)
857 m_ctrlURL.AddString(list[i]);
858 if (list[i] == url)
859 found = true;
862 if (lastSelected >= 0 && !found)
864 m_ctrlURL.SetCurSel(0);
865 m_ctrlURL.GetWindowText(url);
868 CString local;
869 CString remote;
870 this->m_ctrlLocalBranch.GetWindowText(local);
871 this->m_ctrlRemoteBranch.GetWindowText(remote);
873 this->LoadBranchInfo();
875 this->m_ctrlLocalBranch.AddString(local);
876 this->m_ctrlRemoteBranch.AddString(remote);
877 this->m_ctrlURL.AddString(url);
879 m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_REFRESHING)));
880 this->FetchOutList(true);
881 theApp.DoWaitCursor(-1);
884 BOOL CSyncDlg::PreTranslateMessage(MSG* pMsg)
886 if (pMsg->message == WM_KEYDOWN)
888 switch (pMsg->wParam)
891 case VK_F5:
893 if (m_bBlock)
894 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
895 Refresh();
897 break;
899 /* Avoid TAB control destroy but dialog exist*/
900 case VK_ESCAPE:
901 case VK_CANCEL:
903 TCHAR buff[128];
904 ::GetClassName(pMsg->hwnd,buff,128);
906 if(_tcsnicmp(buff,_T("RichEdit20W"),128)==0)
908 this->PostMessage(WM_KEYDOWN,VK_ESCAPE,0);
909 return TRUE;
914 m_tooltips.RelayEvent(pMsg);
915 return __super::PreTranslateMessage(pMsg);
917 void CSyncDlg::FetchOutList(bool force)
919 if(!m_bInited)
920 return;
921 m_OutChangeFileList.Clear();
922 this->m_OutLogList.Clear();
924 CString remote;
925 this->m_ctrlURL.GetWindowText(remote);
926 CString remotebranch;
927 this->m_ctrlRemoteBranch.GetWindowText(remotebranch);
928 remotebranch=remote+_T("/")+remotebranch;
930 if(IsURL())
932 CString str;
933 str.LoadString(IDS_PROC_SYNC_PUSH_UNKNOWN);
934 m_OutLogList.ShowText(str);
935 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
936 m_OutLocalBranch.Empty();
937 m_OutRemoteBranch.Empty();
939 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
940 return ;
943 else if(g_Git.GetHash(remotebranch).IsEmpty())
945 CString str;
946 str.Format(IDS_PROC_SYNC_PUSH_UNKNOWNBRANCH, remotebranch);
947 m_OutLogList.ShowText(str);
948 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
949 m_OutLocalBranch.Empty();
950 m_OutRemoteBranch.Empty();
952 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
953 return ;
955 else
957 CString localbranch;
958 localbranch=this->m_ctrlLocalBranch.GetString();
960 if(localbranch != m_OutLocalBranch || m_OutRemoteBranch != remotebranch || force)
962 m_OutLogList.ClearText();
964 CGitHash base, remotehash;
965 bool isFastForward = g_Git.IsFastForward(remotebranch, localbranch, &base);
967 remotehash = g_Git.GetHash(remotebranch);
968 if (remotehash == g_Git.GetHash(localbranch))
970 CString str;
971 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, 0, remotebranch);
972 m_OutLogList.ShowText(str);
973 this->m_ctrlStatus.SetWindowText(str);
974 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,FALSE);
975 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
977 else if (isFastForward || m_bForce)
979 //fast forward
980 m_OutLogList.FillGitLog(NULL, CGit::LOG_INFO_STAT | CGit::LOG_INFO_FILESTATE | CGit::LOG_INFO_SHOW_MERGEDFILE, &remotebranch, &localbranch);
981 CString str;
982 str.Format(IDS_PROC_SYNC_COMMITSAHEAD, m_OutLogList.GetItemCount(), remotebranch);
983 this->m_ctrlStatus.SetWindowText(str);
985 if (isFastForward)
986 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, remotebranch);
987 else
989 CString baseString = base.ToString();
990 AddDiffFileList(&m_OutChangeFileList, &m_arOutChangeList, localbranch, baseString);
993 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID()-1,TRUE);
994 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(TRUE);
996 else
998 CString str;
999 str.Format(IDS_PROC_SYNC_NOFASTFORWARD, localbranch, remotebranch);
1000 m_OutLogList.ShowText(str);
1001 this->m_ctrlStatus.SetWindowText(str);
1002 this->m_ctrlTabCtrl.ShowTab(m_OutChangeFileList.GetDlgCtrlID() - 1, FALSE);
1003 this->GetDlgItem(IDC_BUTTON_EMAIL)->EnableWindow(FALSE);
1006 this->m_OutLocalBranch=localbranch;
1007 this->m_OutRemoteBranch=remotebranch;
1012 bool CSyncDlg::IsURL()
1014 CString str;
1015 this->m_ctrlURL.GetWindowText(str);
1016 if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)
1017 return true;
1018 else
1019 return false;
1021 void CSyncDlg::OnCbnEditchangeComboboxex()
1023 SetTimer(IDT_INPUT, 1000, NULL);
1024 this->m_OutLogList.ShowText(CString(MAKEINTRESOURCE(IDS_PROC_SYNC_WAINTINPUT)));
1026 //this->FetchOutList();
1029 UINT CSyncDlg::ProgressThread()
1031 m_GitCmdStatus=CProgressDlg::RunCmdList(this,m_GitCmdList,true,NULL,&this->m_bAbort);
1032 InterlockedExchange(&m_bBlock, FALSE);
1033 return 0;
1037 LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
1039 if(wParam == MSG_PROGRESSDLG_START)
1041 m_ctrlAnimate.Play(0, UINT_MAX, UINT_MAX);
1042 this->m_ctrlProgress.SetPos(0);
1043 if (m_pTaskbarList)
1045 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NORMAL);
1046 m_pTaskbarList->SetProgressValue(m_hWnd, 0, 100);
1050 if(wParam == MSG_PROGRESSDLG_END || wParam == MSG_PROGRESSDLG_FAILED)
1052 //m_bDone = true;
1053 m_ctrlAnimate.Stop();
1054 m_ctrlProgress.SetPos(100);
1055 //this->DialogEnableWindow(IDOK,TRUE);
1057 DWORD exitCode = (DWORD)lParam;
1058 if (exitCode)
1060 if (m_pTaskbarList)
1062 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_ERROR);
1063 m_pTaskbarList->SetProgressValue(m_hWnd, 100, 100);
1065 CString log;
1066 log.Format(IDS_PROC_PROGRESS_GITUNCLEANEXIT, exitCode);
1067 CString err;
1068 err.Format(_T("\r\n\r\n%s\r\n"), log);
1069 CProgressDlg::InsertColorText(this->m_ctrlCmdOut, err, RGB(255,0,0));
1071 else
1073 if (m_pTaskbarList)
1074 m_pTaskbarList->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
1075 CString temp;
1076 temp.LoadString(IDS_SUCCESS);
1077 CString log;
1078 log.Format(_T("\r\n%s\r\n"), temp);
1079 CProgressDlg::InsertColorText(this->m_ctrlCmdOut, log, RGB(0,0,255));
1082 //if(wParam == MSG_PROGRESSDLG_END)
1083 if(this->m_CurrentCmd == GIT_COMMAND_PUSH )
1085 if(!m_GitCmdStatus)
1087 CTGitPathList list;
1088 list.AddPath(CTGitPath(g_Git.m_CurrentDir));
1089 DWORD exitcode;
1090 CString error;
1091 if (CHooks::Instance().PostPush(list,exitcode, error))
1093 if (exitcode)
1095 CString temp;
1096 temp.Format(IDS_ERR_HOOKFAILED, (LPCTSTR)error);
1097 //ReportError(temp);
1098 CMessageBox::Show(NULL,temp,_T("TortoiseGit"),MB_OK|MB_ICONERROR);
1099 return false;
1104 EnableControlButton(true);
1105 SwitchToInput();
1106 this->FetchOutList(true);
1108 if(this->m_CurrentCmd == GIT_COMMAND_PULL )
1110 PullComplete();
1112 if(this->m_CurrentCmd == GIT_COMMAND_FETCH || this->m_CurrentCmd == GIT_COMMAND_FETCHANDREBASE)
1114 FetchComplete();
1116 if(this->m_CurrentCmd == GIT_COMMAND_SUBMODULE)
1118 //this->m_ctrlCmdOut.SetSel(-1,-1);
1119 //this->m_ctrlCmdOut.ReplaceSel(_T("Done\r\n"));
1120 //this->m_ctrlCmdOut.SetSel(-1,-1);
1121 EnableControlButton(true);
1122 SwitchToInput();
1124 if(this->m_CurrentCmd == GIT_COMMAND_REMOTE)
1126 this->FetchOutList(true);
1127 EnableControlButton(true);
1128 SwitchToInput();
1132 if(lParam != 0)
1133 ParserCmdOutput((char)lParam);
1135 return 0;
1139 void CSyncDlg::ParserCmdOutput(char ch)
1141 CProgressDlg::ParserCmdOutput(m_ctrlCmdOut,m_ctrlProgress,m_hWnd,m_pTaskbarList,m_LogText,ch);
1143 void CSyncDlg::OnBnClickedButtonCommit()
1145 CString cmd = _T("/command:commit");
1146 cmd += _T(" /path:\"");
1147 cmd += g_Git.m_CurrentDir;
1148 cmd += _T("\"");
1150 CAppUtils::RunTortoiseProc(cmd);
1153 void CSyncDlg::OnOK()
1155 UpdateCombox();
1156 this->UpdateData();
1157 m_ctrlURL.SaveHistory();
1158 SaveHistory();
1159 m_regAutoLoadPutty = this->m_bAutoLoadPuttyKey;
1160 __super::OnOK();
1163 void CSyncDlg::OnBnClickedButtonSubmodule()
1165 this->UpdateData();
1166 UpdateCombox();
1167 m_ctrlCmdOut.SetWindowTextW(_T(""));
1168 m_LogText = "";
1170 this->m_regSubmoduleButton = (DWORD)this->m_ctrlSubmodule.GetCurrentEntry();
1172 this->SwitchToRun();
1174 this->m_bAbort=false;
1175 this->m_GitCmdList.clear();
1177 ShowTab(IDC_CMD_LOG);
1179 CString cmd;
1181 switch (m_ctrlSubmodule.GetCurrentEntry())
1183 case 0:
1184 cmd=_T("git.exe submodule update --init");
1185 break;
1186 case 1:
1187 cmd=_T("git.exe submodule init");
1188 break;
1189 case 2:
1190 cmd=_T("git.exe submodule sync");
1191 break;
1194 m_GitCmdList.push_back(cmd);
1196 m_CurrentCmd = GIT_COMMAND_SUBMODULE;
1198 m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
1199 if (m_pThread==NULL)
1201 // ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
1203 else
1205 m_pThread->m_bAutoDelete = TRUE;
1206 m_pThread->ResumeThread();
1210 void CSyncDlg::OnTimer(UINT_PTR nIDEvent)
1212 if( nIDEvent == IDT_INPUT)
1214 KillTimer(IDT_INPUT);
1215 this->FetchOutList(true);
1220 void CSyncDlg::OnLvnInLogListColumnClick(NMHDR * /* pNMHDR */, LRESULT *pResult)
1222 *pResult = 0;
1225 LRESULT CSyncDlg::OnTaskbarBtnCreated(WPARAM /*wParam*/, LPARAM /*lParam*/)
1227 m_pTaskbarList.Release();
1228 m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList);
1229 return 0;
1232 void CSyncDlg::OnBnClickedCheckForce()
1234 UpdateData();
1237 void CSyncDlg::OnBnClickedLog()
1239 CString cmd = _T("/command:log");
1240 cmd += _T(" /path:\"");
1241 cmd += g_Git.m_CurrentDir;
1242 cmd += _T("\"");
1244 CAppUtils::RunTortoiseProc(cmd);