fix(git): tolerate remotes without a url key
git-annex S3 special remotes have no url key; running `git config --get-all remote.<name>.url` on them exits 1, which made tea hard-fail in Config() on any repo that has such a remote. Treat a missing key (exit 1 with empty or 'No such section or key' stderr) as an empty URL list, mirroring the existing branch-section handling.
This commit is contained in:
@@ -73,8 +73,16 @@ func (r *cliRepository) Config() (*Config, error) {
|
||||
for _, remoteName := range strings.Fields(remoteOut) {
|
||||
urlOut, err := r.git(nil, nil, "config", "--get-all", "remote."+remoteName+".url")
|
||||
if err != nil {
|
||||
// tolerate remotes without a url key (e.g. git-annex special remotes)
|
||||
var gitErr *gitCommandError
|
||||
if !errors.As(err, &gitErr) {
|
||||
return nil, err
|
||||
}
|
||||
stderr := strings.TrimSpace(gitErr.stderr)
|
||||
if stderr != "" && !strings.Contains(stderr, "No such section or key") {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
cfg.Remotes[remoteName] = &RemoteConfig{Name: remoteName, URLs: splitNonEmptyLines(urlOut)}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user