Add support for "project" config level
[TortoiseGit.git] / src / TortoiseProc / FileDiffDlg.cpp
blob724725948b2dc1a8891efc72b26b6d492c5e03d8
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "UnicodeUtils.h"
23 #include "MessageBox.h"
24 #include "AppUtils.h"
25 #include "TempFile.h"
26 #include "SysImageList.h"
27 #include "IconMenu.h"
28 #include "StringUtils.h"
29 #include "PathUtils.h"
30 #include "BrowseFolder.h"
31 #include "FileDiffDlg.h"
32 #include "GitDiff.h"
33 #include "LoglistCommonResource.h"
34 #include "LoglistUtils.h"
35 #include "BrowseRefsDlg.h"
36 #include "LogDlg.h"
37 #include "RefLogDlg.h"
38 #include "GitStatusListCtrl.h"
39 #include "FormatMessageWrapper.h"
41 #define ID_COMPARE 1
42 #define ID_BLAME 2
43 #define ID_SAVEAS 3
44 #define ID_EXPORT 4
45 #define ID_CLIPBOARD_PATH 5
46 #define ID_CLIPBOARD_ALL 6
47 #define ID_LOG 7
48 #define ID_GNUDIFFCOMPARE 8
49 #define ID_REVERT1 9
50 #define ID_REVERT2 10
52 BOOL CFileDiffDlg::m_bAscending = FALSE;
53 int CFileDiffDlg::m_nSortedColumn = -1;
55 UINT CFileDiffDlg::WM_DISABLEBUTTONS = RegisterWindowMessage(_T("TORTOISEGIT_FILEDIFF_DISABLEBUTTONS"));
56 UINT CFileDiffDlg::WM_DIFFFINISHED = RegisterWindowMessage(_T("TORTOISEGIT_FILEDIFF_DIFFFINISHED"));
58 IMPLEMENT_DYNAMIC(CFileDiffDlg, CResizableStandAloneDialog)
59 CFileDiffDlg::CFileDiffDlg(CWnd* pParent /*=NULL*/)
60 : CResizableStandAloneDialog(CFileDiffDlg::IDD, pParent)
61 , m_bBlame(false)
62 , m_pProgDlg(NULL)
63 , m_bCancelled(false)
64 , m_nIconFolder(0)
65 , m_bThreadRunning(FALSE)
67 m_bLoadingRef=FALSE;
70 CFileDiffDlg::~CFileDiffDlg()
74 void CFileDiffDlg::DoDataExchange(CDataExchange* pDX)
76 CResizableStandAloneDialog::DoDataExchange(pDX);
77 DDX_Control(pDX, IDC_FILELIST, m_cFileList);
78 DDX_Control(pDX, IDC_SWITCHLEFTRIGHT, m_SwitchButton);
79 DDX_Control(pDX, IDC_REV1BTN, m_cRev1Btn);
80 DDX_Control(pDX, IDC_REV2BTN, m_cRev2Btn);
81 DDX_Control(pDX, IDC_FILTER, m_cFilter);
82 DDX_Control(pDX, IDC_REV1EDIT, m_ctrRev1Edit);
83 DDX_Control(pDX, IDC_REV2EDIT, m_ctrRev2Edit);
87 BEGIN_MESSAGE_MAP(CFileDiffDlg, CResizableStandAloneDialog)
88 ON_NOTIFY(NM_DBLCLK, IDC_FILELIST, OnNMDblclkFilelist)
89 ON_NOTIFY(LVN_GETINFOTIP, IDC_FILELIST, OnLvnGetInfoTipFilelist)
90 ON_NOTIFY(NM_CUSTOMDRAW, IDC_FILELIST, OnNMCustomdrawFilelist)
91 ON_WM_CONTEXTMENU()
92 ON_WM_SETCURSOR()
93 ON_EN_SETFOCUS(IDC_SECONDURL, &CFileDiffDlg::OnEnSetfocusSecondurl)
94 ON_EN_SETFOCUS(IDC_FIRSTURL, &CFileDiffDlg::OnEnSetfocusFirsturl)
95 ON_BN_CLICKED(IDC_SWITCHLEFTRIGHT, &CFileDiffDlg::OnBnClickedSwitchleftright)
96 ON_NOTIFY(HDN_ITEMCLICK, 0, &CFileDiffDlg::OnHdnItemclickFilelist)
97 ON_BN_CLICKED(IDC_REV1BTN, &CFileDiffDlg::OnBnClickedRev1btn)
98 ON_BN_CLICKED(IDC_REV2BTN, &CFileDiffDlg::OnBnClickedRev2btn)
99 ON_MESSAGE(WM_FILTEREDIT_CANCELCLICKED, OnClickedCancelFilter)
100 ON_EN_CHANGE(IDC_FILTER, &CFileDiffDlg::OnEnChangeFilter)
101 ON_WM_TIMER()
102 ON_MESSAGE(ENAC_UPDATE, &CFileDiffDlg::OnEnUpdate)
103 ON_MESSAGE(MSG_REF_LOADED, OnRefLoad)
104 ON_REGISTERED_MESSAGE(WM_DISABLEBUTTONS, OnDisableButtons)
105 ON_REGISTERED_MESSAGE(WM_DIFFFINISHED, OnDiffFinished)
106 ON_BN_CLICKED(IDC_LOG, &CFileDiffDlg::OnBnClickedLog)
107 END_MESSAGE_MAP()
110 void CFileDiffDlg::SetDiff(CTGitPath * path, GitRev rev1, GitRev rev2)
112 if(path!=NULL)
114 m_path1 = *path;
115 m_path2 = *path;
116 m_sFilter = path->GetGitPathString();
118 m_rev1 = rev1;
119 m_rev2 = rev2;
122 void CFileDiffDlg::SetDiff(CTGitPath * path, CString hash1, CString hash2)
124 if(path!=NULL)
126 m_path1 = *path;
127 m_path2 = *path;
128 m_sFilter = path->GetGitPathString();
131 BYTE_VECTOR logout;
133 if(hash1 == GIT_REV_ZERO)
135 m_rev1.m_CommitHash.Empty();
136 m_rev1.GetSubject() = CString(MAKEINTRESOURCE(IDS_git_DEPTH_WORKING));
138 else
142 m_rev1.GetCommit(hash1);
144 catch (const char *msg)
146 MessageBox(_T("Could not get commit ") + hash1 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
150 logout.clear();
152 if(hash2 == GIT_REV_ZERO)
154 m_rev2.m_CommitHash.Empty();
155 m_rev2.GetSubject() = CString(MAKEINTRESOURCE(IDS_git_DEPTH_WORKING));
157 else
161 m_rev2.GetCommit(hash2);
163 catch (const char *msg)
165 MessageBox(_T("Could not get commit ") + hash2 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
170 void CFileDiffDlg::SetDiff(CTGitPath * path, GitRev rev1)
172 if(path!=NULL)
174 m_path1 = *path;
175 m_path2 = *path;
176 m_sFilter = path->GetGitPathString();
178 m_rev1 = rev1;
179 m_rev2.m_CommitHash.Empty();
180 m_rev2.GetSubject() = CString(MAKEINTRESOURCE(IDS_PROC_PREVIOUSVERSION));
182 //this->GetDlgItem()->EnableWindow(FALSE);
185 BOOL CFileDiffDlg::OnInitDialog()
187 CResizableStandAloneDialog::OnInitDialog();
188 CString temp;
190 CString sWindowTitle;
191 GetWindowText(sWindowTitle);
192 CString pathText = g_Git.m_CurrentDir;
193 if (!m_path1.IsEmpty())
194 pathText = g_Git.m_CurrentDir + _T("\\") + m_path1.GetWinPathString();
195 CAppUtils::SetWindowTitle(m_hWnd, pathText, sWindowTitle);
197 this->m_ctrRev1Edit.Init();
198 this->m_ctrRev2Edit.Init();
200 m_tooltips.Create(this);
201 m_tooltips.AddTool(IDC_SWITCHLEFTRIGHT, IDS_FILEDIFF_SWITCHLEFTRIGHT_TT);
203 m_cFileList.SetRedraw(false);
204 m_cFileList.DeleteAllItems();
205 DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP;
206 m_cFileList.SetExtendedStyle(exStyle);
208 m_nIconFolder = SYS_IMAGE_LIST().GetDirIconIndex();
209 m_cFileList.SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL);
211 m_SwitchButton.SetImage((HICON)LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_SWITCHLEFTRIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR));
212 m_SwitchButton.Invalidate();
214 m_cFilter.SetCancelBitmaps(IDI_CANCELNORMAL, IDI_CANCELPRESSED);
215 m_cFilter.SetInfoIcon(IDI_FILTEREDIT);
216 temp.LoadString(IDS_FILEDIFF_FILTERCUE);
217 temp = _T(" ")+temp;
218 m_cFilter.SetCueBanner(temp);
219 if (!m_sFilter.IsEmpty())
220 m_cFilter.SetWindowText(m_sFilter);
222 int c = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
223 while (c>=0)
224 m_cFileList.DeleteColumn(c--);
226 temp.LoadString(IDS_FILEDIFF_FILE);
227 m_cFileList.InsertColumn(0, temp);
228 temp.LoadString(IDS_FILEDIFF_EXT);
229 m_cFileList.InsertColumn(1, temp);
230 temp.LoadString(IDS_FILEDIFF_ACTION);
231 m_cFileList.InsertColumn(2, temp);
233 temp.LoadString(IDS_FILEDIFF_STATADD);
234 m_cFileList.InsertColumn(3, temp);
235 temp.LoadString(IDS_FILEDIFF_STATDEL);
236 m_cFileList.InsertColumn(4, temp);
238 int mincol = 0;
239 int maxcol = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
240 int col;
241 for (col = mincol; col <= maxcol; col++)
243 m_cFileList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);
246 m_cFileList.SetRedraw(true);
248 AddAnchor(IDC_DIFFSTATIC1, TOP_LEFT, TOP_RIGHT);
249 AddAnchor(IDC_SWITCHLEFTRIGHT, TOP_RIGHT);
250 AddAnchor(IDC_FIRSTURL, TOP_LEFT, TOP_RIGHT);
251 AddAnchor(IDC_REV1BTN, TOP_RIGHT);
252 //AddAnchor(IDC_DIFFSTATIC2, TOP_LEFT, TOP_RIGHT);
253 AddAnchor(IDC_SECONDURL, TOP_LEFT, TOP_RIGHT);
254 AddAnchor(IDC_REV2BTN, TOP_RIGHT);
255 AddAnchor(IDC_FILTER, TOP_LEFT, TOP_RIGHT);
256 AddAnchor(IDC_FILELIST, TOP_LEFT, BOTTOM_RIGHT);
257 AddAnchor(IDC_REV1GROUP,TOP_LEFT,TOP_RIGHT);
258 AddAnchor(IDC_REV2GROUP,TOP_LEFT,TOP_RIGHT);
259 AddAnchor(IDC_REV1EDIT,TOP_LEFT);
260 AddAnchor(IDC_REV2EDIT,TOP_LEFT);
261 AddAnchor(IDC_LOG, TOP_RIGHT);
263 EnableSaveRestore(_T("FileDiffDlg"));
265 if(this->m_strRev1.IsEmpty())
266 this->m_ctrRev1Edit.SetWindowText(this->m_rev1.m_CommitHash.ToString());
267 else
269 bool rev1fail = false;
272 rev1fail = !!m_rev1.GetCommit(m_strRev1);
274 catch (const char *msg)
276 rev1fail = true;
277 MessageBox(_T("Could not get commit ") + m_strRev1 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
279 if (rev1fail)
281 CString msg;
282 msg.Format(IDS_PROC_REFINVALID, m_strRev1);
283 this->m_FileListText += msg;
286 this->m_ctrRev1Edit.SetWindowText(m_strRev1);
289 if(this->m_strRev2.IsEmpty())
290 this->m_ctrRev2Edit.SetWindowText(this->m_rev2.m_CommitHash.ToString());
291 else
293 bool rev2fail = false;
296 rev2fail = !!m_rev2.GetCommit(m_strRev2);
298 catch (const char *msg)
300 rev2fail = true;
301 MessageBox(_T("Could not get commit ") + m_strRev2 + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
303 if (rev2fail)
305 CString msg;
306 msg.Format(IDS_PROC_REFINVALID, m_strRev2);
307 this->m_FileListText += msg;
310 this->m_ctrRev2Edit.SetWindowText(m_strRev2);
313 SetURLLabels();
315 InterlockedExchange(&m_bThreadRunning, TRUE);
316 if (AfxBeginThread(DiffThreadEntry, this)==NULL)
318 InterlockedExchange(&m_bThreadRunning, FALSE);
319 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
322 InterlockedExchange(&m_bLoadingRef, TRUE);
323 if (AfxBeginThread(LoadRefThreadEntry, this)==NULL)
325 InterlockedExchange(&m_bLoadingRef, FALSE);
326 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
329 this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
330 this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
331 this->m_cRev1Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));
333 this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFBROWSE)));
334 this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_LOG)));
335 this->m_cRev2Btn.AddEntry(CString(MAKEINTRESOURCE(IDS_REFLOG)));
337 // Start with focus on file list
338 GetDlgItem(IDC_FILELIST)->SetFocus();
340 if(m_rev2.m_CommitHash.IsEmpty())
341 m_SwitchButton.EnableWindow(FALSE);
343 KillTimer(IDT_INPUT);
344 return FALSE;
347 UINT CFileDiffDlg::DiffThreadEntry(LPVOID pVoid)
349 return ((CFileDiffDlg*)pVoid)->DiffThread();
352 UINT CFileDiffDlg::DiffThread()
354 SendMessage(WM_DISABLEBUTTONS);
356 if( m_rev1.m_CommitHash.IsEmpty() || m_rev2.m_CommitHash.IsEmpty())
357 g_Git.RefreshGitIndex();
359 g_Git.GetCommitDiffList(m_rev1.m_CommitHash.ToString(),m_rev2.m_CommitHash.ToString(),m_arFileList);
361 SendMessage(WM_DIFFFINISHED);
363 InterlockedExchange(&m_bThreadRunning, FALSE);
364 return 0;
367 LRESULT CFileDiffDlg::OnDisableButtons(WPARAM, LPARAM)
369 RefreshCursor();
370 m_cFileList.ShowText(CString(MAKEINTRESOURCE(IDS_FILEDIFF_WAIT)));
371 m_cFileList.DeleteAllItems();
372 m_arFileList.Clear();
373 EnableInputControl(false);
374 return 0;
377 LRESULT CFileDiffDlg::OnDiffFinished(WPARAM, LPARAM)
379 CString sFilterText;
380 m_cFilter.GetWindowText(sFilterText);
381 m_cFileList.SetRedraw(false);
382 Filter(sFilterText);
383 if (m_arFileList.GetCount() > 0)
385 // Highlight first entry in file list
386 m_cFileList.SetSelectionMark(0);
387 m_cFileList.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
390 int mincol = 0;
391 int maxcol = ((CHeaderCtrl*)(m_cFileList.GetDlgItem(0)))->GetItemCount()-1;
392 int col;
393 for (col = mincol; col <= maxcol; ++col)
395 m_cFileList.SetColumnWidth(col, LVSCW_AUTOSIZE_USEHEADER);
398 m_cFileList.ClearText();
399 m_cFileList.SetRedraw(true);
401 InvalidateRect(NULL);
402 RefreshCursor();
403 EnableInputControl(true);
404 return 0;
407 int CFileDiffDlg::AddEntry(const CTGitPath * fd)
409 int ret = -1;
410 if (fd)
412 int index = m_cFileList.GetItemCount();
414 int icon_idx = 0;
415 if (fd->IsDirectory())
416 icon_idx = m_nIconFolder;
417 else
418 icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(fd->GetGitPathString());
420 ret = m_cFileList.InsertItem(index, fd->GetGitPathString(), icon_idx);
421 m_cFileList.SetItemText(index, 1, ((CTGitPath*)fd)->GetFileExtension());
422 m_cFileList.SetItemText(index, 2, ((CTGitPath*)fd)->GetActionName());
423 m_cFileList.SetItemText(index, 3, ((CTGitPath*)fd)->m_StatAdd);
424 m_cFileList.SetItemText(index, 4, ((CTGitPath*)fd)->m_StatDel);
426 return ret;
429 void CFileDiffDlg::EnableInputControl(bool b)
431 this->m_ctrRev1Edit.EnableWindow(b);
432 this->m_ctrRev2Edit.EnableWindow(b);
433 this->m_cRev1Btn.EnableWindow(b);
434 this->m_cRev2Btn.EnableWindow(b);
435 m_cFilter.EnableWindow(b);
436 m_SwitchButton.EnableWindow(b);
437 GetDlgItem(IDC_LOG)->EnableWindow(b && !(m_rev1.m_CommitHash.IsEmpty() || m_rev2.m_CommitHash.IsEmpty()));
440 void CFileDiffDlg::DoDiff(int selIndex, bool blame)
442 CGitDiff diff;
443 CTGitPath* fd2 = m_arFilteredList[selIndex];
444 CTGitPath* fd1 = fd2;
445 if (fd2->m_Action & CTGitPath::LOGACTIONS_REPLACED)
446 fd1 = new CTGitPath(fd2->GetGitOldPathString());
447 diff.Diff(fd2, fd1, this->m_rev1.m_CommitHash.ToString(), this->m_rev2.m_CommitHash.ToString(), blame, FALSE);
451 void CFileDiffDlg::OnNMDblclkFilelist(NMHDR *pNMHDR, LRESULT *pResult)
453 *pResult = 0;
454 LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
455 int selIndex = pNMLV->iItem;
456 if (selIndex < 0)
457 return;
458 if (selIndex >= (int)m_arFilteredList.size())
459 return;
461 DoDiff(selIndex, m_bBlame);
464 void CFileDiffDlg::OnLvnGetInfoTipFilelist(NMHDR *pNMHDR, LRESULT *pResult)
467 LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);
468 if (pGetInfoTip->iItem >= (int)m_arFilteredList.size())
469 return;
471 CString path = m_path1.GetGitPathString() + _T("/") + m_arFilteredList[pGetInfoTip->iItem]->GetGitPathString();
472 if (pGetInfoTip->cchTextMax > path.GetLength())
473 _tcsncpy_s(pGetInfoTip->pszText, pGetInfoTip->cchTextMax, path, pGetInfoTip->cchTextMax);
475 *pResult = 0;
478 void CFileDiffDlg::OnNMCustomdrawFilelist(NMHDR *pNMHDR, LRESULT *pResult)
480 NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
481 // Take the default processing unless we set this to something else below.
482 *pResult = CDRF_DODEFAULT;
484 // First thing - check the draw stage. If it's the control's prepaint
485 // stage, then tell Windows we want messages for every item.
487 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
489 *pResult = CDRF_NOTIFYITEMDRAW;
491 else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
493 // This is the prepaint stage for an item. Here's where we set the
494 // item's text color. Our return value will tell Windows to draw the
495 // item itself, but it will use the new color we set here.
497 // Tell Windows to paint the control itself.
498 *pResult = CDRF_DODEFAULT;
500 COLORREF crText = GetSysColor(COLOR_WINDOWTEXT);
502 if (m_arFilteredList.size() > pLVCD->nmcd.dwItemSpec)
504 CTGitPath * fd = m_arFilteredList[pLVCD->nmcd.dwItemSpec];
505 switch (fd->m_Action)
507 case CTGitPath::LOGACTIONS_ADDED:
508 crText = m_colors.GetColor(CColors::Added);
509 break;
510 case CTGitPath::LOGACTIONS_DELETED:
511 crText = m_colors.GetColor(CColors::Deleted);
512 break;
513 case CTGitPath::LOGACTIONS_MODIFIED:
514 crText = m_colors.GetColor(CColors::Modified);
515 break;
516 default:
517 crText = m_colors.GetColor(CColors::PropertyChanged);
518 break;
521 // Store the color back in the NMLVCUSTOMDRAW struct.
522 pLVCD->clrText = crText;
526 UINT CFileDiffDlg::LoadRefThread()
528 g_Git.GetBranchList(m_Reflist,NULL,CGit::BRANCH_ALL_F);
529 g_Git.GetTagList(m_Reflist);
531 this->PostMessage(MSG_REF_LOADED);
532 InterlockedExchange(&m_bLoadingRef, FALSE);
533 return 0;
536 void CFileDiffDlg::OnContextMenu(CWnd* pWnd, CPoint point)
538 if ((pWnd==0)||(pWnd != &m_cFileList))
539 return;
540 if (m_cFileList.GetSelectedCount() == 0)
541 return;
542 // if the context menu is invoked through the keyboard, we have to use
543 // a calculated position on where to anchor the menu on
544 if ((point.x == -1) && (point.y == -1))
546 CRect rect;
547 m_cFileList.GetItemRect(m_cFileList.GetSelectionMark(), &rect, LVIR_LABEL);
548 m_cFileList.ClientToScreen(&rect);
549 point = rect.CenterPoint();
551 CIconMenu popup;
552 if (popup.CreatePopupMenu())
554 CString menuText;
555 popup.AppendMenuIcon(ID_COMPARE, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF);
556 popup.AppendMenuIcon(ID_GNUDIFFCOMPARE, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
557 popup.AppendMenu(MF_SEPARATOR, NULL);
558 menuText.Format(IDS_FILEDIFF_POPREVERTTOREV, m_rev1.m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()));
559 popup.AppendMenuIcon(ID_REVERT1, menuText, IDI_REVERT);
560 menuText.Format(IDS_FILEDIFF_POPREVERTTOREV, m_rev2.m_CommitHash.ToString().Left(g_Git.GetShortHASHLength()));
561 popup.AppendMenuIcon(ID_REVERT2, menuText, IDI_REVERT);
562 popup.AppendMenu(MF_SEPARATOR, NULL);
563 popup.AppendMenuIcon(ID_LOG, IDS_FILEDIFF_LOG, IDI_LOG);
564 popup.AppendMenuIcon(ID_BLAME, IDS_FILEDIFF_POPBLAME, IDI_BLAME);
565 popup.AppendMenu(MF_SEPARATOR, NULL);
566 popup.AppendMenuIcon(ID_EXPORT, IDS_FILEDIFF_POPEXPORT, IDI_EXPORT);
567 popup.AppendMenu(MF_SEPARATOR, NULL);
568 popup.AppendMenuIcon(ID_SAVEAS, IDS_FILEDIFF_POPSAVELIST, IDI_SAVEAS);
569 popup.AppendMenuIcon(ID_CLIPBOARD_PATH, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP);
570 popup.AppendMenuIcon(ID_CLIPBOARD_ALL, IDS_STATUSLIST_CONTEXT_COPYEXT, IDI_COPYCLIP);
572 int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
573 m_bCancelled = false;
574 switch (cmd)
576 case ID_COMPARE:
578 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
579 while (pos)
581 int index = m_cFileList.GetNextSelectedItem(pos);
582 DoDiff(index, false);
585 break;
586 case ID_GNUDIFFCOMPARE:
588 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
589 while (pos)
591 CTGitPath *fd2 = m_arFilteredList[m_cFileList.GetNextSelectedItem(pos)];
592 CTGitPath *fd1 = fd2;
593 if (fd2->m_Action & CTGitPath::LOGACTIONS_REPLACED)
594 fd1 = new CTGitPath(fd2->GetGitOldPathString());
595 CAppUtils::StartShowUnifiedDiff(m_hWnd, *fd2, m_rev2.m_CommitHash.ToString(), *fd1, m_rev1.m_CommitHash.ToString());
598 break;
599 case ID_REVERT1:
600 RevertSelectedItemToVersion(m_rev1.m_CommitHash.ToString());
601 break;
602 case ID_REVERT2:
603 RevertSelectedItemToVersion(m_rev2.m_CommitHash.ToString());
604 break;
605 case ID_BLAME:
607 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
608 while (pos)
610 int index = m_cFileList.GetNextSelectedItem(pos);
611 CAppUtils::LaunchTortoiseBlame(m_arFilteredList[index]->GetWinPathString(), m_rev1.m_CommitHash.ToString());
614 break;
615 case ID_LOG:
617 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
618 while (pos)
620 int index = m_cFileList.GetNextSelectedItem(pos);
621 CString cmd = _T("/command:log");
622 cmd += _T(" /path:\"")+m_arFilteredList[index]->GetWinPathString()+_T("\" ");
623 cmd += _T(" /endrev:")+m_rev1.m_CommitHash.ToString();
624 CAppUtils::RunTortoiseGitProc(cmd);
627 break;
628 case ID_SAVEAS:
630 if (m_cFileList.GetSelectedCount() > 0)
632 CString temp;
633 CTGitPath savePath;
634 CString pathSave;
635 if (!CAppUtils::FileOpenSave(pathSave, NULL, IDS_REPOBROWSE_SAVEAS, IDS_COMMONFILEFILTER, false, m_hWnd))
637 break;
639 savePath = CTGitPath(pathSave);
641 // now open the selected file for writing
644 CStdioFile file(savePath.GetWinPathString(), CFile::typeBinary | CFile::modeReadWrite | CFile::modeCreate);
645 // temp.Format(IDS_FILEDIFF_CHANGEDLISTINTRO, (LPCTSTR)m_path1.GetGitPathString(), (LPCTSTR)m_rev1.ToString(), (LPCTSTR)m_path2.GetGitPathString(), (LPCTSTR)m_rev2.ToString());
646 file.WriteString(temp + _T("\n"));
647 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
648 while (pos)
650 int index = m_cFileList.GetNextSelectedItem(pos);
651 CTGitPath* fd = m_arFilteredList[index];
652 file.WriteString(fd->GetGitPathString());
653 file.WriteString(_T("\n"));
655 file.Close();
657 catch (CFileException* pE)
659 pE->ReportError();
663 break;
664 case ID_CLIPBOARD_PATH:
666 CopySelectionToClipboard();
668 break;
670 case ID_CLIPBOARD_ALL:
672 CopySelectionToClipboard(TRUE);
674 break;
675 case ID_EXPORT:
677 // export all changed files to a folder
678 CBrowseFolder browseFolder;
679 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
680 if (browseFolder.Show(GetSafeHwnd(), m_strExportDir) == CBrowseFolder::OK)
682 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
683 while (pos)
685 int index = m_cFileList.GetNextSelectedItem(pos);
686 CTGitPath* fd = m_arFilteredList[index];
687 // we cannot export directories or folders
688 if (fd->m_Action == CTGitPath::LOGACTIONS_DELETED || fd->IsDirectory())
689 continue;
690 CAppUtils::CreateMultipleDirectory(m_strExportDir + _T("\\") + fd->GetContainingDirectory().GetWinPathString());
691 CString filename = m_strExportDir + _T("\\") + fd->GetWinPathString();
692 if(m_rev1.m_CommitHash.ToString() == GIT_REV_ZERO)
694 if(!CopyFile(g_Git.m_CurrentDir + _T("\\") + fd->GetWinPath(), filename, false))
696 MessageBox(CFormatMessageWrapper(), _T("TortoiseGit"), MB_OK | MB_ICONERROR);
697 return;
700 else
702 if(g_Git.GetOneFile(m_rev1.m_CommitHash, *fd, filename))
704 CString out;
705 out.Format(IDS_STATUSLIST_CHECKOUTFILEFAILED, fd->GetGitPathString(), m_rev1.m_CommitHash.ToString(), filename);
706 if (CMessageBox::Show(NULL, out, _T("TortoiseGit"), 2, IDI_WARNING, CString(MAKEINTRESOURCE(IDS_IGNOREBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2)
707 return;
714 break;
720 BOOL CFileDiffDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
722 if (pWnd != &m_cFileList)
723 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
724 if (m_bThreadRunning == 0)
726 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
727 SetCursor(hCur);
728 return CResizableStandAloneDialog::OnSetCursor(pWnd, nHitTest, message);
730 HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
731 SetCursor(hCur);
732 return TRUE;
735 void CFileDiffDlg::OnEnSetfocusFirsturl()
737 GetDlgItem(IDC_FIRSTURL)->HideCaret();
740 void CFileDiffDlg::OnEnSetfocusSecondurl()
742 GetDlgItem(IDC_SECONDURL)->HideCaret();
746 void CFileDiffDlg::OnBnClickedSwitchleftright()
749 if (m_bThreadRunning)
750 return;
752 #if 0
753 CString sFilterString;
754 m_cFilter.GetWindowText(sFilterString);
756 m_cFileList.SetRedraw(false);
757 m_cFileList.DeleteAllItems();
758 for (int i=0; i<(int)m_arFileList.GetCount(); ++i)
760 CTGitPath fd = m_arFileList[i];
761 if (fd.m_Action == CTGitPath::LOGACTIONS_ADDED)
762 fd.m_Action = CTGitPath::LOGACTIONS_DELETED;
763 else if (fd.m_Action == CTGitPath::LOGACTIONS_DELETED)
764 fd.m_Action = CTGitPath::LOGACTIONS_ADDED;
765 std::swap(fd.m_StatAdd, fd.m_StatDel);
766 (CTGitPath&)m_arFileList[i] = fd;
768 Filter(sFilterString);
769 #endif
771 m_cFileList.SetRedraw(true);
772 CTGitPath path = m_path1;
773 m_path1 = m_path2;
774 m_path2 = path;
775 GitRev rev = m_rev1;
776 m_rev1 = m_rev2;
777 m_rev2 = rev;
779 CString str1,str2;
780 this->m_ctrRev1Edit.GetWindowText(str1);
781 this->m_ctrRev2Edit.GetWindowText(str2);
783 this->m_ctrRev1Edit.SetWindowText(str2);
784 this->m_ctrRev2Edit.SetWindowText(str1);
786 SetURLLabels();
787 //KillTimer(IDT_INPUT);
790 void CFileDiffDlg::SetURLLabels(int mask)
793 // m_cRev1Btn.SetWindowText(m_rev1.m_CommitHash.ToString().Left(6));
794 // m_cRev2Btn.SetWindowText(m_rev2.m_CommitHash.ToString().Left(6));
796 if(mask &0x1)
798 SetDlgItemText(IDC_FIRSTURL, m_rev1.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev1.GetSubject());
799 m_tooltips.AddTool(IDC_FIRSTURL,
800 CLoglistUtils::FormatDateAndTime(m_rev1.GetAuthorDate(), DATE_SHORTDATE, false) + _T(" ") + m_rev1.GetAuthorName());
804 if(mask &0x2)
806 SetDlgItemText(IDC_SECONDURL,m_rev2.m_CommitHash.ToString().Left(8)+_T(": ")+m_rev2.GetSubject());
808 m_tooltips.AddTool(IDC_SECONDURL,
809 CLoglistUtils::FormatDateAndTime(m_rev2.GetAuthorDate(), DATE_SHORTDATE, false) + _T(" ") + m_rev2.GetAuthorName());
812 this->GetDlgItem(IDC_REV2GROUP)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_FILEDIFF_VERSION2BASE)));
813 this->GetDlgItem(IDC_REV1GROUP)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_FILEDIFF_VERSION1)));
815 if( (mask&0x3) == 0x3)
816 if(m_rev2.GetCommitterDate() > m_rev1.GetCommitterDate())
818 this->GetDlgItem(IDC_REV2GROUP)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_FILEDIFF_VERSION2BASENEWER)));
820 else
822 this->GetDlgItem(IDC_REV1GROUP)->SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_FILEDIFF_VERSION1NEWER)));
826 void CFileDiffDlg::ClearURLabels(int mask)
828 if(mask&0x1)
830 SetDlgItemText(IDC_FIRSTURL, _T(""));
831 m_tooltips.AddTool(IDC_FIRSTURL, _T(""));
834 if(mask&0x2)
836 SetDlgItemText(IDC_SECONDURL, _T(""));
837 m_tooltips.AddTool(IDC_SECONDURL, _T(""));
840 BOOL CFileDiffDlg::PreTranslateMessage(MSG* pMsg)
842 m_tooltips.RelayEvent(pMsg);
843 if (pMsg->message == WM_KEYDOWN)
845 switch (pMsg->wParam)
847 case 'A':
849 if (GetAsyncKeyState(VK_CONTROL)&0x8000)
851 // select all entries
852 for (int i=0; i<m_cFileList.GetItemCount(); ++i)
854 m_cFileList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
856 return TRUE;
859 break;
860 case 'C':
861 case VK_INSERT:
863 if (GetAsyncKeyState(VK_CONTROL)&0x8000)
865 CopySelectionToClipboard();
866 return TRUE;
869 break;
870 case '\r':
872 if (GetFocus() == GetDlgItem(IDC_FILELIST))
874 // Return pressed in file list. Show diff, as for double click
875 int selIndex = m_cFileList.GetSelectionMark();
876 if ((selIndex >= 0) && (selIndex < (int)m_arFileList.GetCount()))
877 DoDiff(selIndex, m_bBlame);
878 return TRUE;
881 break;
882 case VK_F5:
884 OnTimer(IDT_INPUT);
886 break;
889 return __super::PreTranslateMessage(pMsg);
892 void CFileDiffDlg::OnCancel()
894 if (m_bThreadRunning)
896 m_bCancelled = true;
897 return;
899 __super::OnCancel();
902 void CFileDiffDlg::OnHdnItemclickFilelist(NMHDR *pNMHDR, LRESULT *pResult)
904 LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
905 if (m_bThreadRunning)
906 return;
908 if (m_nSortedColumn == phdr->iItem)
909 m_bAscending = !m_bAscending;
910 else
911 m_bAscending = TRUE;
912 m_nSortedColumn = phdr->iItem;
913 Sort();
915 CString temp;
916 m_cFileList.SetRedraw(FALSE);
917 m_cFileList.DeleteAllItems();
918 m_cFilter.GetWindowText(temp);
919 Filter(temp);
921 CHeaderCtrl * pHeader = m_cFileList.GetHeaderCtrl();
922 HDITEM HeaderItem = {0};
923 HeaderItem.mask = HDI_FORMAT;
924 for (int i=0; i<pHeader->GetItemCount(); ++i)
926 pHeader->GetItem(i, &HeaderItem);
927 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);
928 pHeader->SetItem(i, &HeaderItem);
930 pHeader->GetItem(m_nSortedColumn, &HeaderItem);
931 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);
932 pHeader->SetItem(m_nSortedColumn, &HeaderItem);
934 m_cFileList.SetRedraw(TRUE);
936 *pResult = 0;
939 void CFileDiffDlg::Sort()
941 if(m_arFileList.GetCount() < 2)
943 return;
946 std::sort(m_arFileList.m_paths.begin(), m_arFileList.m_paths.end(), &CFileDiffDlg::SortCompare);
949 bool CFileDiffDlg::SortCompare(const CTGitPath& Data1, const CTGitPath& Data2)
951 int result = 0;
952 int d1, d2;
953 switch (m_nSortedColumn)
955 case 0: //path column
956 result = Data1.GetWinPathString().Compare(Data2.GetWinPathString());
957 break;
958 case 1: //extension column
959 result = Data1.GetFileExtension().Compare(Data2.GetFileExtension());
960 break;
961 case 2: //action column
962 result = Data1.m_Action - Data2.m_Action;
963 break;
964 case 3:
965 d1 = CSorter::A2L(Data1.m_StatAdd);
966 d2 = CSorter::A2L(Data2.m_StatAdd);
967 result = d1 - d2;
968 break;
969 case 4:
970 d1 = CSorter::A2L(Data1.m_StatDel);;
971 d2 = CSorter::A2L(Data2.m_StatDel);
972 result = d1 - d2;
973 break;
974 default:
975 break;
977 // sort by path name as second priority
978 if (m_nSortedColumn != 0 && result == 0)
979 result = Data1.GetWinPathString().Compare(Data2.GetWinPathString());
981 if (!m_bAscending)
982 result = -result;
983 return result < 0;
987 void CFileDiffDlg::OnBnClickedRev1btn()
989 ClickRevButton(&this->m_cRev1Btn,&this->m_rev1, &this->m_ctrRev1Edit);
992 void CFileDiffDlg::ClickRevButton(CMenuButton *button, GitRev *rev, CACEdit *edit)
994 INT_PTR entry=button->GetCurrentEntry();
995 if(entry == 0) /* Browse Refence*/
998 CString str = CBrowseRefsDlg::PickRef();
999 if(str.IsEmpty())
1000 return;
1002 if(FillRevFromString(rev,str))
1003 return;
1005 edit->SetWindowText(str);
1009 if(entry == 1) /*Log*/
1011 CLogDlg dlg;
1012 dlg.SetSelect(true);
1013 if(dlg.DoModal() == IDOK)
1015 if( dlg.GetSelectedHash().IsEmpty() )
1016 return;
1018 if(FillRevFromString(rev,dlg.GetSelectedHash()))
1019 return;
1021 edit->SetWindowText(dlg.GetSelectedHash());
1024 else
1025 return;
1028 if(entry == 2) /*RefLog*/
1030 CRefLogDlg dlg;
1031 if(dlg.DoModal() == IDOK)
1033 if(FillRevFromString(rev,dlg.m_SelectedHash))
1034 return;
1036 edit->SetWindowText(dlg.m_SelectedHash);
1039 else
1040 return;
1043 SetURLLabels();
1045 InterlockedExchange(&m_bThreadRunning, TRUE);
1046 if (AfxBeginThread(DiffThreadEntry, this)==NULL)
1048 InterlockedExchange(&m_bThreadRunning, FALSE);
1049 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
1051 KillTimer(IDT_INPUT);
1054 void CFileDiffDlg::OnBnClickedRev2btn()
1056 ClickRevButton(&this->m_cRev2Btn,&this->m_rev2, &this->m_ctrRev2Edit);
1059 LRESULT CFileDiffDlg::OnClickedCancelFilter(WPARAM /*wParam*/, LPARAM /*lParam*/)
1061 if (m_bThreadRunning)
1063 SetTimer(IDT_FILTER, 1000, NULL);
1064 return 0L;
1067 KillTimer(IDT_FILTER);
1069 m_cFileList.SetRedraw(FALSE);
1070 m_arFilteredList.clear();
1071 m_cFileList.DeleteAllItems();
1073 Filter(_T(""));
1075 m_cFileList.SetRedraw(TRUE);
1076 return 0L;
1079 void CFileDiffDlg::OnEnChangeFilter()
1081 SetTimer(IDT_FILTER, 1000, NULL);
1084 void CFileDiffDlg::OnTimer(UINT_PTR nIDEvent)
1086 if (m_bThreadRunning)
1087 return;
1089 if( nIDEvent == IDT_FILTER)
1091 CString sFilterText;
1092 KillTimer(IDT_FILTER);
1093 m_cFilter.GetWindowText(sFilterText);
1095 m_cFileList.SetRedraw(FALSE);
1096 m_cFileList.DeleteAllItems();
1098 Filter(sFilterText);
1100 m_cFileList.SetRedraw(TRUE);
1102 __super::OnTimer(nIDEvent);
1105 if( nIDEvent == IDT_INPUT)
1107 KillTimer(IDT_INPUT);
1108 TRACE(_T("Input Timer\r\n"));
1110 GitRev gitrev;
1111 CString str;
1112 int mask = 0;
1113 this->m_ctrRev1Edit.GetWindowText(str);
1116 if (!gitrev.GetCommit(str))
1118 m_rev1 = gitrev;
1119 mask |= 0x1;
1122 catch (const char *msg)
1124 CMessageBox::Show(m_hWnd, _T("Could not get commit ") + str + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
1127 this->m_ctrRev2Edit.GetWindowText(str);
1131 if (!gitrev.GetCommit(str))
1133 m_rev2 = gitrev;
1134 mask |= 0x2;
1137 catch (const char *msg)
1139 CMessageBox::Show(m_hWnd, _T("Could not get commit ") + str + _T("\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR);
1142 this->SetURLLabels(mask);
1144 if(mask == 0x3)
1147 InterlockedExchange(&m_bThreadRunning, TRUE);
1148 if (AfxBeginThread(DiffThreadEntry, this)==NULL)
1150 InterlockedExchange(&m_bThreadRunning, FALSE);
1151 CMessageBox::Show(NULL, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
1157 void CFileDiffDlg::Filter(CString sFilterText)
1159 sFilterText.MakeLower();
1161 m_arFilteredList.clear();
1163 for (int i=0;i<m_arFileList.GetCount();i++)
1165 CString sPath = m_arFileList[i].GetGitPathString();
1166 sPath.MakeLower();
1167 if (sPath.Find(sFilterText) >= 0)
1169 m_arFilteredList.push_back((CTGitPath*)&(m_arFileList[i]));
1172 for (std::vector<CTGitPath*>::const_iterator it = m_arFilteredList.begin(); it != m_arFilteredList.end(); ++it)
1174 AddEntry(*it);
1178 void CFileDiffDlg::CopySelectionToClipboard(BOOL isFull)
1180 // copy all selected paths to the clipboard
1181 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
1182 int index;
1183 CString sTextForClipboard;
1184 while ((index = m_cFileList.GetNextSelectedItem(pos)) >= 0)
1186 sTextForClipboard += m_cFileList.GetItemText(index, 0);
1187 sTextForClipboard += _T("\t");
1189 if(!isFull)
1191 sTextForClipboard += _T("\r\n");
1194 else
1196 sTextForClipboard += m_cFileList.GetItemText(index, 1);
1197 sTextForClipboard += _T("\t");
1198 sTextForClipboard += m_cFileList.GetItemText(index, 2);
1199 sTextForClipboard += _T("\t");
1200 sTextForClipboard += m_cFileList.GetItemText(index, 3);
1201 sTextForClipboard += _T("\t");
1202 sTextForClipboard += m_cFileList.GetItemText(index, 4);
1203 sTextForClipboard += _T("\r\n");
1206 CStringUtils::WriteAsciiStringToClipboard(sTextForClipboard);
1210 LRESULT CFileDiffDlg::OnRefLoad(WPARAM /*wParam*/, LPARAM /*lParam*/)
1212 for(int i=0;i<m_Reflist.size();i++)
1214 CString str=m_Reflist[i];
1216 if(str.Find(_T("remotes/")) == 0)
1217 str=str.Mid(8);
1219 m_ctrRev1Edit.AddSearchString(str);
1220 m_ctrRev2Edit.AddSearchString(str);
1222 return 0;
1225 BOOL CFileDiffDlg::DestroyWindow()
1227 return CResizableStandAloneDialog::DestroyWindow();
1230 LRESULT CFileDiffDlg::OnEnUpdate(WPARAM /*wParam*/, LPARAM lParam)
1232 if(lParam == IDC_REV1EDIT)
1234 OnTextUpdate(&this->m_ctrRev1Edit);
1235 ClearURLabels(1);
1237 if(lParam == IDC_REV2EDIT)
1239 OnTextUpdate(&this->m_ctrRev2Edit);
1240 ClearURLabels(1<<1);
1242 return 0;
1245 void CFileDiffDlg::OnTextUpdate(CACEdit * /*pEdit*/)
1247 SetTimer(IDT_INPUT, 1000, NULL);
1248 this->m_cFileList.ShowText(_T("Wait For input validate version"));
1251 int CFileDiffDlg::RevertSelectedItemToVersion(CString rev)
1253 if (rev.IsEmpty() || rev == GIT_REV_ZERO)
1254 return 0;
1256 POSITION pos = m_cFileList.GetFirstSelectedItemPosition();
1257 int index;
1258 int count = 0;
1259 while ((index = m_cFileList.GetNextSelectedItem(pos)) >= 0)
1261 CString cmd, out;
1262 CTGitPath *fentry = (CTGitPath *)m_arFilteredList[index];
1263 cmd.Format(_T("git.exe checkout %s -- \"%s\""), rev, fentry->GetGitPathString());
1264 if (g_Git.Run(cmd, &out, CP_UTF8))
1266 if (CMessageBox::Show(NULL, out, _T("TortoiseGit"), 2, IDI_WARNING, CString(MAKEINTRESOURCE(IDS_IGNOREBUTTON)), CString(MAKEINTRESOURCE(IDS_ABORTBUTTON))) == 2)
1267 break;
1269 else
1270 count++;
1273 CString out;
1274 out.Format(IDS_STATUSLIST_FILESREVERTED, count, rev);
1275 CMessageBox::Show(NULL, out, _T("TortoiseGit"), MB_OK);
1276 return 0;
1279 void CFileDiffDlg::OnBnClickedLog()
1281 CLogDlg dlg;
1282 dlg.SetRange(m_rev2.m_CommitHash.ToString() + _T("..") + m_rev1.m_CommitHash.ToString());
1283 dlg.DoModal();