Fixed issue #1500: Support git merge --log option
[TortoiseGit.git] / src / TortoiseProc / MergeDlg.cpp
blob706c52b0d9ed5633298ca6434c70b9c661cbcccd
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-2013 - 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 // MergeDlg.cpp : implementation file
23 #include "stdafx.h"
25 #include "Git.h"
26 #include "TortoiseProc.h"
27 #include "MergeDlg.h"
28 #include "AppUtils.h"
30 #include "Messagebox.h"
31 // CMergeDlg dialog
33 IMPLEMENT_DYNAMIC(CMergeDlg, CResizableStandAloneDialog)
35 CMergeDlg::CMergeDlg(CWnd* pParent /*=NULL*/)
36 : CResizableStandAloneDialog(CMergeDlg::IDD, pParent),
37 CChooseVersion(this)
39 m_pDefaultText = MAKEINTRESOURCE(IDS_PROC_AUTOGENERATEDBYGIT);
40 m_bNoFF=false;
41 m_bSquash=false;
42 m_bNoCommit=false;
43 m_bLog = FALSE;
44 CString mergeLog = g_Git.GetConfigValue(_T("merge.log"));
45 int nLog = _ttoi(mergeLog);
46 m_nLog = nLog > 0 ? nLog : 20;
49 CMergeDlg::~CMergeDlg()
53 void CMergeDlg::DoDataExchange(CDataExchange* pDX)
55 CDialog::DoDataExchange(pDX);
57 CHOOSE_VERSION_DDX;
59 DDX_Check(pDX,IDC_CHECK_NOFF,this->m_bNoFF);
60 DDX_Check(pDX,IDC_CHECK_SQUASH,this->m_bSquash);
61 DDX_Check(pDX,IDC_CHECK_NOCOMMIT,this->m_bNoCommit);
62 DDX_Check(pDX, IDC_CHECK_MERGE_LOG, m_bLog);
63 DDX_Text(pDX, IDC_EDIT_MERGE_LOGNUM, m_nLog);
64 DDX_Control(pDX, IDC_LOGMESSAGE, m_cLogMessage);
68 BEGIN_MESSAGE_MAP(CMergeDlg, CResizableStandAloneDialog)
69 CHOOSE_VERSION_EVENT
70 ON_BN_CLICKED(IDOK, &CMergeDlg::OnBnClickedOk)
71 ON_WM_DESTROY()
72 ON_BN_CLICKED(IDC_CHECK_MERGE_LOG, &CMergeDlg::OnBnClickedCheckMergeLog)
73 END_MESSAGE_MAP()
76 BOOL CMergeDlg::OnInitDialog()
78 CResizableStandAloneDialog::OnInitDialog();
79 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
81 CHOOSE_VERSION_ADDANCHOR;
83 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
84 AddAnchor(IDC_STATIC_MERGE_MESSAGE,TOP_LEFT,BOTTOM_RIGHT);
85 AddAnchor(IDC_LOGMESSAGE,TOP_LEFT,BOTTOM_RIGHT);
87 AddAnchor(IDOK,BOTTOM_RIGHT);
88 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
89 AddAnchor(IDHELP, BOTTOM_RIGHT);
91 this->AddOthersToAnchor();
93 AdjustControlSize(IDC_RADIO_BRANCH);
94 AdjustControlSize(IDC_RADIO_TAGS);
95 AdjustControlSize(IDC_RADIO_VERSION);
96 AdjustControlSize(IDC_CHECK_SQUASH);
97 AdjustControlSize(IDC_CHECK_NOFF);
98 AdjustControlSize(IDC_CHECK_NOCOMMIT);
99 AdjustControlSize(IDC_CHECK_MERGE_LOG);
101 CheckRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION,IDC_RADIO_BRANCH);
102 this->SetDefaultChoose(IDC_RADIO_BRANCH);
104 CString sWindowTitle;
105 GetWindowText(sWindowTitle);
106 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
108 Init();
110 m_ProjectProperties.ReadProps(CTGitPath(g_Git.m_CurrentDir));
112 m_cLogMessage.Init(m_ProjectProperties);
113 m_cLogMessage.SetFont((CString)CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")), (DWORD)CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8));
114 m_cLogMessage.RegisterContextMenuHandler(this);
116 m_cLogMessage.SetText(m_pDefaultText);
118 EnableSaveRestore(_T("MergeDlg"));
119 GetDlgItem(IDOK)->SetFocus();
121 return FALSE;
124 // CMergeDlg message handlers
127 void CMergeDlg::OnBnClickedOk()
129 this->UpdateData(TRUE);
131 this->UpdateRevsionName();
133 this->m_strLogMesage = m_cLogMessage.GetText() ;
134 if( m_strLogMesage == CString(this->m_pDefaultText) )
136 m_strLogMesage.Empty();
139 OnOK();
142 void CMergeDlg::OnDestroy()
144 WaitForFinishLoading();
145 __super::OnDestroy();
148 void CMergeDlg::OnBnClickedCheckMergeLog()
150 UpdateData(TRUE);
151 GetDlgItem(IDC_EDIT_MERGE_LOGNUM)->EnableWindow(m_bLog);