| 126 | } |
| 127 | }, |
| 128 | }, |
| 129 | ]; |
| 130 | } |
| 131 | |
| 132 | const MINUS_RE = /^--- (.+)$/m; |
| 133 | const PLUS_RE = /^\+\+\+ (.+)$/m; |
| 134 | const BINARY_RE = /^Binary files|^GIT binary patch/m; |
| 135 | // Mode 120000 marks a symlink. Old and new sides are detected separately so a |
| 136 | // symlink<->regular transition (old mode/new mode pairs) fetches each side with |
| 137 | // the right reader instead of treating both as links. |
| 138 | const OLD_MODE_RE = /^(?:old mode|deleted file mode) (\d{6})$/m; |
| 139 | const NEW_MODE_RE = /^(?:new mode|new file mode) (\d{6})$/m; |
| 140 | const INDEX_MODE_RE = /^index [0-9a-f]+\.\.[0-9a-f]+ (\d{6})$/m; |
| 141 | const SYMLINK_MODE = "120000"; |
| 142 | const RENAME_FROM_RE = /^(?:rename|copy) from (.+)$/m; |
| 143 | const RENAME_TO_RE = /^(?:rename|copy) to (.+)$/m; |
| 144 | // `diff --git "a/x y" "b/x y"` — git quotes paths containing spaces or specials. |
| 145 | const DIFF_GIT_QUOTED_RE = /^diff --git "a\/((?:[^"\\]|\\.)+)" "b\/((?:[^"\\]|\\.)+)"$/m; |
| 146 | const DIFF_GIT_RE = /^diff --git a\/(.+) b\/(.+)$/m; |
| 147 | |
| 148 | interface ParsedFilePaths { |
| 149 | oldPath: string | null; |
| 150 | newPath: string | null; |
| 151 | isBinary: boolean; |
| 152 | oldIsSymlink: boolean; |
| 153 | newIsSymlink: boolean; |
| 154 | /** |
| 155 | * A pure rename/copy (100% similarity) emits only `similarity index` + |