From 2f5d527ffbf470bcbf11ab3af0f6eb0b7f4b3071 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Wed, 6 Feb 2019 22:22:20 +0100 Subject: [PATCH] Fix viewing and resolving conflicts of a submodule with a git-link-file containing a relative path The relative git path of the submodule was passed to GitAdminDir::ReadGitLink, then a relative path in the .git file caused a wrong path to the adminDir to be generated. Regression of commit b338858dd98c1a391aa1ec2a5e105fd94c94bced. Signed-off-by: Sven Strickroth --- src/TortoiseProc/AppUtils.cpp | 20 ++++++++++++-------- src/TortoiseProc/GitDiff.cpp | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index c0273f3b1..507e23614 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -1796,10 +1796,12 @@ bool CAppUtils::ConflictEdit(HWND hWnd, CTGitPath& path, bool bAlternativeTool / if (!baseIsFile || !localIsFile || !remoteIsFile) { - if (merge.HasAdminDir()) + CTGitPath fullMergePath; + fullMergePath.SetFromWin(g_Git.CombinePath(merge)); + if (fullMergePath.HasAdminDir()) { CGit subgit; - subgit.m_CurrentDir = g_Git.CombinePath(merge); + subgit.m_CurrentDir = fullMergePath.GetWinPath(); CGitHash hash; subgit.GetHash(hash, L"HEAD"); baseHash = hash.ToString(); @@ -1810,10 +1812,10 @@ bool CAppUtils::ConflictEdit(HWND hWnd, CTGitPath& path, bool bAlternativeTool / bool baseOK = false, mineOK = false, theirsOK = false; CString baseSubject, mineSubject, theirsSubject; - if (merge.HasAdminDir()) + if (fullMergePath.HasAdminDir()) { CGit subgit; - subgit.m_CurrentDir = g_Git.CombinePath(merge); + subgit.m_CurrentDir = fullMergePath.GetWinPath(); CGitDiff::GetSubmoduleChangeType(subgit, baseHash, localHash, baseOK, mineOK, changeTypeMine, baseSubject, mineSubject); CGitDiff::GetSubmoduleChangeType(subgit, baseHash, remoteHash, baseOK, theirsOK, changeTypeTheirs, baseSubject, theirsSubject); } @@ -3686,10 +3688,12 @@ int CAppUtils::ResolveConflict(HWND hWnd, CTGitPath& path, resolve_with resolveW { if (!willBeFile) { - if (!path.HasAdminDir()) // check if submodule is initialized + CTGitPath fullPath; + fullPath.SetFromWin(g_Git.CombinePath(path)); + if (!fullPath.HasAdminDir()) // check if submodule is initialized { CString gitcmd, output; - if (!path.IsDirectory()) + if (!fullPath.IsDirectory()) { gitcmd.Format(L"git.exe checkout-index -f --stage=%d -- \"%s\"", stage, (LPCTSTR)path.GetGitPathString()); if (g_Git.Run(gitcmd, &output, CP_UTF8)) @@ -3708,7 +3712,7 @@ int CAppUtils::ResolveConflict(HWND hWnd, CTGitPath& path, resolve_with resolveW } CGit subgit; - subgit.m_CurrentDir = g_Git.CombinePath(path); + subgit.m_CurrentDir = fullPath.GetWinPath(); CGitHash submoduleHead; if (subgit.GetHash(submoduleHead, L"HEAD")) { @@ -3718,7 +3722,7 @@ int CAppUtils::ResolveConflict(HWND hWnd, CTGitPath& path, resolve_with resolveW if (submoduleHead.ToString() != hash) { CString origPath = g_Git.m_CurrentDir; - g_Git.m_CurrentDir = g_Git.CombinePath(path); + g_Git.m_CurrentDir = fullPath.GetWinPath(); SetCurrentDirectory(g_Git.m_CurrentDir); if (!GitReset(hWnd, &hash)) { diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 07ba46f46..feb378913 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2008 - TortoiseSVN -// Copyright (C) 2008-2018 - TortoiseGit +// Copyright (C) 2008-2019 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -257,7 +257,7 @@ int CGitDiff::SubmoduleDiff(HWND hWnd, const CTGitPath* pPath, const CTGitPath* subgit.m_CurrentDir = g_Git.CombinePath(pPath); ChangeType changeType = Unknown; - if (pPath->HasAdminDir()) + if (CTGitPath(subgit.m_CurrentDir).HasAdminDir()) GetSubmoduleChangeType(subgit, oldhash, newhash, oldOK, newOK, changeType, oldsub, newsub); CSubmoduleDiffDlg submoduleDiffDlg(GetExplorerHWND() == hWnd ? nullptr : CWnd::FromHandle(hWnd)); -- 2.11.4.GIT