{"record":{"id":"8376ac29920051a6","repo":"abhigyanpatwari/GitNexus","slug":"source-branch-name-must-not-be-the-single-character","errorCode":null,"errorMessage":"${source}: branch name must not be the single character \"@\".","messagePattern":"(.+?): branch name must not be the single character \"@\"\\.","errorType":"validation","errorClass":"InvalidBranchError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/git-ref.ts","lineNumber":106,"sourceCode":"  if (trimmed.includes('..')) {\n    throw new InvalidBranchError(`${source}: branch name must not contain \"..\".`);\n  }\n  // The remaining `git check-ref-format` rules. Without these the validator\n  // accepted refs git itself refuses (`feature.lock`, `/feature`, `feature/`,\n  // `feature//next`, `@`, `.hidden`), so the failure surfaced later from the\n  // git subprocess instead of here. No real branch can violate them — git\n  // could not have created one — so nothing that works today starts failing.\n  if (trimmed.endsWith('.lock') || trimmed.split('/').some((part) => part.endsWith('.lock'))) {\n    throw new InvalidBranchError(`${source}: branch name must not end with \".lock\".`);\n  }\n  if (trimmed.startsWith('/') || trimmed.endsWith('/')) {\n    throw new InvalidBranchError(`${source}: branch name must not start or end with \"/\".`);\n  }\n  if (trimmed.includes('//')) {\n    throw new InvalidBranchError(`${source}: branch name must not contain consecutive slashes.`);\n  }\n  if (trimmed === '@') {\n    throw new InvalidBranchError(`${source}: branch name must not be the single character \"@\".`);\n  }\n  if (trimmed.includes('@{')) {\n    throw new InvalidBranchError(`${source}: branch name must not contain \"@{\".`);\n  }\n  if (trimmed.endsWith('.') || trimmed.split('/').some((part) => part.startsWith('.'))) {\n    throw new InvalidBranchError(\n      `${source}: branch name must not end with \".\" or have a path component starting with \".\".`,\n    );\n  }\n  // Git permits a backtick in a ref, but the branch is embedded inside a\n  // Markdown inline-code span in the generated AGENTS.md/CLAUDE.md regression\n  // example, where a backtick would close the span early and let the rest of\n  // the template render as instruction text. Reject it at this single\n  // chokepoint so all three tiers (CLI flag, .gitnexusrc, auto-detect via\n  // sanitizeDetectedBranch) are covered (#1996 tri-review P1).\n  if (trimmed.includes('`')) {\n    throw new InvalidBranchError(\n      `${source}: branch name must not contain a backtick (it would break the generated Markdown).`,","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/git-ref.ts#L88-L124","documentation":"validateBranchName rejects the single character '@' because git reserves a bare '@' as an alias for HEAD. Since '@' cannot be a real branch name (git's own rule), the validator throws early so callers get a clear InvalidBranchError instead of a git subprocess failure or silent HEAD aliasing.","triggerScenarios":"Calling validateBranchName with branch='@', typically from a truncated revision shortcut like '@', '@~1', or a config/env value that collapsed to just '@'.","commonSituations":"Users typing the git shorthand '@' into a branch field; scripts using `git rev-parse @` output assumptions; templating that lost the rest of the name.","solutions":["Pass the real branch name; resolve '@' with `git rev-parse --abbrev-ref @` first if you want the current branch.","If you intended a revision shortcut ('@', '@~1'), use the commit/revision parameter, not the branch parameter.","Check string slicing/format code that may have dropped the rest of the branch name."],"exampleFix":"// before\nconst branch = \"@\";\nvalidateBranchName(branch);\n// after\nconst branch = execSync(\"git rev-parse --abbrev-ref @\").toString().trim();\nvalidateBranchName(branch);","handlingStrategy":"validation","validationCode":"function isBareAt(name) { return typeof name === \"string\" && name === \"@\"; }\nif (isBareAt(branch)) branch = execSync(\"git rev-parse --abbrev-ref @\").toString().trim();","typeGuard":"function isNotBareAt(v: unknown): v is string {\n  return typeof v === \"string\" && v !== \"@\";\n}","tryCatchPattern":"try {\n  validateBranchName(branch, \"cli\");\n} catch (e) {\n  if (e instanceof InvalidBranchError && e.message.includes('\"@\"')) {\n    console.error(\"'@' is git shorthand for HEAD; pass a real branch name.\");\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["Resolve git's '@' shorthand before using it as a branch name.","Avoid truncating branch-name strings — '@' often means the rest was lost.","Use revision parameters for '@', '@~1', etc., not the branch parameter.","Document that branch parameters require concrete ref names."],"tags":["git","branch-name","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}