git-ecosystem/git-credential-manager · error · Trace2Exception

Failed to get all Git configuration entries

Error message

Failed to get all Git configuration entries '{name}'

What it means

Thrown by GitConfiguration.GetAll when `git config --get-all <name>` exits with a code other than 0 or 1. Exit 1 means no results and is tolerated; any other exit code (2+) indicates a real failure such as a malformed key or an unreadable config.

Solutions

  1. Validate the key format: must be 'section.key' or 'section.subsection.key' with a final subkey
  2. Test with `git config --get-all <name>` manually to capture git's stderr
  3. Repair the corrupted config file git points to in its error message
  4. Handle the empty case separately — exit 1 (no entries) does not throw

Example fix

// before
var vals = config.GetAll(level, GitConfigurationType.Path, "remote"); // throws: key lacks subkey
// after
var vals = config.GetAll(level, GitConfigurationType.Path, "remote.origin.url");
Defensive patterns

Strategy: validation

Validate before calling

static bool IsValidConfigKey(string name) {
    var parts = name.Split('.');
    return parts.Length >= 2 && parts.All(p => p.Length > 0);
}
// GetAll tolerates 'no results'; validate key format before querying

Try / catch

try { values = cfg.GetAll(level, type, name).ToList(); }
catch (GitException ex) { log.Warn($"GetAll '{name}' failed: {ex.Message}"); values = new List<string>(); }

Prevention

When it happens

Trigger: Calling GetAll(level, type, name) with a syntactically invalid key name, or when the config file is corrupted/unreadable so git cannot even evaluate the query.

Common situations: Querying a key like 'http' (no subkey) which git rejects; querying after a broken editor or merge tool corrupted .gitconfig; environment where HOME is unset so system config resolution fails oddly.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/208cc866b2143885. Report an issue: GitHub.

Appendix: source

Thrown at src/Core/GitConfiguration.cs:698

                switch (git.ExitCode)
                {
                    case 0: // OK
                        string[] entries = data.Split('\0');

                        // Because each line terminates with the \0 character, splitting leaves us with one
                        // bogus blank entry at the end of the array which we should ignore
                        for (var i = 0; i < entries.Length - 1; i++)
                        {
                            yield return entries[i];
                        }
                        break;

                    case 1: // No results
                        break;

                    default:
                        _trace.WriteLine($"Failed to get all config entries '{name}' (exit={git.ExitCode}, level={level})");
                        throw GitProcess.CreateGitException(git, $"Failed to get all Git configuration entries '{name}'");
                }
            }
        }

        public IEnumerable<string> GetRegex(GitConfigurationLevel level, GitConfigurationType type, string nameRegex, string valueRegex)
        {
            string levelArg = GetLevelFilterArg(level);
            string typeArg = GetCanonicalizeTypeArg(type);

            var gitArgs = $"config --null {levelArg} {typeArg} --get-regex {QuoteCmdArg(nameRegex)}";
            if (valueRegex != null)
            {
                gitArgs += $" {QuoteCmdArg(valueRegex)}";
            }

            using (ChildProcess git = _git.CreateProcess(gitArgs))
            {
                git.Start(Trace2ProcessClass.Git);

View on GitHub (pinned to e8ce762cd0)