Description
When running av branch <name> -m '<message>' in a freshly cloned and av init'd repository, the resulting av.db entry records the new branch as its own parent instead of the current HEAD branch (e.g., dev).
This creates a circular reference in the branch graph, which causes a stack overflow in SubsequentBranches when any subsequent av command traverses the branch tree (av tree, av sync, av pr, etc.).
Steps to Reproduce
git clone [email protected]:<org>/<repo>.git fresh-clone
cd fresh-clone
git checkout dev && git pull
av init
av branch my-feature -m 'feat: my feature'
cat .git/av/av.db
Expected Result
{
"branches": {
"my-feature": {
"name": "my-feature",
"parent": {
"name": "dev",
"trunk": true
}
}
}
}
Actual Result
{
"branches": {
"my-feature": {
"name": "my-feature",
"parent": {
"name": "my-feature",
"trunk": true
}
}
}
}
The branch is its own parent. Any subsequent av tree or av sync call triggers infinite recursion in SubsequentBranches and crashes with a goroutine stack overflow.
Workaround
Manually edit .git/av/av.db and set parent.name to the correct trunk branch (e.g., dev). After this fix, all av commands work correctly.
Environment
av version: v0.1.19
- OS: Ubuntu 22.04 (Linux 6.8.0-107-generic)
- Discovered by myself and Gwen while running parallel development workflows across multiple cloned copies of the same repository
Additional Context
This is reproducible in every fresh clone — tested across 3 separate clones of the same repo, all exhibited the identical self-referencing parent bug. The main (original) repo's av.db has correct parent entries for branches created there, so the issue is specific to av branch in a freshly initialized clone.
The secondary issue is that SubsequentBranches has no cycle detection or depth guard — a self-referencing parent should be caught and reported as an error rather than causing a stack overflow.
Description
When running
av branch <name> -m '<message>'in a freshly cloned andav init'd repository, the resultingav.dbentry records the new branch as its own parent instead of the current HEAD branch (e.g.,dev).This creates a circular reference in the branch graph, which causes a stack overflow in
SubsequentBrancheswhen any subsequentavcommand traverses the branch tree (av tree,av sync,av pr, etc.).Steps to Reproduce
Expected Result
{ "branches": { "my-feature": { "name": "my-feature", "parent": { "name": "dev", "trunk": true } } } }Actual Result
{ "branches": { "my-feature": { "name": "my-feature", "parent": { "name": "my-feature", "trunk": true } } } }The branch is its own parent. Any subsequent
av treeorav synccall triggers infinite recursion inSubsequentBranchesand crashes with a goroutine stack overflow.Workaround
Manually edit
.git/av/av.dband setparent.nameto the correct trunk branch (e.g.,dev). After this fix, allavcommands work correctly.Environment
avversion: v0.1.19Additional Context
This is reproducible in every fresh clone — tested across 3 separate clones of the same repo, all exhibited the identical self-referencing parent bug. The main (original) repo's
av.dbhas correct parent entries for branches created there, so the issue is specific toav branchin a freshly initialized clone.The secondary issue is that
SubsequentBrancheshas no cycle detection or depth guard — a self-referencing parent should be caught and reported as an error rather than causing a stack overflow.