@@ -3,11 +3,8 @@ import type {
33 GitDiff ,
44 AnyFileChange ,
55 AnyLineChange ,
6- Chunk ,
76 ChunkRange ,
8- CombinedChunk ,
97 AnyChunk ,
10- FilledGitDiffOptions ,
118 GitDiffOptions ,
129} from './types.js' ;
1310import {
@@ -55,7 +52,6 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
5552 let pathAfter = '' ;
5653 while ( ! ctx . isEof ( ) ) {
5754 const extHeader = parseExtendedHeader ( ctx ) ;
58-
5955 if ( ! extHeader ) {
6056 break ;
6157 }
@@ -129,7 +125,6 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
129125 path : chunks [ 0 ] . pathAfter ,
130126 } ;
131127 }
132-
133128 return ;
134129}
135130
@@ -142,11 +137,14 @@ function parseComparisonInputLine(
142137) : { from : string ; to : string } | null {
143138 const line = ctx . getCurLine ( ) ;
144139 const splitted = line . split ( ' ' ) . reverse ( ) ;
145- const to = splitted . find ( ( p ) => p . startsWith ( 'b/' ) ) ?. replace ( 'b/' , '' ) ;
146- const from = splitted . find ( ( p ) => p . startsWith ( 'a/' ) ) ?. replace ( 'a/' , '' ) ;
140+ const to = splitted . find ( ( p ) => p . startsWith ( 'b/' ) ) ;
141+ const from = splitted . find ( ( p ) => p . startsWith ( 'a/' ) ) ;
147142 ctx . nextLine ( ) ;
148143 if ( to && from ) {
149- return { to, from } ;
144+ return {
145+ from : getFilePath ( ctx , from , 'src' ) ,
146+ to : getFilePath ( ctx , to , 'dst' ) ,
147+ } ;
150148 }
151149 return null ;
152150}
@@ -169,7 +167,6 @@ function parseChunk(context: Context): AnyChunk | undefined {
169167 if ( ! chunkHeader ) {
170168 return ;
171169 }
172-
173170 if ( chunkHeader . type === 'Normal' ) {
174171 const changes = parseChanges (
175172 context ,
@@ -404,4 +401,5 @@ function getFilePath(ctx: Context, input: string, type: 'src' | 'dst') {
404401 }
405402 if ( type === 'src' ) return input . replace ( / ^ a \/ / , '' ) ;
406403 if ( type === 'dst' ) return input . replace ( / ^ b \/ / , '' ) ;
404+ throw new Error ( 'Unexpected unreachable code' ) ;
407405}
0 commit comments