For git > 2.1, pass --date=now when amending commit with author date reset
[TortoiseGit.git] / src / TortoiseProc / StashSave.cpp
bloba782a882109e2bd44d8533a61fc6a418cebaac86
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011-2015 - TortoiseGit
4 // Copyright (C) 2011-2013 Sven Strickroth, <email@cs-ware.de>
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.
21 #include "stdafx.h"
22 #include "TortoiseProc.h"
23 #include "StashSave.h"
24 #include "AppUtils.h"
25 #include "MessageBox.h"
26 #include "Git.h"
28 IMPLEMENT_DYNAMIC(CStashSaveDlg, CHorizontalResizableStandAloneDialog)
30 CStashSaveDlg::CStashSaveDlg(CWnd* pParent /*=NULL*/)
31 : CHorizontalResizableStandAloneDialog(CStashSaveDlg::IDD, pParent)
32 , m_bIncludeUntracked(FALSE)
33 , m_bAll(FALSE)
37 CStashSaveDlg::~CStashSaveDlg()
41 void CStashSaveDlg::DoDataExchange(CDataExchange* pDX)
43 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX);
44 DDX_Text(pDX, IDC_STASHMESSAGE, m_sMessage);
45 DDX_Check(pDX, IDC_CHECK_UNTRACKED, m_bIncludeUntracked);
46 DDX_Check(pDX, IDC_CHECK_ALL, m_bAll);
49 BEGIN_MESSAGE_MAP(CStashSaveDlg, CHorizontalResizableStandAloneDialog)
50 ON_BN_CLICKED(IDOK, &CStashSaveDlg::OnBnClickedOk)
51 ON_BN_CLICKED(IDC_CHECK_UNTRACKED, &CStashSaveDlg::OnBnClickedCheckUntracked)
52 ON_BN_CLICKED(IDC_CHECK_ALL, &CStashSaveDlg::OnBnClickedCheckAll)
53 END_MESSAGE_MAP()
55 BOOL CStashSaveDlg::OnInitDialog()
57 CHorizontalResizableStandAloneDialog::OnInitDialog();
58 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
60 AddAnchor(IDOK,BOTTOM_RIGHT);
61 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
62 AddAnchor(IDHELP, BOTTOM_RIGHT);
63 AddAnchor(IDC_GROUP_STASHMESSAGE, TOP_LEFT, TOP_RIGHT);
64 AddAnchor(IDC_STASHMESSAGE, TOP_LEFT, TOP_RIGHT);
65 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
67 AdjustControlSize(IDC_CHECK_UNTRACKED);
68 AdjustControlSize(IDC_CHECK_ALL);
70 CString sWindowTitle;
71 GetWindowText(sWindowTitle);
72 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
74 this->UpdateData(false);
76 if (CAppUtils::GetMsysgitVersion() < 0x01070700)
78 GetDlgItem(IDC_CHECK_UNTRACKED)->EnableWindow(FALSE);
79 GetDlgItem(IDC_CHECK_ALL)->EnableWindow(FALSE);
82 return TRUE;
85 void CStashSaveDlg::OnBnClickedOk()
87 CHorizontalResizableStandAloneDialog::UpdateData(TRUE);
89 if (m_bIncludeUntracked)
91 if (CMessageBox::ShowCheck(GetSafeHwnd(), IDS_STASHSAVE_INCLUDEUNTRACKED, IDS_APPNAME, 2, IDI_WARNING, IDS_CONTINUEBUTTON, IDS_ABORTBUTTON, NULL, _T("NoStashIncludeUntrackedWarning"), IDS_PROC_NOTSHOWAGAINCONTINUE) == 2)
93 CMessageBox::RemoveRegistryKey(_T("NoStashIncludeUntrackedWarning")); // only store answer if it is "Continue"
94 return;
98 CHorizontalResizableStandAloneDialog::OnOK();
101 void CStashSaveDlg::OnBnClickedCheckUntracked()
103 UpdateData();
104 DialogEnableWindow(IDC_CHECK_ALL, !m_bIncludeUntracked);
107 void CStashSaveDlg::OnBnClickedCheckAll()
109 UpdateData();
110 DialogEnableWindow(IDC_CHECK_UNTRACKED, !m_bAll);