git remote: only check for an existing remote when adding
cloning currently fails with Error: Git remote named '$remote' already exists if the user has some config somewhere that applies to $remote, e.g. in ~/.gitconfig. this error makes sense if you are trying to add a remote that already exists in the local config, but doesn't make sense while cloning since there must not be a local config (I think?)
this removes the check from git::add_remote and moves it to validate_remote_does_not_exist. this function is then called in cmd_git_remote_add and in rename_remote. this means that the add_remote call in configure_remote in clone.rs will not fail if there is some config somewhere affecting the remote.
Checklist
If applicable:
- [ ] I have updated
CHANGELOG.md - [ ] I have updated the documentation (
README.md,docs/,demos/) - [ ] I have updated the config schema (
cli/src/config-schema.json) - [ ] I have added/updated tests to cover my changes
I think we can instead make add_remote(), etc. load remote "name"s only from the repo .git/config. git remote add appears to ignore remotes defined only in ~/.gitconfig. git remote -v lists such remotes, though.
I also think it's okay to introduce incompatible change and make all jj git subcommands ignore remotes not defined in .git/config. We'll still need to load remote attributes from system/user settings, though.