@@ -74,12 +74,28 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
7474 chunks,
7575 path : changeMarkers . deleted ,
7676 } ;
77+ } else if (
78+ isDeleted &&
79+ chunks . length &&
80+ chunks [ 0 ] . type === 'BinaryFilesChunk'
81+ ) {
82+ return {
83+ type : FileType . Deleted ,
84+ chunks,
85+ path : chunks [ 0 ] . pathBefore ,
86+ } ;
7787 } else if ( isNew && changeMarkers ) {
7888 return {
7989 type : FileType . Added ,
8090 chunks,
8191 path : changeMarkers . added ,
8292 } ;
93+ } else if ( isNew && chunks . length && chunks [ 0 ] . type === 'BinaryFilesChunk' ) {
94+ return {
95+ type : FileType . Added ,
96+ chunks,
97+ path : chunks [ 0 ] . pathAfter ,
98+ } ;
8399 } else if ( isRename ) {
84100 return {
85101 type : FileType . Renamed ,
@@ -93,7 +109,18 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
93109 chunks,
94110 path : changeMarkers . added ,
95111 } ;
112+ } else if (
113+ chunks . length &&
114+ chunks [ 0 ] . type === 'BinaryFilesChunk' &&
115+ chunks [ 0 ] . pathAfter === chunks [ 0 ] . pathBefore
116+ ) {
117+ return {
118+ type : FileType . Changed ,
119+ chunks,
120+ path : chunks [ 0 ] . pathAfter ,
121+ } ;
96122 }
123+
97124 return ;
98125}
99126
@@ -148,6 +175,16 @@ function parseChunk(context: Context): AnyChunk | undefined {
148175 type : 'CombinedChunk' ,
149176 changes,
150177 } ;
178+ } else if (
179+ chunkHeader . type === 'BinaryFiles' &&
180+ chunkHeader . fileA &&
181+ chunkHeader . fileB
182+ ) {
183+ return {
184+ type : 'BinaryFilesChunk' ,
185+ pathBefore : chunkHeader . fileA ,
186+ pathAfter : chunkHeader . fileB ,
187+ } ;
151188 }
152189}
153190
@@ -184,6 +221,19 @@ function parseChunkHeader(ctx: Context) {
184221 ) ;
185222
186223 if ( ! combinedChunkExec ) {
224+ const binaryChunkExec = / ^ B i n a r y \s f i l e s \s ( .* ) \s a n d \s ( .* ) \s d i f f e r $ / . exec (
225+ line
226+ ) ;
227+ if ( binaryChunkExec ) {
228+ const [ all , fileA , fileB ] = binaryChunkExec ;
229+ ctx . nextLine ( ) ;
230+ return {
231+ type : 'BinaryFiles' ,
232+ fileA : fileA . replace ( 'a/' , '' ) ,
233+ fileB : fileB . replace ( 'b/' , '' ) ,
234+ } as const ;
235+ }
236+
187237 return null ;
188238 }
189239
@@ -206,6 +256,7 @@ function parseChunkHeader(ctx: Context) {
206256 toFileRange : getRange ( addStart , addLines ) ,
207257 } as const ;
208258 }
259+
209260 const [ all , delStart , delLines , addStart , addLines , context ] =
210261 normalChunkExec ;
211262 ctx . nextLine ( ) ;
0 commit comments