{"record":{"id":"d8d27e33781b67bd","repo":"jesseduffield/lazygit","slug":"unexpected-git-output","errorCode":null,"errorMessage":"unexpected git output","messagePattern":"unexpected git output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/commands/git_commands/commit.go","lineNumber":201,"sourceCode":"\ntype Author struct {\n\tName  string\n\tEmail string\n}\n\nfunc (self *CommitCommands) GetCommitAuthor(commitHash string) (Author, error) {\n\tcmdArgs := NewGitCmd(\"show\").\n\t\tArg(\"--no-patch\", \"--pretty=format:%an%x00%ae\", commitHash).\n\t\tToArgv()\n\n\toutput, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()\n\tif err != nil {\n\t\treturn Author{}, err\n\t}\n\n\tsplit := strings.SplitN(strings.TrimSpace(output), \"\\x00\", 2)\n\tif len(split) < 2 {\n\t\treturn Author{}, errors.New(\"unexpected git output\")\n\t}\n\n\tauthor := Author{Name: split[0], Email: split[1]}\n\treturn author, err\n}\n\nfunc (self *CommitCommands) GetCommitMessageFirstLine(hash string) (string, error) {\n\treturn self.GetCommitMessagesFirstLine([]string{hash})\n}\n\nfunc (self *CommitCommands) GetCommitMessagesFirstLine(hashes []string) (string, error) {\n\tcmdArgs := NewGitCmd(\"show\").\n\t\tArg(\"--no-patch\", \"--pretty=format:%s\").\n\t\tArg(hashes...).\n\t\tToArgv()\n\n\treturn self.cmd.New(cmdArgs).DontLog().RunWithOutput()\n}","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/commands/git_commands/commit.go#L183-L219","documentation":"GetCommitAuthor runs `git show --no-patch --pretty=format:%an%x00%ae <hash>` and splits the output on a NUL byte; the error fires when no NUL is present, i.e. the output did not contain both a name and an email separated by %x00. This happens when the commit cannot be shown (git printed an error instead) or the author fields are empty/malformed so git emits nothing before the separator.","triggerScenarios":"Passing a hash that does not exist (typo, abbreviated collision, commit garbage-collected); an author with empty name/email (repo allowing missing ident); git printing a fatal message to stdout in some edge cases; commits from a shallow clone boundary.","commonSituations":"UI flows that resolve authors for commits selected in the log after a background gc/prune removed them; scripts calling GetCommitAuthor with user-supplied hashes; imported repos with malformed author metadata.","solutions":["Verify the commit exists before calling: `git cat-file -e <hash>`","Fix the commit's author metadata if name/email is empty (filter-repo or rebase with --reset-author)","Unshallow the clone if the hash sits at a shallow boundary: `git fetch --unshallow`"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func commitExists(hash string) bool {\n    return exec.Command(\"git\", \"cat-file\", \"-e\", hash+\"^{commit}\").Run() == nil\n}\n\nif !commitExists(commitHash) {\n    return Author{}, fmt.Errorf(\"commit %s not found\", commitHash)\n}\nauthor, err := commitCmd.GetCommitAuthor(commitHash)","typeGuard":null,"tryCatchPattern":"Treat this error as 'author unresolvable for this commit': skip the author display rather than aborting the whole view, and optionally fall back to parsing `git log -1 --format=%an <%ae>` which tolerates missing emails differently.","preventionTips":["Validate hashes with `git cat-file -e <hash>^{commit}` before querying authors","Keep models refreshed so UI code doesn't query pruned commits","Unshallow clones that must reference boundary commits"],"tags":["git","commit-metadata","parsing","edge-case"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}