From 228114f8bec1ded7028c8ff66ba011cdc42e23ba Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Tue, 2 Aug 2016 22:23:13 +0200 Subject: [PATCH] Make using alternative merge tool work by pressing the shift key Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/Git/GitStatusListCtrl.cpp | 2 +- src/TortoiseProc/AppUtils.cpp | 16 ++++++++++++---- src/TortoiseProc/AppUtils.h | 2 +- src/TortoiseShell/ContextMenu.cpp | 2 ++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index 2ca1c829e..49785c9d3 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -3,6 +3,7 @@ Released: unreleased == Features == * Fixed issue #2755: TortoiseGitMerge: find dialog box does not remember desktop location between invocations + * When an alternative/external diff or merge tool is configured, you can now press the shift key while opening the diff to fall back to TortoiseGitMerge == Bug Fixes == * Fixed issue #2789: Sync Dialog In ChangeList tab auto-resize column not optimal diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 6db330072..daad7dfbd 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -2792,7 +2792,7 @@ void CGitStatusListCtrl::StartDiff(int fileindex) CMessageBox::Show(GetSafeHwnd(), IDS_STATUSLIST_FAILEDGETBASEFILE, IDS_APPNAME, MB_OK | MB_ICONERROR); } } - CAppUtils::StartExtMerge(base, theirs, mine, merge,_T("BASE"),_T("REMOTE"),_T("LOCAL")); + CAppUtils::StartExtMerge(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000), base, theirs, mine, merge, L"BASE", L"REMOTE", L"LOCAL"); } else { diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index ccb556ab7..be1e6f7f1 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -248,7 +248,7 @@ bool CAppUtils::StashPop(int showChanges /* = 1 */) return false; } -BOOL CAppUtils::StartExtMerge( +BOOL CAppUtils::StartExtMerge(bool bAlternative, const CTGitPath& basefile, const CTGitPath& theirfile, const CTGitPath& yourfile, const CTGitPath& mergedfile, const CString& basename, const CString& theirname, const CString& yourname, const CString& mergedname, bool bReadOnly, HWND resolveMsgHwnd, bool bDeleteBaseTheirsMineOnClose) @@ -270,6 +270,14 @@ BOOL CAppUtils::StartExtMerge( if (!CString(mergetool).IsEmpty()) com = mergetool; + if (bAlternative && !com.IsEmpty()) + { + if (com.Left(1).Compare(L"#") == 0) + com.Delete(0); + else + com.Empty(); + } + if (com.IsEmpty()||(com.Left(1).Compare(_T("#"))==0)) { // Maybe we should use TortoiseIDiff? @@ -1650,7 +1658,7 @@ bool ParseHashesFromLsFile(const BYTE_VECTOR& out, CString& hash1, CString& hash return false; } -bool CAppUtils::ConflictEdit(const CTGitPath& path, bool /*bAlternativeTool = false*/, bool revertTheirMy /*= false*/, HWND resolveMsgHwnd /*= nullptr*/) +bool CAppUtils::ConflictEdit(const CTGitPath& path, bool bAlternativeTool /*= false*/, bool revertTheirMy /*= false*/, HWND resolveMsgHwnd /*= nullptr*/) { bool bRet = false; @@ -1821,9 +1829,9 @@ bool CAppUtils::ConflictEdit(const CTGitPath& path, bool /*bAlternativeTool = fa { merge.SetFromWin(g_Git.CombinePath(merge)); if( revertTheirMy ) - bRet = !!CAppUtils::StartExtMerge(base, mine, theirs, merge, _T("BASE"), _T("REMOTE"), _T("LOCAL"), CString(), false, resolveMsgHwnd, true); + bRet = !!CAppUtils::StartExtMerge(bAlternativeTool, base, mine, theirs, merge, L"BASE", L"REMOTE", L"LOCAL", CString(), false, resolveMsgHwnd, true); else - bRet = !!CAppUtils::StartExtMerge(base, theirs, mine, merge, _T("BASE"), _T("REMOTE"), _T("LOCAL"), CString(), false, resolveMsgHwnd, true); + bRet = !!CAppUtils::StartExtMerge(bAlternativeTool, base, theirs, mine, merge, L"BASE", L"REMOTE", L"LOCAL", CString(), false, resolveMsgHwnd, true); } else { diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 17b9ad8fa..e4aae246f 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -59,7 +59,7 @@ public: * Launches the external merge program if there is one. * \return TRUE if the program could be started */ - static BOOL StartExtMerge( + static BOOL StartExtMerge(bool bAlternativeTool, const CTGitPath& basefile, const CTGitPath& theirfile, const CTGitPath& yourfile, const CTGitPath& mergedfile, const CString& basename = CString(), const CString& theirname = CString(), const CString& yourname = CString(), const CString& mergedname = CString(), bool bReadOnly = false, HWND resolveMsgHwnd = nullptr, bool bDeleteBaseTheirsMineOnClose = false); diff --git a/src/TortoiseShell/ContextMenu.cpp b/src/TortoiseShell/ContextMenu.cpp index 0562cf68f..d9b1612a6 100644 --- a/src/TortoiseShell/ContextMenu.cpp +++ b/src/TortoiseShell/ContextMenu.cpp @@ -1450,6 +1450,8 @@ STDMETHODIMP CShellExt::InvokeCommand_Wrap(LPCMINVOKECOMMANDINFO lpcmi) break; case ShellMenuConflictEditor: AddPathCommand(gitCmd, L"conflicteditor", true); + if (GetAsyncKeyState(VK_SHIFT) & 0x8000) + gitCmd += L" /alternative"; break; case ShellMenuGitSVNRebase: AddPathCommand(gitCmd, L"svnrebase", false); -- 2.11.4.GIT