Commit 3187b50e authored by ch3cooli's avatar ch3cooli

Allow to choose Git Credential Manager for Windows (GCM)

Signed-off-by: ch3cooli's avatarSup Yut Sum <ch3cooli@gmail.com>
parent 56f33957
......@@ -10852,6 +10852,18 @@ msgstr ""
msgid "line: %d(+) %d(-) files: %s = %ld\n%s = %ld\n%s = %ld\n%s = %ld\n%s = %ld\n%s = %ld"
msgstr ""
#. Resource IDs: (IDS_SYSTEM_GCM)
msgid "manager - all Windows users"
msgstr ""
#. Resource IDs: (IDS_GLOBAL_GCM)
msgid "manager - current Windows user"
msgstr ""
#. Resource IDs: (IDS_LOCAL_GCM)
msgid "manager - this repository only"
msgstr ""
#. Resource IDs: (Dialog IDD_PULLFETCH: Control id 1494)
msgid "master"
msgstr ""
......
......@@ -10,6 +10,7 @@ Released: unreleased
* Fixed issue #2578: Resolve Dialog <enter> should open "Edit conflicts"
* Fixed issue #2590: Allow to resolve conflicts with TortoiseGitIDiff by clicking on select
* Added branch revision number for tracking of the source code version of a branch in automated builds using "git rev-list --count --first-parent"
* Allow to choose Git Credential Manager for Windows (GCM)
== Bug Fixes ==
* TortoiseGitMerge highlights wrong line in case of file starts with LF+CRLF
......
......@@ -4716,6 +4716,13 @@ BEGIN
IDS_MERGEBUTTON "&Merge"
IDS_REBASEBUTTON "&Rebase"
IDS_RESTORE_FROM_INDEX "R&estore this file from index"
IDS_LOCAL_GCM "manager - this repository only"
END
STRINGTABLE
BEGIN
IDS_GLOBAL_GCM "manager - current Windows user"
IDS_SYSTEM_GCM "manager - all Windows users"
END
#endif // English (U.S.) resources
......
......@@ -35,9 +35,12 @@ namespace SimpleCredentialType
static int None;
static int LocalWincred;
static int LocalWinstore;
static int LocalGCM;
static int GlobalWincred;
static int GlobalWinstore;
static int GlobalGCM;
static int SystemWincred;
static int SystemGCM;
static void Init()
{
......@@ -45,9 +48,12 @@ namespace SimpleCredentialType
None = -1;
LocalWincred = -1;
LocalWinstore = -1;
LocalGCM = -1;
GlobalWincred = -1;
GlobalWinstore = -1;
GlobalGCM = -1;
SystemWincred = -1;
SystemGCM = -1;
}
}
......@@ -135,6 +141,13 @@ static bool WinstoreExists()
return !!PathFileExists(GetWinstorePath());
}
static bool GCMExists()
{
CString path = CGit::ms_MsysGitRootDir;
path.Append(_T("libexec\\git-core\\git-credential-manager.exe"));
return !!PathFileExists(path);
}
static CStringA RegexEscape(CStringA str)
{
CStringA result;
......@@ -180,15 +193,20 @@ BOOL CSettingGitCredential::OnInitDialog()
((CComboBox*) GetDlgItem(IDC_COMBO_HELPER))->AddString(_T("wincred"));
if (WinstoreExists())
((CComboBox*) GetDlgItem(IDC_COMBO_HELPER))->AddString(GetWinstorePath());
if (GCMExists())
((CComboBox*)GetDlgItem(IDC_COMBO_HELPER))->AddString(_T("manager"));
SimpleCredentialType::Init();
AddSimpleCredential(SimpleCredentialType::Advanced, CString(MAKEINTRESOURCE(IDS_ADVANCED)));
AddSimpleCredential(SimpleCredentialType::None, CString(MAKEINTRESOURCE(IDS_NONE)));
AddSimpleCredential(SimpleCredentialType::LocalWincred, CString(MAKEINTRESOURCE(IDS_LOCAL_WINCRED)), hasLocal && WincredExists());
AddSimpleCredential(SimpleCredentialType::LocalWinstore, CString(MAKEINTRESOURCE(IDS_LOCAL_WINSTORE)), hasLocal && WinstoreExists());
AddSimpleCredential(SimpleCredentialType::LocalGCM, CString(MAKEINTRESOURCE(IDS_LOCAL_GCM)), hasLocal && GCMExists());
AddSimpleCredential(SimpleCredentialType::GlobalWincred, CString(MAKEINTRESOURCE(IDS_GLOBAL_WINCRED)), WincredExists());
AddSimpleCredential(SimpleCredentialType::GlobalWinstore, CString(MAKEINTRESOURCE(IDS_GLOBAL_WINSTORE)), WinstoreExists());
AddSimpleCredential(SimpleCredentialType::GlobalGCM, CString(MAKEINTRESOURCE(IDS_GLOBAL_GCM)), GCMExists());
AddSimpleCredential(SimpleCredentialType::SystemWincred, CString(MAKEINTRESOURCE(IDS_SYSTEM_WINCRED)), WincredExists());
AddSimpleCredential(SimpleCredentialType::SystemGCM, CString(MAKEINTRESOURCE(IDS_SYSTEM_GCM)), GCMExists());
LoadList();
......@@ -447,6 +465,11 @@ void CSettingGitCredential::LoadList()
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::LocalWinstore);
return;
}
else if (value == _T("manager"))
{
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::LocalGCM);
return;
}
}
if (prefix == _T("G") || prefix == _T("X"))
......@@ -461,6 +484,11 @@ void CSettingGitCredential::LoadList()
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::GlobalWinstore);
return;
}
else if (value == _T("manager"))
{
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::GlobalGCM);
return;
}
}
if (prefix == _T("S"))
......@@ -470,6 +498,11 @@ void CSettingGitCredential::LoadList()
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::SystemWincred);
return;
}
else if (value == _T("manager"))
{
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::SystemGCM);
return;
}
}
m_ctrlSimpleCredential.SetCurSel(SimpleCredentialType::Advanced);
......@@ -551,12 +584,18 @@ static int DeleteOtherKeys(int type)
match = _T("L\ncredential.helper\nwincred");
else if (type == SimpleCredentialType::LocalWinstore)
match = _T("L\ncredential.helper\n") + GetWinstorePath();
else if (type == SimpleCredentialType::LocalGCM)
match = _T("L\ncredential.helper\nmanager");
else if (type == SimpleCredentialType::GlobalWincred)
match = _T("G\ncredential.helper\nwincred");
else if (type == SimpleCredentialType::GlobalWinstore)
match = _T("G\ncredential.helper\n") + GetWinstorePath();
else if (type == SimpleCredentialType::GlobalGCM)
match = _T("G\ncredential.helper\nmanager");
else if (type == SimpleCredentialType::SystemWincred)
match = _T("S\ncredential.helper\nwincred");
else if (type == SimpleCredentialType::SystemGCM)
match = _T("S\ncredential.helper\nmanager");
CAutoConfig config(true);
git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitLocalConfig()), GIT_CONFIG_LEVEL_LOCAL, FALSE);
......@@ -619,6 +658,11 @@ bool SaveSimpleCredential(int type)
configLevel = CONFIG_LOCAL;
value = GetWinstorePath();
}
else if (type == SimpleCredentialType::LocalGCM)
{
configLevel = CONFIG_LOCAL;
value = _T("manager");
}
else if (type == SimpleCredentialType::GlobalWincred)
{
configLevel = CONFIG_GLOBAL;
......@@ -629,11 +673,21 @@ bool SaveSimpleCredential(int type)
configLevel = CONFIG_GLOBAL;
value = GetWinstorePath();
}
else if (type == SimpleCredentialType::GlobalGCM)
{
configLevel = CONFIG_GLOBAL;
value = _T("manager");
}
else if (type == SimpleCredentialType::SystemWincred)
{
configLevel = CONFIG_SYSTEM;
value = _T("wincred");
}
else if (type == SimpleCredentialType::SystemGCM)
{
configLevel = CONFIG_SYSTEM;
value = _T("manager");
}
else
{
return true;
......@@ -666,6 +720,12 @@ BOOL CSettingGitCredential::OnApply()
EndDialog(0);
return FALSE;
}
if (type == SimpleCredentialType::SystemGCM && !CAppUtils::IsAdminLogin())
{
RunUAC();
EndDialog(0);
return FALSE;
}
if (type != SimpleCredentialType::Advanced)
{
if (!SaveSimpleCredential(type))
......
......@@ -1226,12 +1226,15 @@
#define IDC_REP_BROWSE 1583
#define IDC_SEND_ADDRESS 1583
#define IDC_UUIDLABEL64 1583
#define IDS_LOCAL_GCM 1583
#define IDC_BUTTON_PATH_BROWSE 1584
#define IDC_SMTP_SERVER 1584
#define IDC_UUID64 1584
#define IDS_GLOBAL_GCM 1584
#define IDC_GROUP_SUBMODULE 1585
#define IDC_SMTP_AUTH 1585
#define IDC_PARAMS 1585
#define IDS_SYSTEM_GCM 1585
#define IDC_BRANCH_CHECK 1586
#define IDC_SMTP_USER 1586
#define IDC_PARAMSLABEL 1586
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment