Description
Remote names containing uppercase letters (e.g. G, Origin, MyRemote) are displayed as all-lowercase in the UI (e.g. g, origin, myremote).
Root Cause
- In commit
582c1a2217001d1fae0c1f89e80d9a62407be007 (refactor: repository remote), Commands.QueryRemotes was changed to extract remote names directly from Commands.Config.ReadAllAsync() instead of parsing the output of git remote -v.
- In
Commands.Config.ReadAllAsync(), the config key is lowercased unconditionally:
var key = parts[0].ToLower(CultureInfo.CurrentCulture);
- According to the Git configuration specification:
- Section (e.g.,
remote) and Variable name (e.g., url) are case-insensitive.
- Subsection (e.g.,
<name> in remote.<name>.url) is case-sensitive.
Lowercasing the full key converts remote.G.url to remote.g.url, causing QueryRemotes to extract the remote name as g rather than G.
Steps to Reproduce
- In a repository, configure a remote with uppercase letters, e.g.:
git remote add G git@github.com:example/repo.git
- Open SourceGit and inspect the repository.
- Observe the remote name in the sidebar remotes tree, fetch/pull/push dialogs, and commit decorators.
- It is shown as
g instead of G.
Suggested Solution
When canonicalizing git config keys, preserve the case of subsections (between the first and last dots):
public static string CanonicalizeKey(string key)
{
if (string.IsNullOrEmpty(key))
return key;
var firstDot = key.IndexOf('.');
if (firstDot < 0)
return key.ToLower(CultureInfo.CurrentCulture);
var lastDot = key.LastIndexOf('.');
if (firstDot == lastDot)
return key.ToLower(CultureInfo.CurrentCulture);
var section = key.Substring(0, firstDot).ToLower(CultureInfo.CurrentCulture);
var subsection = key.Substring(firstDot, lastDot - firstDot);
var variable = key.Substring(lastDot).ToLower(CultureInfo.CurrentCulture);
return string.Concat(section, subsection, variable);
}
And apply it when parsing keys in Config.ReadAll() and Config.ReadAllAsync().
Description
Remote names containing uppercase letters (e.g.
G,Origin,MyRemote) are displayed as all-lowercase in the UI (e.g.g,origin,myremote).Root Cause
582c1a2217001d1fae0c1f89e80d9a62407be007(refactor: repository remote),Commands.QueryRemoteswas changed to extract remote names directly fromCommands.Config.ReadAllAsync()instead of parsing the output ofgit remote -v.Commands.Config.ReadAllAsync(), the config key is lowercased unconditionally:remote) and Variable name (e.g.,url) are case-insensitive.<name>inremote.<name>.url) is case-sensitive.Lowercasing the full key converts
remote.G.urltoremote.g.url, causingQueryRemotesto extract the remote name asgrather thanG.Steps to Reproduce
ginstead ofG.Suggested Solution
When canonicalizing git config keys, preserve the case of subsections (between the first and last dots):
And apply it when parsing keys in
Config.ReadAll()andConfig.ReadAllAsync().