{"record":{"id":"902e1d52b94d83fc","repo":"lapce/lapce","slug":"error-while-creating-commit-s-signature","errorCode":null,"errorMessage":"Error while creating commit's signature: {}","messagePattern":"Error while creating commit's signature: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lapce-proxy/src/dispatch.rs","lineNumber":1437,"sourceCode":"                .and_then(|head| Ok(vec![head.peel_to_commit()?]))\n                .unwrap_or(vec![]);\n            let parents_refs = parents.iter().collect::<Vec<_>>();\n\n            repo.commit(\n                Some(\"HEAD\"),\n                &signature,\n                &signature,\n                message,\n                &tree,\n                &parents_refs,\n            )?;\n            Ok(())\n        }\n        Err(e) => match e.code() {\n            NotFound => Err(anyhow!(\n                \"No user.name and/or user.email configured for this git repository.\"\n            )),\n            _ => Err(anyhow!(\n                \"Error while creating commit's signature: {}\",\n                e.message()\n            )),\n        },\n    }\n}\n\nfn git_checkout(workspace_path: &Path, reference: &str) -> Result<()> {\n    let repo = Repository::discover(workspace_path)?;\n    let (object, reference) = repo.revparse_ext(reference)?;\n    repo.checkout_tree(&object, None)?;\n    repo.set_head(reference.unwrap().name().unwrap())?;\n    Ok(())\n}\n\nfn git_discard_files_changes<'a>(\n    workspace_path: &Path,\n    files: impl Iterator<Item = &'a Path>,","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/lapce/lapce/blob/c9e4c33948033f10f003991a037d949a708eedf8/lapce-proxy/src/dispatch.rs#L1419-L1455","documentation":"The catch-all arm of the same signature match in lapce-proxy/src/dispatch.rs:1437: libgit2 failed to create the commit signature with an error code other than NotFound, and libgit2's own message is interpolated. Typical codes are malformed config values (user.name containing '<'/newlines, invalid user.email), config files that fail to parse, or I/O errors reading .git/config.","triggerScenarios":"git2's signature lookup returns e.g. a parse/invalid-spec error: user.name set to 'Name <email>' (double-wrapping), user.email missing '@', .git/config with syntax errors or a stale .git/config.lock, or permission problems reading system config.","commonSituations":"Users pasting a full 'Name <email>' string into user.name; hand-edited config files with typos; crashed git processes leaving config.lock behind; shared machines with unreadable /etc/gitconfig.","solutions":["Read the embedded libgit2 message — it names the exact config defect","Reproduce in a terminal: git commit --allow-empty to get git's own diagnosis","git config --global --edit and fix/flatten user.name and user.email to plain values","Remove stale .git/config.lock (and ~/.gitconfig.lock) if present","git config --list --show-origin to find which file carries the bad value"],"exampleFix":"# before\n# user.name accidentally contains the email too\ngit config --global user.name 'Ada <ada@example.com>'\n\n# after\ngit config --global user.name 'Ada Lovelace'\ngit config --global user.email 'ada@example.com'","handlingStrategy":"try-catch","validationCode":"// Validate config shape before committing: names must be plain, email must contain '@'\nlet name = repo.config()?.get_string(\"user.name\")?;\nlet email = repo.config()?.get_string(\"user.email\")?;\nif name.contains('<') || !email.contains('@') {\n    return Err(anyhow!(\"malformed git identity: user.name='{name}', user.email='{email}'\"));\n}","typeGuard":null,"tryCatchPattern":"match git_commit(workspace_path, message, staged) {\n    Err(e) if e.to_string().contains(\"commit's signature\") => {\n        // embed libgit2's message; suggest terminal reproduction\n        Err(e.context(\"run `git commit` in a terminal to see git's own diagnosis\"))\n    }\n    other => other,\n}?","preventionTips":["Never paste 'Name <email>' into user.name — keep the two config values separate","git config --list --show-origin after hand-editing config files","Delete stale .git/config.lock after crashed git processes"],"tags":["git","configuration","commit","rust"],"backgroundTag":null,"analyzedSha":"c9e4c33948033f10f003991a037d949a708eedf8","analyzedAt":"2026-08-16T11:46:13.210Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}