{"record":{"id":"9f400f2aebae57a0","repo":"zed-industries/zed","slug":"tracked-changes-are-present-commit-or-stash-them","errorCode":null,"errorMessage":"tracked changes are present. Commit or stash them, or omit --require-clean.","messagePattern":"tracked changes are present\\. Commit or stash them, or omit --require-clean\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"crates/eval_cli/zed_eval/source.py","lineNumber":245,"sourceCode":"    # remote (see `resolve_remote_ref`); it must be used verbatim because the\n    # launcher may not have that commit fetched locally to `rev-parse`.\n    if pre_resolved_base_sha:\n        resolved_base_sha = pre_resolved_base_sha\n    elif base_sha:\n        resolved_base_sha = resolve_git_ref(base_sha)\n    else:\n        resolved_base_sha = current_base_sha()\n    resolved_repo_url = repo_url or DEFAULT_REPO_URL\n    patch = read_patch(patch_path, resolved_base_sha, clean=clean)\n    patch_sha256 = sha256_text(patch) if patch.strip() else None\n    untracked = [] if clean else untracked_files()\n    is_dirty = bool(patch.strip())\n\n    if untracked and not allow_untracked:\n        raise ValueError(format_untracked_warning(untracked))\n\n    if require_clean and is_dirty:\n        raise ValueError(\n            \"tracked changes are present. Commit or stash them, or omit --require-clean.\"\n        )\n\n    return {\n        \"schema\": SOURCE_SCHEMA_VERSION,\n        \"type\": \"git_patch\",\n        \"repo_url\": resolved_repo_url,\n        \"base_sha\": resolved_base_sha,\n        \"base_ref\": source_label or (base_sha if clean else current_ref_name()),\n        \"patch_sha256\": patch_sha256,\n        \"is_dirty\": is_dirty,\n        \"patch_path\": \"source.patch\" if patch.strip() else None,\n        \"untracked_files\": untracked,\n        \"untracked_files_included\": False,\n        \"allow_untracked\": allow_untracked,\n        \"require_clean\": require_clean,\n        \"clean_source\": clean,\n    }, patch","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/zed_eval/source.py#L227-L263","documentation":"With require_clean set, the source builder refuses to proceed when the computed patch is non-empty — i.e. tracked changes exist in the worktree. It is the stricter sibling of the untracked-files guard: even the patch-recording workflow (is_dirty/patch_sha256) is disallowed, and this ValueError is raised.","triggerScenarios":"Passing --require-clean with unstaged or uncommitted tracked changes; a forgotten stash; a CI checkout contaminated by a previous step that edited files in place (formatter, codegen).","commonSituations":"Release or eval jobs demanding reproducible pristine builds; a formatter rewriting files before the build step; partial stash restores leaving residue.","solutions":["Stash or commit the tracked changes, then rebuild","Drop --require-clean when a dirty patch is acceptable — the patch and its sha256 are recorded either way","In CI, restore the worktree first: git checkout -- . or use a fresh clone","Audit pre-build steps that mutate files in place"],"exampleFix":"# before\nzed-eval build --require-clean   # ValueError: tracked changes are present\n\n# after\ngit stash\ngit status --porcelain   # empty now\nzed-eval build --require-clean\ngit stash pop","handlingStrategy":"validation","validationCode":"import subprocess\n\ndirty = subprocess.run([\"git\", \"diff\", \"--quiet\"], capture_output=True).returncode != 0\nif require_clean and dirty:\n    raise SystemExit(\"worktree has tracked changes; stash or commit before --require-clean\")","typeGuard":null,"tryCatchPattern":"try:\n    source = build_git_patch_source(..., require_clean=True)\nexcept ValueError as err:\n    if \"tracked changes\" in str(err):\n        subprocess.run([\"git\", \"stash\"], check=True)\n        source = build_git_patch_source(..., require_clean=True)\n    else:\n        raise","preventionTips":["Run git diff --quiet in CI before --require-clean builds","Audit pre-build steps that mutate files in place (formatters, codegen)","Decide explicitly per pipeline whether dirty patches are acceptable, instead of flipping the flag reactively"],"tags":["git","dirty-worktree","require-clean","build-patch"],"backgroundTag":"dirty-worktree","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}