@@ -319,6 +319,35 @@ impl ConsumeHunk for FileDiff {
319
319
}
320
320
}
321
321
322
+ fn file_diff_for_binary_files (
323
+ old_data : gix:: diff:: blob:: platform:: resource:: Data ,
324
+ new_data : gix:: diff:: blob:: platform:: resource:: Data ,
325
+ ) -> FileDiff {
326
+ use gix:: diff:: blob:: platform:: resource:: Data ;
327
+
328
+ let mut file_diff = FileDiff :: default ( ) ;
329
+
330
+ let old_size = match old_data {
331
+ Data :: Missing => 0 ,
332
+ Data :: Buffer { buf, .. } => u64:: conv ( buf. len ( ) ) ,
333
+ Data :: Binary { size } => size,
334
+ } ;
335
+ let new_size = match new_data {
336
+ Data :: Missing => 0 ,
337
+ Data :: Buffer { buf, .. } => u64:: conv ( buf. len ( ) ) ,
338
+ Data :: Binary { size } => size,
339
+ } ;
340
+
341
+ let sizes = ( old_size, new_size) ;
342
+ let size_delta =
343
+ ( i64:: conv ( new_size) ) . saturating_sub ( i64:: conv ( old_size) ) ;
344
+
345
+ file_diff. sizes = sizes;
346
+ file_diff. size_delta = size_delta;
347
+
348
+ file_diff
349
+ }
350
+
322
351
/// returns diff of a specific file either in `stage` or workdir
323
352
pub fn get_diff (
324
353
repo_path : & RepoPath ,
@@ -342,9 +371,6 @@ pub fn get_diff(
342
371
gix_repo
343
372
. head_tree ( ) ?
344
373
. lookup_entry_by_path ( p)
345
- . expect ( "TODO" )
346
- . expect ( "TODO" )
347
- . object_id ( ) ,
348
374
None ,
349
375
)
350
376
} else {
@@ -406,7 +432,10 @@ pub fn get_diff(
406
432
unreachable ! ( "We disabled that" )
407
433
}
408
434
Operation :: SourceOrDestinationIsBinary => {
409
- todo ! ( ) ;
435
+ return Ok ( file_diff_for_binary_files (
436
+ outcome. old . data ,
437
+ outcome. new . data ,
438
+ ) ) ;
410
439
}
411
440
}
412
441
} ;
0 commit comments