{"record":{"id":"d3d14ca4c6860ae3","repo":"nikivdev/code","slug":"no-branches-available-to-search","errorCode":null,"errorMessage":"No branches available to search","messagePattern":"No branches available to search","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/branches.rs","lineNumber":57,"sourceCode":"        return Ok(());\n    }\n\n    let limit = opts.limit.max(1);\n    for entry in branches.iter().take(limit) {\n        print_branch(entry);\n    }\n    Ok(())\n}\n\nfn run_find(opts: BranchFindOpts) -> Result<()> {\n    let query = opts.query.trim().to_string();\n    if query.is_empty() {\n        bail!(\"Query cannot be empty\");\n    }\n\n    let branches = collect_branches(opts.remote)?;\n    if branches.is_empty() {\n        bail!(\"No branches available to search\");\n    }\n\n    let ranked = rank_branches(&query, &branches);\n    if ranked.is_empty() {\n        bail!(\"No branches matched query '{}'.\", query);\n    }\n\n    let limit = opts.limit.max(1);\n    for (_, entry) in ranked.iter().take(limit) {\n        print_branch(entry);\n    }\n\n    if opts.switch {\n        let best = ranked\n            .first()\n            .map(|(_, entry)| (*entry).clone())\n            .context(\"No match available to switch\")?;\n        println!(\"\\nSwitching to {}...\", best.name);","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/branches.rs#L39-L75","documentation":"`run_find` (src/branches.rs:57) collects local (or remote, if requested) git branches and bails if the resulting list is empty. There is nothing to search, so the find operation aborts before ranking.","triggerScenarios":"`collect_branches(opts.remote)` returns an empty vector — running in a directory with no git repo/branches, or `--remote` set while no remote branches exist (no fetch, no remote configured, or wrong repo).","commonSituations":"Invoked outside a git repository; fresh clone with zero local branches and no fetched remotes; `--remote` flag used in a repo whose remote hasn't been fetched yet.","solutions":["Run the command from inside a git repository that has branches","If using --remote, run `git fetch --all` first so remote refs exist","Verify the remote is configured (`git remote -v`)","Drop the --remote flag to search local branches"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure we're in a repo with refs before running find\nlet out = std::process::Command::new(\"git\").args([\"rev-parse\", \"--is-inside-work-tree\"]).output()?;\nif !out.status.success() {\n    anyhow::bail!(\"not inside a git repository\");\n}","typeGuard":"fn branches_available(b: &[Branch]) -> bool { !b.is_empty() }","tryCatchPattern":"match run_find(opts) {\n    Err(e) if e.to_string().contains(\"No branches available\") => {\n        eprintln!(\"run inside a repo with branches, or `git fetch --all` first\");\n    }\n    other => other?,\n}","preventionTips":["Verify `git branch -a` lists branches in the target directory","Run `git fetch --all` before remote searches","Check working directory in scripts/CI before invoking"],"tags":["git","branches","empty-state"],"backgroundTag":"no-branches-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}