From cec5726c8cd8816425c9346b9886c22bd4b49243 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 2 Aug 2016 07:26:08 +0200 Subject: [PATCH] Try to find stale rebase lock file and allow user to clean it Signed-off-by: Sven Strickroth --- Languages/Tortoise.pot | 8 ++++++++ src/Resources/TortoiseProcENG.rc | 2 ++ src/TortoiseProc/AppUtils.cpp | 23 +++++++++++++++++++++++ src/TortoiseProc/AppUtils.h | 2 ++ src/TortoiseProc/RebaseDlg.cpp | 2 ++ src/TortoiseProc/resource.h | 2 ++ 6 files changed, 39 insertions(+) diff --git a/Languages/Tortoise.pot b/Languages/Tortoise.pot index 350e594d2..47d1c63c9 100644 --- a/Languages/Tortoise.pot +++ b/Languages/Tortoise.pot @@ -4793,6 +4793,10 @@ msgstr "" msgid "Forward %d" msgstr "" +#. Resource IDs: (IDS_REBASELOCKFILEFOUND) +msgid "Found a lock file indicating that a TortoiseGit rebase process is running. This blocks this operation.\n\nIf you are not runnig a TortoiseGit rebase process right now, you can remove the stale lock file in order to continue." +msgstr "" + #. Resource IDs: (IDS_PROC_REBASE_EMPTYCOMMITMSG) msgid "Found an empty commit message. You have to enter one or rebase cannot proceed." msgstr "" @@ -7724,6 +7728,10 @@ msgstr "" msgid "Remove ignored files (-fX)" msgstr "" +#. Resource IDs: (IDS_REMOVESTALEBUTTON) +msgid "Remove stale lock file" +msgstr "" + #. Resource IDs: (Dialog IDD_CLEAN: Control id 1626) msgid "Remove untracked directories (-d)" msgstr "" diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index a54d76050..0136a810c 100644 --- a/src/Resources/TortoiseProcENG.rc +++ b/src/Resources/TortoiseProcENG.rc @@ -3614,6 +3614,7 @@ BEGIN IDS_REPOBROWSE_SAVEAS "Save &as..." IDS_REPOBROWSE_SHOWLOG "Show &log" IDS_REPOBROWSE_OPEN "&Open" + IDS_REBASELOCKFILEFOUND "Found a lock file indicating that a TortoiseGit rebase process is running. This blocks this operation.\n\nIf you are not runnig a TortoiseGit rebase process right now, you can remove the stale lock file in order to continue." END STRINGTABLE @@ -4746,6 +4747,7 @@ BEGIN IDS_NOTYET_SETTRACKEDBRANCH "For the current branch ""%s"" no tracked branch is configured.\nDo you want to set the selected branch ""%s"" as tracked branch?\nThis will automatically select it for push and pull in the future." IDS_PROC_DIFF_BASE "Base" + IDS_REMOVESTALEBUTTON "Remove stale lock file" END #endif // English (U.S.) resources diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 003629dae..d7177c25b 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -2347,6 +2347,9 @@ int CAppUtils::SaveCommitUnicodeFile(const CString& filename, CString &message) bool CAppUtils::Pull(bool showPush, bool showStashPop) { + if (IsTGitRebaseActive()) + return false; + CPullFetchDlg dlg; dlg.m_IsPull = TRUE; if (dlg.DoModal() == IDOK) @@ -3138,6 +3141,9 @@ BOOL CAppUtils::Merge(const CString* commit, bool showStashPop) if (!CheckUserData()) return FALSE; + if (IsTGitRebaseActive()) + return FALSE; + CMergeDlg dlg; if(commit) dlg.m_initialRefName = *commit; @@ -3719,3 +3725,20 @@ bool CAppUtils::ShowOpenWithDialog(const CString& file, HWND hwnd /*= nullptr */ oi.oaifInFlags = OAIF_EXEC; return SUCCEEDED(SHOpenWithDialog(hwnd, &oi)); } + +bool CAppUtils::IsTGitRebaseActive() +{ + CString adminDir; + if (!GitAdminDir::GetAdminDirPath(g_Git.m_CurrentDir, adminDir)) + return false; + + if (!PathIsDirectory(adminDir + L"tgitrebase.active")) + return false; + + if (CMessageBox::Show(nullptr, IDS_REBASELOCKFILEFOUND, IDS_APPNAME, 2, IDI_EXCLAMATION, IDS_REMOVESTALEBUTTON, IDS_ABORTBUTTON) == 2) + return true; + + RemoveDirectory(adminDir + L"tgitrebase.active"); + + return false; +} diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index c666eb6fd..c157d91ea 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -237,6 +237,8 @@ public: static int ResolveConflict(CTGitPath& path, resolve_with resolveWith); + static bool IsTGitRebaseActive(); + private: static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2); diff --git a/src/TortoiseProc/RebaseDlg.cpp b/src/TortoiseProc/RebaseDlg.cpp index 3f3d688ce..32a4674df 100644 --- a/src/TortoiseProc/RebaseDlg.cpp +++ b/src/TortoiseProc/RebaseDlg.cpp @@ -1119,6 +1119,8 @@ void CRebaseDlg::OnBnClickedContinue() { if (CheckRebaseCondition()) return; + if (CAppUtils::IsTGitRebaseActive()) + return; } if( this->m_IsFastForward ) diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index 2a86258f2..e3d984457 100644 --- a/src/TortoiseProc/resource.h +++ b/src/TortoiseProc/resource.h @@ -1265,6 +1265,7 @@ #define IDS_NOTYET_SETTRACKEDBRANCH 1597 #define IDS_PROC_DIFF_BASE 1598 #define IDC_BUGTRAQ_URL 1599 +#define IDS_REMOVESTALEBUTTON 1599 #define IDS_REPOBROWSE_SAVEAS 1600 #define IDC_BUGTRAQ_MESSAGE 1600 #define IDS_REPOBROWSE_SHOWLOG 1601 @@ -1273,6 +1274,7 @@ #define IDC_LANGCOMBO 1602 #define IDC_CLONE_GROUP_SVN 1603 #define IDC_CHECK_PRUNE 1603 +#define IDS_REBASELOCKFILEFOUND 1603 #define IDC_CHECK_SVN 1604 #define IDC_CHECK_SVN_TRUNK 1605 #define IDC_EDIT_SVN_TRUNK 1606 -- 2.11.4.GIT