From 00cc5556dff04e1447362d62cec328fbf8de2570 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 3 Dec 2011 00:07:27 +0100 Subject: [PATCH] Fixed issue #801: Be able to enter a custom stash message Signed-off-by: Sven Strickroth --- doc/source/en/TortoiseGit/tsvn_dug/dug.xml | 1 + doc/source/en/TortoiseGit/tsvn_dug/dug_stash.xml | 23 +++++++ src/Changelog.txt | 1 + src/Resources/TortoiseProcENG.rc | 19 ++++++ src/TortoiseProc/AppUtils.cpp | 35 +++++++---- src/TortoiseProc/StashSave.cpp | 77 ++++++++++++++++++++++++ src/TortoiseProc/StashSave.h | 49 +++++++++++++++ src/TortoiseProc/TortoiseProc.vcproj | 8 +++ src/TortoiseProc/resource.h | 5 +- 9 files changed, 205 insertions(+), 13 deletions(-) create mode 100644 doc/source/en/TortoiseGit/tsvn_dug/dug_stash.xml create mode 100644 src/TortoiseProc/StashSave.cpp create mode 100644 src/TortoiseProc/StashSave.h diff --git a/doc/source/en/TortoiseGit/tsvn_dug/dug.xml b/doc/source/en/TortoiseGit/tsvn_dug/dug.xml index 0d31e64fb..8d39da646 100644 --- a/doc/source/en/TortoiseGit/tsvn_dug/dug.xml +++ b/doc/source/en/TortoiseGit/tsvn_dug/dug.xml @@ -88,6 +88,7 @@ + diff --git a/doc/source/en/TortoiseGit/tsvn_dug/dug_stash.xml b/doc/source/en/TortoiseGit/tsvn_dug/dug_stash.xml new file mode 100644 index 000000000..2cc890f9c --- /dev/null +++ b/doc/source/en/TortoiseGit/tsvn_dug/dug_stash.xml @@ -0,0 +1,23 @@ + + + + + Stash Changes + + stash + + + When you want to record the current state of the working directory and the index, + but want to go back to a clean working directory, + right click on a folder to pop up the context menu and then select + the command + + TortoiseGit + Stash Save + + A dialog will pop up where you can optionally enter a message for this state. + + + You can find more information at + + diff --git a/src/Changelog.txt b/src/Changelog.txt index fde474b00..b7b11d4b9 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -9,6 +9,7 @@ * Fixed issue #894: Make images "open with" TortoiseIDiff * Fixed issue #985: Store status for view patch in commit dialog * Fixed issue #977: Fetch does not have an option to fetch tags + * Fixed issue #801: Be able to enter a custom stash message == Bug Fix == * Fixed issue #747: TortoiseProc & less process not closing diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 2a91fff1e..0f8af79b8 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -1587,6 +1587,17 @@ BEGIN PUSHBUTTON "Help",IDHELP,255,44,50,14,WS_DISABLED END +IDD_STASH DIALOGEX 0, 0, 267, 66 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +CAPTION "Stash" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Stash &Message",IDC_GROUP_STASHMESSAGE,7,7,253,32 + EDITTEXT IDC_STASHMESSAGE,15,19,237,13,ES_AUTOHSCROLL + DEFPUSHBUTTON "OK",IDOK,99,45,50,14 + PUSHBUTTON "Cancel",IDCANCEL,154,45,50,14 + PUSHBUTTON "Help",IDHELP,210,45,50,14 +END ///////////////////////////////////////////////////////////////////////////// // @@ -2330,6 +2341,14 @@ BEGIN BOTTOMMARGIN, 58 HORZGUIDE, 25 END + + IDD_STASH, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 260 + TOPMARGIN, 7 + BOTTOMMARGIN, 59 + END END #endif // APSTUDIO_INVOKED diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 7473268df..fbad4ca03 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -57,6 +57,7 @@ #include "PullFetchDlg.h" #include "RebaseDlg.h" #include "PropKey.h" +#include "StashSave.h" CAppUtils::CAppUtils(void) { @@ -68,21 +69,31 @@ CAppUtils::~CAppUtils(void) bool CAppUtils::StashSave() { - bool bRet = false; - - CString cmd,out; - cmd=_T("git.exe stash"); + CStashSaveDlg dlg; - if(g_Git.Run(cmd,&out,CP_ACP)) - { - CMessageBox::Show(NULL,CString(_T("Stash Fail!!!\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONERROR); - } - else + if (dlg.DoModal() == IDOK) { - CMessageBox::Show(NULL,CString(_T("Stash Success\n"))+out,_T("TortoiseGit"),MB_OK|MB_ICONINFORMATION); - bRet = true; + CString cmd, out; + cmd = _T("git.exe stash save"); + + if (!dlg.m_sMessage.IsEmpty()) + { + CString message = dlg.m_sMessage; + message.Replace(_T("\""), _T("\"\"")); + cmd += _T(" \"") + message + _T("\""); + } + + if (g_Git.Run(cmd, &out, CP_ACP)) + { + CMessageBox::Show(NULL, CString(_T("Stash Fail!!!\n")) + out, _T("TortoiseGit"), MB_OK|MB_ICONERROR); + } + else + { + CMessageBox::Show(NULL, CString(_T("Stash Success\n")) + out, _T("TortoiseGit"), MB_OK | MB_ICONINFORMATION); + return true; + } } - return bRet; + return false; } int CAppUtils::StashApply(CString ref) diff --git a/src/TortoiseProc/StashSave.cpp b/src/TortoiseProc/StashSave.cpp new file mode 100644 index 000000000..cce74f13d --- /dev/null +++ b/src/TortoiseProc/StashSave.cpp @@ -0,0 +1,77 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2011 Sven Strickroth, + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// + +#include "stdafx.h" +#include "TortoiseProc.h" +#include "StashSave.h" +#include "AppUtils.h" + +IMPLEMENT_DYNAMIC(CStashSaveDlg, CHorizontalResizableStandAloneDialog) + +CStashSaveDlg::CStashSaveDlg(CWnd* pParent /*=NULL*/) + : CHorizontalResizableStandAloneDialog(CStashSaveDlg::IDD, pParent) +{ +} + +CStashSaveDlg::~CStashSaveDlg() +{ +} + +void CStashSaveDlg::DoDataExchange(CDataExchange* pDX) +{ + CHorizontalResizableStandAloneDialog::DoDataExchange(pDX); + DDX_Text(pDX, IDC_STASHMESSAGE, m_sMessage); +} + + +BEGIN_MESSAGE_MAP(CStashSaveDlg, CHorizontalResizableStandAloneDialog) + ON_BN_CLICKED(IDOK, &CStashSaveDlg::OnBnClickedOk) + ON_BN_CLICKED(IDHELP, &CStashSaveDlg::OnBnClickedHelp) +END_MESSAGE_MAP() + +BOOL CStashSaveDlg::OnInitDialog() +{ + CHorizontalResizableStandAloneDialog::OnInitDialog(); + CAppUtils::MarkWindowAsUnpinnable(m_hWnd); + + AddAnchor(IDOK,BOTTOM_RIGHT); + AddAnchor(IDCANCEL, BOTTOM_RIGHT); + AddAnchor(IDHELP, BOTTOM_RIGHT); + AddAnchor(IDC_GROUP_STASHMESSAGE, TOP_LEFT, TOP_RIGHT); + AddAnchor(IDC_STASHMESSAGE, TOP_LEFT, TOP_RIGHT); + + CString sWindowTitle; + GetWindowText(sWindowTitle); + CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle); + + this->UpdateData(false); + return TRUE; +} + +void CStashSaveDlg::OnBnClickedOk() +{ + CHorizontalResizableStandAloneDialog::UpdateData(TRUE); + + CHorizontalResizableStandAloneDialog::OnOK(); +} + +void CStashSaveDlg::OnBnClickedHelp() +{ + OnHelp(); +} diff --git a/src/TortoiseProc/StashSave.h b/src/TortoiseProc/StashSave.h new file mode 100644 index 000000000..2ed4cdf72 --- /dev/null +++ b/src/TortoiseProc/StashSave.h @@ -0,0 +1,49 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2011 Sven Strickroth, +// +// Based on PushDlg.cpp +// Copyright (C) 2003-2008 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// + +#pragma once + +#include "HorizontalResizableStandAloneDialog.h" + +class CStashSaveDlg : public CHorizontalResizableStandAloneDialog +{ + DECLARE_DYNAMIC(CStashSaveDlg) + +public: + CStashSaveDlg(CWnd* pParent = NULL); // standard constructor + virtual ~CStashSaveDlg(); + +// Dialog Data + enum { IDD = IDD_STASH }; + +protected: + virtual BOOL OnInitDialog(); + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + + afx_msg void OnBnClickedOk(); + afx_msg void OnBnClickedHelp(); + +public: + CString m_sMessage; +}; diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index 34fcd7108..24c865e1c 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -1948,6 +1948,14 @@ RelativePath=".\Commands\StashCommand.h" > + + + +