(entries: StatusEntry[])
| 125 | |
| 126 | /** Render `entries` as porcelain v2 lines. */ |
| 127 | export function formatPorcelainV2(entries: StatusEntry[]): string { |
| 128 | // git's porcelain v2 uses headers per record and mode/oid |
| 129 | // fields we don't compute. We emit a simplified shape that |
| 130 | // matches the v2 *changed-files* line prefix (`1 <XY> ...`) |
| 131 | // and the untracked prefix (`? <path>`) — enough for a CLI |
| 132 | // consumer that just wants a programmatic list. The full |
| 133 | // header-with-mtime form is deferred until a caller needs it. |
| 134 | if (entries.length === 0) return ""; |
| 135 | const lines: string[] = []; |
| 136 | for (const e of entries) { |
| 137 | if (e.worktree === "?") { |
| 138 | lines.push(`? ${e.path}`); |
| 139 | } else { |
| 140 | lines.push(`1 ${e.index}${e.worktree} ${e.path}`); |
| 141 | } |
| 142 | } |
| 143 | return `${lines.join("\n")}\n`; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Render `entries` as porcelain v1 lines (`XY <path>`). Identical |
no test coverage detected