From 4e65310335e4613e9bdba6702d938d4e149b0cfa Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Fri, 22 Jun 2012 02:38:26 +0200 Subject: [PATCH] Added CString wrapper for get_windows_home_directory() Signed-off-by: Sven Strickroth --- src/Git/Git.cpp | 13 ++++++++----- src/Git/Git.h | 1 + src/Git/GitIndex.cpp | 2 +- src/TortoiseProc/GitProgressDlg.cpp | 2 +- src/TortoiseProc/Settings/SettingGitConfig.cpp | 8 ++------ src/TortoiseProc/TortoiseProc.cpp | 8 ++------ 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index ad4e085ff..21eb0440f 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -1321,11 +1321,9 @@ BOOL CGit::CheckMsysGitDir() _tgetenv_s(&homesize, NULL, 0, _T("HOME")); if (!homesize) { - char charBuf[MAX_PATH]; - TCHAR buf[MAX_PATH]; - strcpy_s(charBuf, MAX_PATH, get_windows_home_directory()); - _tcscpy_s(buf, MAX_PATH, CA2CT(charBuf)); - m_Environment.SetEnv(_T("HOME"), buf); + CString home = g_Git.GetHomeDirectory(); + m_Environment.SetEnv(_T("HOME"), home.GetBuffer()); + home.ReleaseBuffer(); } CString str; @@ -1417,6 +1415,11 @@ BOOL CGit::CheckMsysGitDir() return true; } +CString CGit::GetHomeDirectory() +{ + return CString(get_windows_home_directory()); +} + BOOL CGit::CheckCleanWorkTree() { CString out; diff --git a/src/Git/Git.h b/src/Git/Git.h index df944dafb..8691c2992 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -142,6 +142,7 @@ public: BOOL CheckMsysGitDir(); BOOL m_bInitialized; + CString GetHomeDirectory(); static CString ms_LastMsysGitDir; // the last msysgitdir added to the path, blank if none static int m_LogEncode; static bool IsBranchNameValid(CString branchname); diff --git a/src/Git/GitIndex.cpp b/src/Git/GitIndex.cpp index 2b328b951..07e5b9cdb 100644 --- a/src/Git/GitIndex.cpp +++ b/src/Git/GitIndex.cpp @@ -1220,7 +1220,7 @@ bool CGitIgnoreList::CheckAndUpdateCoreExcludefile(const CString &adminDir) } const CString CGitIgnoreList::GetWindowsHome() { - static CString sWindowsHome(get_windows_home_directory()); + static CString sWindowsHome(g_Git.GetHomeDirectory()); return sWindowsHome; } bool CGitIgnoreList::IsIgnore(const CString &path,const CString &projectroot) diff --git a/src/TortoiseProc/GitProgressDlg.cpp b/src/TortoiseProc/GitProgressDlg.cpp index af0483fea..40ae5d409 100644 --- a/src/TortoiseProc/GitProgressDlg.cpp +++ b/src/TortoiseProc/GitProgressDlg.cpp @@ -1884,7 +1884,7 @@ bool CGitProgressDlg::CmdAdd(CString& sWindowTitle, bool& localoperation) return false; } projectConfigA.ReleaseBuffer(); - CString globalConfig = CString(get_windows_home_directory()) + _T("\\.gitconfig"); + CString globalConfig = g_Git.GetHomeDirectory() + _T("\\.gitconfig"); if (PathFileExists(globalConfig)) { CStringA globalConfigA = CUnicodeUtils::GetMulti(globalConfig, CP_UTF8); diff --git a/src/TortoiseProc/Settings/SettingGitConfig.cpp b/src/TortoiseProc/Settings/SettingGitConfig.cpp index e669417b4..9b1b492eb 100644 --- a/src/TortoiseProc/Settings/SettingGitConfig.cpp +++ b/src/TortoiseProc/Settings/SettingGitConfig.cpp @@ -224,13 +224,9 @@ void CSettingGitConfig::OnCbnSelchangeSafeCrLf() void CSettingGitConfig::OnBnClickedEditglobalgitconfig() { - char charBuf[MAX_PATH]; - TCHAR buf[MAX_PATH]; - strcpy_s(charBuf, MAX_PATH, get_windows_home_directory()); - _tcscpy_s(buf, MAX_PATH, CA2CT(charBuf)); - _tcscat_s(buf, MAX_PATH, _T("\\.gitconfig")); + CString filename = g_Git.GetHomeDirectory() + _T("\\.gitconfig"); // use alternative editor because of LineEndings - CAppUtils::LaunchAlternativeEditor(buf); + CAppUtils::LaunchAlternativeEditor(filename); } void CSettingGitConfig::OnBnClickedEditlocalgitconfig() diff --git a/src/TortoiseProc/TortoiseProc.cpp b/src/TortoiseProc/TortoiseProc.cpp index f17d25121..85f1170fc 100644 --- a/src/TortoiseProc/TortoiseProc.cpp +++ b/src/TortoiseProc/TortoiseProc.cpp @@ -446,12 +446,8 @@ BOOL CTortoiseProcApp::InitInstance() else if (choice == 2) { // open the global config file with alternative editor - char charBuf[MAX_PATH]; - TCHAR buf[MAX_PATH]; - strcpy_s(charBuf, MAX_PATH, get_windows_home_directory()); - _tcscpy_s(buf, MAX_PATH, CA2CT(charBuf)); - _tcscat_s(buf, MAX_PATH, _T("\\.gitconfig")); - CAppUtils::LaunchAlternativeEditor(buf); + CString filename = g_Git.GetHomeDirectory() + _T("\\.gitconfig"); + CAppUtils::LaunchAlternativeEditor(filename); } return FALSE; } -- 2.11.4.GIT