From 984788d592c306040392c9d40e75923a97b82cb5 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 29 Dec 2015 02:11:50 +0100 Subject: [PATCH] Add support for rebase.autostash Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/TortoiseProc/AppUtils.cpp | 8 +++++--- src/TortoiseProc/AppUtils.h | 8 +++++++- src/TortoiseProc/ChangedDlg.cpp | 2 +- src/TortoiseProc/Commands/StashCommand.cpp | 2 +- src/TortoiseProc/RebaseDlg.cpp | 7 ++++--- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index 3feeb9dbc..6f5642de0 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -19,6 +19,7 @@ Released: unreleased * Fixed issue #2673: Display tracked remote URL in folder properties * Fixed issue #2630: TGitBlame: Allow to blame files of different working trees w/o restarting * Fixed issue #2679: Unnecessary horizontal scrollbar is shown in case logwidthmarker is set + * Rebase dialog now honors rebase.autostash=true == Bug Fixes == * Fixed issue #2647: TortoiseGitBlame does not display files correctly with mixed line endings (such as CRCRLF) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index dd41e0f04..e1038c04b 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -207,7 +207,7 @@ bool CAppUtils::StashApply(CString ref, bool showChanges /* true */) return false; } -bool CAppUtils::StashPop(bool showChanges /* true */) +bool CAppUtils::StashPop(int showChanges /* = 1 */) { CString cmd,out; cmd=_T("git.exe stash pop "); @@ -235,7 +235,7 @@ bool CAppUtils::StashPop(bool showChanges /* true */) message.LoadString(IDS_PROC_STASHPOPSUCCESS); if (hasConflicts) message.LoadString(IDS_PROC_STASHPOPFAILEDCONFLICTS); - if (showChanges) + if (showChanges == 1 || (showChanges == 0 && hasConflicts)) { if(CMessageBox::Show(NULL,CString(message + _T("\n") + CString(MAKEINTRESOURCE(IDS_SEECHANGES))) ,_T("TortoiseGit"),MB_YESNO|MB_ICONINFORMATION) == IDYES) @@ -246,11 +246,13 @@ bool CAppUtils::StashPop(bool showChanges /* true */) } return true; } - else + else if (showChanges > 1) { CMessageBox::Show(NULL, message ,_T("TortoiseGit"), MB_OK | MB_ICONINFORMATION); return true; } + else if (showChanges == 0) + return true; } return false; } diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index abd4b7e6c..d55f46b67 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -167,7 +167,13 @@ public: static CString GetMergeTempFile(const CString& str, const CTGitPath& merge); static bool StashSave(const CString& msg = CString(), bool showPull = false, bool pullShowPush = false, bool showMerge = false, const CString& mergeRev = CString()); static bool StashApply(CString ref, bool showChanges = true); - static bool StashPop(bool showChanges = true); + /** Execute "stash pop" + * showChanges + * 0: only show info on error (and allow to diff on error) + * 1: allow to open diff dialog on error or success + * 2: only show error or success message + */ + static bool StashPop(int showChanges = 1); static bool IsSSHPutty(); diff --git a/src/TortoiseProc/ChangedDlg.cpp b/src/TortoiseProc/ChangedDlg.cpp index 8c77bde73..99316a027 100644 --- a/src/TortoiseProc/ChangedDlg.cpp +++ b/src/TortoiseProc/ChangedDlg.cpp @@ -409,7 +409,7 @@ void CChangedDlg::OnBnClickedStash() CAppUtils::StashSave(); break; case ID_STASH_POP: - CAppUtils::StashPop(false); + CAppUtils::StashPop(2); break; case ID_STASH_APPLY: CAppUtils::StashApply(_T(""), false); diff --git a/src/TortoiseProc/Commands/StashCommand.cpp b/src/TortoiseProc/Commands/StashCommand.cpp index 4388d9008..0efce93e1 100644 --- a/src/TortoiseProc/Commands/StashCommand.cpp +++ b/src/TortoiseProc/Commands/StashCommand.cpp @@ -35,5 +35,5 @@ bool StashApplyCommand::Execute() bool StashPopCommand::Execute() { - return !CAppUtils::StashPop(true); + return !CAppUtils::StashPop(); } diff --git a/src/TortoiseProc/RebaseDlg.cpp b/src/TortoiseProc/RebaseDlg.cpp index 6698e5511..ce17de7d7 100644 --- a/src/TortoiseProc/RebaseDlg.cpp +++ b/src/TortoiseProc/RebaseDlg.cpp @@ -825,7 +825,7 @@ int CRebaseDlg::CheckRebaseCondition() if( !g_Git.CheckCleanWorkTree() ) { - if (CMessageBox::Show(NULL, IDS_ERROR_NOCLEAN_STASH, IDS_APPNAME, 1, IDI_QUESTION, IDS_STASHBUTTON, IDS_ABORTBUTTON) == 1) + if ((!m_IsCherryPick && g_Git.GetConfigValueBool(L"rebase.autostash")) || CMessageBox::Show(NULL, IDS_ERROR_NOCLEAN_STASH, IDS_APPNAME, 1, IDI_QUESTION, IDS_STASHBUTTON, IDS_ABORTBUTTON) == 1) { CString cmd,out; cmd=_T("git.exe stash"); @@ -852,8 +852,9 @@ int CRebaseDlg::CheckRebaseCondition() void CRebaseDlg::CheckRestoreStash() { - if (m_bStashed && CMessageBox::Show(nullptr, IDS_DCOMMIT_STASH_POP, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION) == IDYES) - CAppUtils::StashPop(); + bool autoStash = !m_IsCherryPick && g_Git.GetConfigValueBool(L"rebase.autostash"); + if (m_bStashed && (autoStash || CMessageBox::Show(nullptr, IDS_DCOMMIT_STASH_POP, IDS_APPNAME, MB_YESNO | MB_ICONQUESTION) == IDYES)) + CAppUtils::StashPop(autoStash ? 0 : 1); m_bStashed = false; } -- 2.11.4.GIT