{"record":{"id":"773e6a9d25ee5361","repo":"jdx/mise","slug":"a-branch-name-is-required","errorCode":null,"errorMessage":"a branch name is required","messagePattern":"a branch name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/origin.rs","lineNumber":247,"sourceCode":"    // written: fetch-only connects without publishing anything\n    let outcome = run::sync(&store, &tracked, &SyncRequest::new(!opts.mode.publishes()))?;\n    report(&outcome);\n    Ok(())\n}\n\n/// The setup branch: the one asked for, else the branch this machine already\n/// follows on the same repository, else the repository's own default branch.\n/// Assuming `main` reads a repository that does not have it as empty, and\n/// publishes an unrelated root branch beside its real history.\nfn resolve_branch(\n    remote: &Remote<'_>,\n    requested: Option<&str>,\n    connected: Option<&str>,\n) -> Result<String> {\n    if let Some(branch) = requested {\n        let branch = branch.trim();\n        if branch.is_empty() {\n            bail!(\"a branch name is required\");\n        }\n        return Ok(branch.to_string());\n    }\n    if let Some(branch) = connected {\n        return Ok(branch.to_string());\n    }\n    // an unreachable repository is reported by the fetch that follows\n    Ok(super::onboard::default_branch(remote)?.unwrap_or_else(|| DEFAULT_BRANCH.to_string()))\n}\n\n/// A missing branch is only an empty repository when the repository has no\n/// branches at all; otherwise connecting would publish an unrelated root\n/// branch beside the history that is already there.\npub(super) fn refuse_missing_branch(remote: &Remote<'_>, branch: &str, url: &str) -> Result<()> {\n    // a listing that fails must not read as an empty repository: that is the\n    // path this check exists to prevent\n    let refs = remote.ls_remote()?;\n    let heads: Vec<&str> = refs","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/sync/origin.rs#L229-L265","documentation":"resolve_branch, which picks the git branch for dotfiles history sync setup, ended with no branch: none was requested, no branch is already connected for this machine on that repository, and no fallback could be determined, so publishing has no target and setup aborts.","triggerScenarios":"`mise dot origin set --branch \" \"` or `--branch \"\"` — the flag is present but its value trims to empty; `resolve_branch` is called from set_inner.","commonSituations":"An unset shell variable interpolated into `--branch \"$B\"`; copy-paste dropping the branch name; quoting issues passing an empty string.","solutions":["Pass a concrete branch name: `mise dot origin set <url> --branch main`","Omit `--branch` to reuse the currently connected branch or the default resolution","Fix the shell variable supplying the branch name"],"exampleFix":"// before\nmise dot origin set <url> --branch \"$BRANCH\"  # empty\n// after\nmise dot origin set <url> --branch main","handlingStrategy":"validation","validationCode":"let branch = std::env::var(\"BRANCH\").unwrap_or_default();\nif branch.trim().is_empty() {\n    eprintln!(\"BRANCH is empty; pass --branch <name> or omit the flag\");\n    std::process::exit(2);\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"a branch name is required\") => eprintln!(\"usage: mise dot origin set <url> --branch <name>\"),\n    _ => {}\n}","preventionTips":["Use ${BRANCH:?} to fail fast on unset shell variables","Omit --branch entirely to fall back to the connected/default branch","Trim user-supplied branch names before passing them"],"tags":["cli","git","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}