From 21b8f0b8a2182c70cf722b3c14a190fe66f8ee73 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sun, 15 Feb 2015 14:22:42 +0100 Subject: [PATCH] Fixed issue #56: Add Cygwin workarounds These have to be enabled manually. Please note that Cygwin Git is not officially supported by TortoiseGit. Thanks to ufo.pu55y. Signed-off-by: Sven Strickroth --- .../TortoiseGit/tgit_dug/dug_settings_advanced.xml | 10 +++++++++ .../TortoiseGit/tgit_dug/dug_settings_general.xml | 26 ++++++++++++++++++++++ src/Changelog.txt | 4 ++++ src/Git/Git.cpp | 14 ++++++++++-- src/Git/Git.h | 3 ++- src/Git/GitStatusListCtrl.cpp | 12 ++++++++++ src/TortoiseProc/AboutDlg.cpp | 9 ++++++-- src/TortoiseProc/Settings/SetMainPage.cpp | 2 ++ src/TortoiseProc/Settings/SettingsAdvanced.cpp | 4 ++++ 9 files changed, 79 insertions(+), 5 deletions(-) diff --git a/doc/source/en/TortoiseGit/tgit_dug/dug_settings_advanced.xml b/doc/source/en/TortoiseGit/tgit_dug/dug_settings_advanced.xml index 961e52e3e..8e30934bc 100644 --- a/doc/source/en/TortoiseGit/tgit_dug/dug_settings_advanced.xml +++ b/doc/source/en/TortoiseGit/tgit_dug/dug_settings_advanced.xml @@ -70,6 +70,16 @@ + CygwinHack + + + This enables some workarounds which enables TortoiseGit to be used wit Cygwin Git. + Cygwin Git, however, is not officially supported by TortoiseGit. + The default is false. + + + + Debug diff --git a/doc/source/en/TortoiseGit/tgit_dug/dug_settings_general.xml b/doc/source/en/TortoiseGit/tgit_dug/dug_settings_general.xml index 8a63ad627..f4c1eb3ca 100644 --- a/doc/source/en/TortoiseGit/tgit_dug/dug_settings_general.xml +++ b/doc/source/en/TortoiseGit/tgit_dug/dug_settings_general.xml @@ -10,6 +10,9 @@ git.exe path + Cygwin git + + Extern DLL Path @@ -100,6 +103,29 @@ + + Cygwin Git + + + There is no official support for Cygwin git in TortoiseGit. The TortoiseGit developers only use Git for Windows. Bugreports, however, are welcome. If you really want to use it here are the steps you have to perform: + + + 1) Select the [CYGWIN-INSTALL-PATH]\bin-folder as git.exe folder. + + + 2) Configure the HOME environment variable in Windows, so that Cygwin and TortoiseGit are using the same home directory and global git-config. Use the normal Windows notation here (e.g., "C:\Users\USERNAME"). By default, TortoiseGit uses the Windows home directory which is normally located under c:\Users and Cygwin uses its own home directories which are located under [CYGWIN-INSTALL-PATH]\home. + + + 3) Configure AutoCrLf, this is necessary as TortoiseGit and Cygwin Git have different defaults. The default in Cygwin Git is true. + + + 4) Go to TortoiseGit and set CygwinHack to true in order to activate cygwin workarounds. + + + 5) Reboot. + + + Context Menu Settings diff --git a/src/Changelog.txt b/src/Changelog.txt index dfaf57155..1ee20267f 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -19,6 +19,10 @@ Released: unreleased true, but can be disabled in cases where refreshing the list takes lots of time or people don't want the list to automatically scroll to the top (this also mitigates issue #1949 until we have a cleaner fix). F5 for manual refresh is needed if enabled. + * Fixed issue #56: Ability to use Cygwin's git instead of msysGit + Check out the manual (keyword "Gygwin git") regarding Cygwin Git support and configuration hints. + Please note that Cygwin Git is not officially supported by TortoiseGit as the developers only + use Git for Windows. Bugreports, however, are welcome. == Bug Fixes == * Fixed issue #2359: Selected files counter not updated after revert diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index 763ad5b4b..5fd6bf6f1 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -34,6 +34,7 @@ #include "../libgit2/filter-filter.h" #include "../libgit2/ssh-wintunnel.h" +bool CGit::ms_bCygwinGit = (CRegDWORD(_T("Software\\TortoiseGit\\CygwinHack"), FALSE) == TRUE); int CGit::m_LogEncode=CP_UTF8; typedef CComCritSecLock CAutoLocker; @@ -326,7 +327,13 @@ int CGit::RunAsync(CString cmd, PROCESS_INFORMATION *piOut, HANDLE *hReadOut, HA memset(&this->m_CurrentGitPi,0,sizeof(PROCESS_INFORMATION)); memset(&pi, 0, sizeof(PROCESS_INFORMATION)); - if(cmd.Find(_T("git")) == 0) + if (ms_bCygwinGit && cmd.Find(_T("git")) == 0) + { + cmd.Replace(_T('\\'), _T('/')); + cmd.Replace(_T("\""), _T("\\\"")); + cmd = _T('"') + CGit::ms_LastMsysGitDir + _T("\\bash.exe\" -c \"/bin/") + cmd + _T('"'); + } + else if(cmd.Find(_T("git")) == 0) { int firstSpace = cmd.Find(_T(" ")); if (firstSpace > 0) @@ -2067,7 +2074,10 @@ BOOL CGit::CheckMsysGitDir(BOOL bFallback) static git_smart_subtransport_definition ssh_wintunnel_subtransport_definition = { [](git_smart_subtransport **out, git_transport* owner) -> int { return git_smart_subtransport_ssh_wintunnel(out, owner, FindExecutableOnPath(g_Git.m_Environment.GetEnv(_T("GIT_SSH")), g_Git.m_Environment.GetEnv(_T("PATH"))), &g_Git.m_Environment[0]); }, 0 }; git_transport_register("ssh", git_transport_smart, &ssh_wintunnel_subtransport_definition); CString msysGitTemplateDir; - PathCanonicalize(msysGitTemplateDir.GetBufferSetLength(MAX_PATH), CGit::ms_LastMsysGitDir + _T("\\..\\share\\git-core\\templates")); + if (!ms_bCygwinGit) + PathCanonicalize(msysGitTemplateDir.GetBufferSetLength(MAX_PATH), CGit::ms_LastMsysGitDir + _T("\\..\\share\\git-core\\templates")); + else + PathCanonicalize(msysGitTemplateDir.GetBufferSetLength(MAX_PATH), CGit::ms_LastMsysGitDir + _T("\\..\\usr\\share\\git-core\\templates")); msysGitTemplateDir.ReleaseBuffer(); SetLibGit2TemplatePath(msysGitTemplateDir); diff --git a/src/Git/Git.h b/src/Git/Git.h index 5483a737e..b9ac09942 100644 --- a/src/Git/Git.h +++ b/src/Git/Git.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2014 - TortoiseGit +// Copyright (C) 2008-2015 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -183,6 +183,7 @@ public: static CStringA GetGitPathStringA(const CString &path); static CString ms_LastMsysGitDir; // the last msysgitdir added to the path, blank if none static int ms_LastMsysGitVersion; + static bool ms_bCygwinGit; static int m_LogEncode; static bool IsBranchNameValid(const CString& branchname); bool IsBranchTagNameUnique(const CString& name); diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index feeccfc00..3bbb03586 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -3710,6 +3710,18 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) CString cmd; if(!g_Git.IsInitRepos()) { + if (CGit::ms_bCygwinGit) + { + // Prevent showing all files as modified when using cygwin's git + if (list == NULL) + cmd = (_T("git.exe status --")); + else + cmd.Format(_T("git.exe status -- \"%s\""), (*list)[i].GetGitPathString()); + cmdList += cmd + _T("\n"); + g_Git.Run(cmd, &cmdout); + cmdout.clear(); + } + // also list staged files which will be in the commit cmd=(_T("git.exe diff-index --cached --raw ") + head + _T(" --numstat -C -M -z --")); cmdList += cmd + _T("\n"); diff --git a/src/TortoiseProc/AboutDlg.cpp b/src/TortoiseProc/AboutDlg.cpp index 83787cb68..a28f0027f 100644 --- a/src/TortoiseProc/AboutDlg.cpp +++ b/src/TortoiseProc/AboutDlg.cpp @@ -1,7 +1,7 @@ // TortoiseGit - a Windows shell extension for easy version control // Copyright (C) 2003-2008 - TortoiseSVN -// Copyright (C) 2009-2013 - TortoiseGit +// Copyright (C) 2009-2015 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -83,7 +83,12 @@ BOOL CAboutDlg::OnInitDialog() out.Trim(); if (!CGit::ms_LastMsysGitDir.IsEmpty()) - out += _T(" (") + CGit::ms_LastMsysGitDir + _T(")"); + { + out += _T(" (") + CGit::ms_LastMsysGitDir; + if (CGit::ms_bCygwinGit) + out += _T("; with cygwin hack"); + out += _T(")"); + } CString tortoisegitprocpath; tortoisegitprocpath.Format(_T("(%s)"), CPathUtils::GetAppDirectory()); diff --git a/src/TortoiseProc/Settings/SetMainPage.cpp b/src/TortoiseProc/Settings/SetMainPage.cpp index 6da5321d1..3cf172a42 100644 --- a/src/TortoiseProc/Settings/SetMainPage.cpp +++ b/src/TortoiseProc/Settings/SetMainPage.cpp @@ -309,6 +309,8 @@ void CSetMainPage::OnCheck() else if (CMessageBox::Show(NULL, _T("Could not get read version information from git.exe.\nCheck help file for \"Git.exe Path\"."),_T("TortoiseGit"), 1, IDI_ERROR, CString(MAKEINTRESOURCE(IDS_MSGBOX_OK)), CString(MAKEINTRESOURCE(IDS_MSGBOX_HELP))) == 2) OnHelp(); } + else if (!CGit::ms_bCygwinGit && out.Find(_T("msysgit")) == -1 && CMessageBox::Show(NULL, _T("Could not find \"msysgit\" in versionstring of git.exe.\nIf you are using git of the cygwin environment please read the help file for the keyword \"cygwin git\"."), _T("TortoiseGit"), 1, IDI_INFORMATION, CString(MAKEINTRESOURCE(IDS_MSGBOX_OK)), CString(MAKEINTRESOURCE(IDS_MSGBOX_HELP))) == 2) + OnHelp(); } else { diff --git a/src/TortoiseProc/Settings/SettingsAdvanced.cpp b/src/TortoiseProc/Settings/SettingsAdvanced.cpp index 752e3e080..45f527598 100644 --- a/src/TortoiseProc/Settings/SettingsAdvanced.cpp +++ b/src/TortoiseProc/Settings/SettingsAdvanced.cpp @@ -50,6 +50,10 @@ CSettingsAdvanced::CSettingsAdvanced() settings[i].type = CSettingsAdvanced::SettingTypeBoolean; settings[i++].def.b = true; + settings[i].sName = L"CygwinHack"; + settings[i].type = CSettingsAdvanced::SettingTypeBoolean; + settings[i++].def.b = false; + settings[i].sName = L"Debug"; settings[i].type = CSettingsAdvanced::SettingTypeBoolean; settings[i++].def.b = false; -- 2.11.4.GIT