Skip to content

[Bug] Remote name with uppercase letters is forced to lowercase in GUI (e.g., 'G' -> 'g') #2715

Description

@heartacker

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

  1. 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.
  2. In Commands.Config.ReadAllAsync(), the config key is lowercased unconditionally:
    var key = parts[0].ToLower(CultureInfo.CurrentCulture);
  3. 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

  1. In a repository, configure a remote with uppercase letters, e.g.:
    git remote add G git@github.com:example/repo.git
  2. Open SourceGit and inspect the repository.
  3. Observe the remote name in the sidebar remotes tree, fetch/pull/push dialogs, and commit decorators.
  4. 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().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions