88using GitCommands . DiffMergeTools ;
99using GitCommands . Settings ;
1010using GitCommands . Utils ;
11+ using GitExtensions . Extensibility . Configurations ;
1112using GitExtensions . Extensibility . Settings ;
1213using Microsoft ;
1314using ResourceManager ;
@@ -159,10 +160,22 @@ protected override void SettingsToPage()
159160
160161 GlobalUserName . Text = CurrentSettings . GetValue ( SettingKeyString . UserName ) ;
161162 GlobalUserEmail . Text = CurrentSettings . GetValue ( SettingKeyString . UserEmail ) ;
162- cbxCredentialHelper . Text = CurrentSettings . GetValue ( "credential.helper" ) ;
163163 GlobalEditor . Text = CurrentSettings . GetValue ( "core.editor" ) ;
164164 txtCommitTemplatePath . Text = CurrentSettings . GetValue ( "commit.template" ) ;
165165
166+ // Hide credential helper because EffectiveGitConfigSettings can only return the last value
167+ GitConfigSettings ? gitConfigSettings = TryGetGitConfigSettings ( CurrentSettings ) ;
168+ bool showCredentialHelper = gitConfigSettings is not null ;
169+ lblCredentialHelper . Visible = showCredentialHelper ;
170+ cbxCredentialHelper . Visible = showCredentialHelper ;
171+ cbxCredentialHelper . Enabled = showCredentialHelper ;
172+ if ( gitConfigSettings is not null )
173+ {
174+ IReadOnlyList < string > values = gitConfigSettings . GetValues ( SettingKeyString . CredentialHelper ) ;
175+ cbxCredentialHelper . Enabled = values . Count <= 1 ;
176+ cbxCredentialHelper . Text = string . Join ( ", " , values ) ;
177+ }
178+
166179 _NO_TRANSLATE_cboMergeTool . Text = mergeTool ;
167180 txtMergeToolPath . Text = _diffMergeToolConfigurationManager . GetToolPath ( mergeTool , DiffMergeToolType . Merge ) ;
168181 txtMergeToolCommand . Text = _diffMergeToolConfigurationManager . GetToolCommand ( mergeTool , DiffMergeToolType . Merge ) ;
@@ -179,6 +192,17 @@ protected override void SettingsToPage()
179192 globalAutoCrlfNotSet . Checked = autocrlf is null ;
180193
181194 base . SettingsToPage ( ) ;
195+
196+ return ;
197+
198+ static GitConfigSettings ? TryGetGitConfigSettings ( SettingsSource settingsSource )
199+ {
200+ return settingsSource is SettingsSource < IPersistentConfigValueStore > persistentSettingsSource
201+ ? persistentSettingsSource . ConfigValueStore as GitConfigSettings
202+ : settingsSource is SettingsSource < IConfigValueStore > otherGenericSettingsSource
203+ ? otherGenericSettingsSource . ConfigValueStore as GitConfigSettings
204+ : null ;
205+ }
182206 }
183207
184208 /// <summary>
@@ -201,8 +225,11 @@ protected override void PageToSettings()
201225 CurrentSettings . SetValue ( SettingKeyString . UserName , GlobalUserName . Text ) ;
202226 CurrentSettings . SetValue ( SettingKeyString . UserEmail , GlobalUserEmail . Text ) ;
203227 CurrentSettings . SetValue ( "commit.template" , txtCommitTemplatePath . Text ) ;
204- CurrentSettings . SetValue ( "credential.helper" , cbxCredentialHelper . Text ) ;
205228 CurrentSettings . SetValue ( "core.editor" , GlobalEditor . Text . ConvertPathToGitSetting ( ) ) ;
229+ if ( cbxCredentialHelper . Enabled )
230+ {
231+ CurrentSettings . SetValue ( SettingKeyString . CredentialHelper , cbxCredentialHelper . Text ) ;
232+ }
206233
207234 Validates . NotNull ( _diffMergeToolConfigurationManager ) ;
208235
0 commit comments