dolt_branch -D of the default branch is refused even when it is not checked out; Dolt deletes it
- Dominant language
- C
- Stars
- 268
- Forks
- 18
- Avg merge
- 2h 27m
- Merged PRs (30d)
- 447
Description
Found in the 2026-08-28 review at c4f33fea01. **MEDIUM — Dolt-parity: cannot delete `main` after switching away.**
`dolt_checkout('other')` then `dolt_branch('-D','main')` errors `cannot delete the default branch; call dolt_default_branch() first` and both branches remain. Dolt 2.2.2 deletes `main` and `dolt_branches` lists only `other`.
The extra guard is `mutateBranchDelete` returning `SQLITE_CONSTRAINT` with `isDefault` in `src/doltlite_branch.c`. DoltLite already refuses deleting the **current** branch (matches Dolt `Cannot delete checked out branch`); the default-branch check is the extra refusal.
Independent of clustering / #1840.
## Repro (deterministic, verified twice)
```bash
D=./build/doltlite
W=$(mktemp -d /tmp/deldef.XXXXXX); cd $W
$D d.db <<'SQL'
CREATE TABLE t(i INTEGER PRIMARY KEY);
SELECT dolt_commit('-Am','x');
SELECT dolt_branch('other');
SELECT dolt_checkout('other');
SELECT dolt_branch('-D','main');
SELECT active_branch();
SELECT name FROM dolt_branches;
SQL
```
Observed: error on `-D main`; `active_branch()=other`; branches `main` and `other`.
EXPECTED (Dolt `CALL dolt_branch('-D','main')` after checkout other): success; `dolt_branches` is only `other`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/doltlite_branch.c at mutateBranchDelete and run the deterministic repro against ./build/doltlite. Compare deleting main after switching to other with the stated Dolt behavior, while preserving the existing refusal for the checked-out branch. Done means the command succeeds and dolt_branches lists only other.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100