| 64 | return out === "" || out === DETACHED_HEAD ? null : out; |
| 65 | } catch { |
| 66 | return null; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** Configured `user.name` for the repo, or null when unset. Used as a viewer-identity fallback. */ |
| 71 | export function readGitUserName(repoRoot: string): string | null { |
| 72 | try { |
| 73 | const out = execFileSync("git", ["-C", repoRoot, "config", "user.name"], { |
| 74 | encoding: "utf8", |
| 75 | stdio: ["ignore", "pipe", "ignore"], |
| 76 | }).trim(); |
| 77 | return out || null; |
| 78 | } catch { |
| 79 | return null; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // View-time diffs must force the same a/ b/ prefixes generation-time getRawDiff |
| 84 | // forces, so users with diff.noprefix=true get consistent patches. |