@@ -74,12 +74,28 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
74
74
chunks,
75
75
path : changeMarkers . deleted ,
76
76
} ;
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
+ } ;
77
87
} else if ( isNew && changeMarkers ) {
78
88
return {
79
89
type : FileType . Added ,
80
90
chunks,
81
91
path : changeMarkers . added ,
82
92
} ;
93
+ } else if ( isNew && chunks . length && chunks [ 0 ] . type === 'BinaryFilesChunk' ) {
94
+ return {
95
+ type : FileType . Added ,
96
+ chunks,
97
+ path : chunks [ 0 ] . pathAfter ,
98
+ } ;
83
99
} else if ( isRename ) {
84
100
return {
85
101
type : FileType . Renamed ,
@@ -93,7 +109,18 @@ function parseFileChange(ctx: Context): AnyFileChange | undefined {
93
109
chunks,
94
110
path : changeMarkers . added ,
95
111
} ;
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
+ } ;
96
122
}
123
+
97
124
return ;
98
125
}
99
126
@@ -148,6 +175,16 @@ function parseChunk(context: Context): AnyChunk | undefined {
148
175
type : 'CombinedChunk' ,
149
176
changes,
150
177
} ;
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
+ } ;
151
188
}
152
189
}
153
190
@@ -184,6 +221,19 @@ function parseChunkHeader(ctx: Context) {
184
221
) ;
185
222
186
223
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
+
187
237
return null ;
188
238
}
189
239
@@ -206,6 +256,7 @@ function parseChunkHeader(ctx: Context) {
206
256
toFileRange : getRange ( addStart , addLines ) ,
207
257
} as const ;
208
258
}
259
+
209
260
const [ all , delStart , delLines , addStart , addLines , context ] =
210
261
normalChunkExec ;
211
262
ctx . nextLine ( ) ;
0 commit comments