`dolt remote remove` leaves an upstream config behind
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 120
Description
A branch can record an upstream, the branch that's merged into it by default, or that it's rebased onto. In Dolt, it's stored under `.dolt/repo_state.json` as two fields: the remote and a ref naming the branch on that remote. `dolt remote remove` clears the remote name but keeps the ref, making it ambiguous with a local branch upstream config.
```sh
$ dolt push -u origin b1:other
$ dolt remote remove origin
$ cat .dolt/repo_state.json
"branches": {
"b1": {
"head": "refs/heads/other",
"remote": ""
}
}
$ dolt branch --set-upstream-to other b1
branch 'b1' set up to track 'other'
$ cat .dolt/repo_state.json
"branches": {
"b1": {
"head": "refs/heads/other",
"remote": ""
}
}
```
When the upstream lives in the local repository, Git indicates it with a '.' character: [the relative path setting](https://git-scm.com/docs/git-config#Documentation/git-config.txt-branchnamemerge).
```sh
$ git config --get-regexp ^branch\.b1\.
branch.b1.remote origin
branch.b1.merge refs/heads/other
$ git remote remove origin
$ git config --get-regexp ^branch\.b1\.
(no output)
$ git branch --set-upstream-to=other2 b1
$ git config --get-regexp ^branch\.b1\.
branch.b1.remote .
branch.b1.merge refs/heads/other2
```
I've left a TODO in `UpstreamRef` since this doesn't allow us to discern if we want the ref.
https://github.com/dolthub/dolt/blob/92de41bbaef077eb6db53bce2b5d5f8ac001891f/go/libraries/doltcore/env/remotes.go#L811-L816
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in go/libraries/doltcore/env/remotes.go at the UpstreamRef TODO, then trace the remote removal and branch upstream-setting entry points. Reproduce the commands in the issue and inspect .dolt/repo_state.json; done means remote removal no longer leaves an ambiguous ref, while local upstreams remain distinguishable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, go
- Domain
- cli, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100