| 93 | // HEAD present, stage != HEAD -> M (stage is "version 2") |
| 94 | // otherwise -> ' ' |
| 95 | function indexCode(head: number, stage: number): StatusEntry["index"] { |
| 96 | if (head === 0 && stage > 0) return "A"; |
| 97 | if (head === 1 && stage === 0) return "D"; |
| 98 | // stage === 2 means "differs from HEAD" (anywhere, regardless of workdir); |
| 99 | // stage === 3 means "differs from HEAD but matches workdir" — still a |
| 100 | // staged modification against HEAD. |
| 101 | if (head === 1 && (stage === 2 || stage === 3)) return "M"; |
| 102 | return " "; |
| 103 | } |
| 104 | |
| 105 | // Derive the Y (workdir-vs-index) column. |
| 106 | // workdir absent, anything -> 'D' (deleted in workdir) |