{"record":{"id":"fade04d4a20aae47","repo":"gastownhall/beads","slug":"merged-into-object-id-q-is-the-target-head-itse","errorCode":null,"errorMessage":"--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment","messagePattern":"--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/worktree_cmd.go","lineNumber":1752,"sourceCode":"\t\treturn pinWorktreeComparatorRef(ctx, git, executionRoot, target, selector, matches[0], true)\n\t}\n\tif !fullOID {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into value %q does not name an existing unambiguous ref\",\n\t\t\tselector,\n\t\t)\n\t}\n\n\toid, err := resolveWorktreeCommitOID(ctx, git, executionRoot, selector)\n\tif err != nil {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into object ID %q does not resolve to a commit: %w\",\n\t\t\tselector,\n\t\t\terr,\n\t\t)\n\t}\n\tif oid == target.headOID {\n\t\treturn pinnedWorktreeComparator{}, fmt.Errorf(\n\t\t\t\"--merged-into object ID %q is the target HEAD itself; use a ref or descendant commit that independently proves containment\",\n\t\t\tselector,\n\t\t)\n\t}\n\treturn pinnedWorktreeComparator{\n\t\tselector: selector,\n\t\texplicit: true,\n\t\toid:      oid,\n\t}, nil\n}\n\nfunc gitRefNameIsValid(\n\tctx context.Context,\n\tgit *worktreeRemovalGit,\n\texecutionRoot string,\n\tref string,\n\tallowOneLevel bool,\n) (bool, error) {","sourceCodeStart":1734,"sourceCodeEnd":1770,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/worktree_cmd.go#L1734-L1770","documentation":"The `--merged-into` comparator must independently prove that the worktree's HEAD is contained in (i.e. is an ancestor of) some other commit. If the resolved OID equals the target worktree's HEAD OID, no such independent proof exists, so bd rejects the selector with this error.","triggerScenarios":"Passing `--merged-into <oid>` where the full resolved OID is exactly the target worktree's current `headOID`.","commonSituations":"Copy-pasting `git rev-parse HEAD` from inside the target worktree; scripting `--merged-into $(git rev-parse <branch>)` where the branch is checked out at HEAD in that worktree.","solutions":["Pass a ref or commit that is a strict descendant of the worktree HEAD, e.g. the branch it was merged into (`refs/heads/main`)","Run `git log --oneline` to pick a commit after the worktree's HEAD","Use the merge-target branch name rather than the worktree's own HEAD"],"exampleFix":"// before\nbd worktree remove --merged-into $(git -C ../wt rev-parse HEAD)\n// after\nbd worktree remove --merged-into refs/heads/main","handlingStrategy":"validation","validationCode":"// shell pre-check: OID must differ from the worktree HEAD\nwt_head=$(git -C \"$WORKTREE\" rev-parse HEAD)\n[ \"$OID\" != \"$wt_head\" ] || echo \"--merged-into equals target HEAD; pick a descendant\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass the worktree's own HEAD or its checked-out branch as --merged-into","Pick the merge-target branch (e.g. main) as the comparator","Verify ancestry with `git merge-base --is-ancestor <head> <selector>` first"],"tags":["git","cli","oid","containment-proof"],"backgroundTag":"invalid-merged-into-ref","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}