@@ -3424,6 +3424,8 @@ mod tests {
3424
3424
3425
3425
assert ! ( index. has_conflicts( ) , "index should have conflicts" ) ;
3426
3426
3427
+ let mut conflict_count = 0 ;
3428
+
3427
3429
let index_conflicts = index. conflicts ( ) . unwrap ( ) ;
3428
3430
for conflict in index_conflicts {
3429
3431
let conflict = conflict. unwrap ( ) ;
@@ -3437,41 +3439,56 @@ mod tests {
3437
3439
let theirs_blob;
3438
3440
3439
3441
if let Some ( ancestor) = conflict. ancestor {
3440
- ancestor_blob = repo
3441
- . find_blob ( ancestor. id . clone ( ) )
3442
- . expect ( "failed to find blob of index entry to make MergeFileInput" ) ;
3443
- let ancestor_content = ancestor_blob. content ( ) ;
3444
- let mut input = MergeFileInput :: new ( ) ;
3445
- input. path ( String :: from_utf8 ( ancestor. path ) . unwrap ( ) ) ;
3446
- input. mode ( Some ( FileMode :: from ( ancestor. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3447
- input. content ( Some ( & ancestor_content) ) ;
3448
- ancestor_input = Some ( input) ;
3442
+ match repo. find_blob ( ancestor. id . clone ( ) ) {
3443
+ Ok ( b) => {
3444
+ ancestor_blob = b;
3445
+ let ancestor_content = ancestor_blob. content ( ) ;
3446
+ let mut input = MergeFileInput :: new ( ) ;
3447
+ input. path ( String :: from_utf8 ( ancestor. path ) . unwrap ( ) ) ;
3448
+ input. mode ( Some ( FileMode :: from ( ancestor. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3449
+ input. content ( Some ( & ancestor_content) ) ;
3450
+ ancestor_input = Some ( input) ;
3451
+ }
3452
+ Err ( _e) => {
3453
+ ancestor_input = None ;
3454
+ }
3455
+ }
3449
3456
} else {
3450
3457
ancestor_input = None ;
3451
3458
}
3452
3459
if let Some ( ours) = conflict. our {
3453
- ours_blob = repo
3454
- . find_blob ( ours. id . clone ( ) )
3455
- . expect ( "failed to find blob of index entry to make MergeFileInput" ) ;
3456
- let ours_content = ours_blob. content ( ) ;
3457
- let mut input = MergeFileInput :: new ( ) ;
3458
- input. path ( String :: from_utf8 ( ours. path ) . unwrap ( ) ) ;
3459
- input. mode ( Some ( FileMode :: from ( ours. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3460
- input. content ( Some ( & ours_content) ) ;
3461
- ours_input = Some ( input) ;
3460
+ match repo. find_blob ( ours. id . clone ( ) ) {
3461
+ Ok ( b) => {
3462
+ ours_blob = b;
3463
+ let ours_content = ours_blob. content ( ) ;
3464
+ let mut input = MergeFileInput :: new ( ) ;
3465
+ input. path ( String :: from_utf8 ( ours. path ) . unwrap ( ) ) ;
3466
+ input. mode ( Some ( FileMode :: from ( ours. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3467
+ input. content ( Some ( & ours_content) ) ;
3468
+ ours_input = Some ( input) ;
3469
+ }
3470
+ Err ( _e) => {
3471
+ ours_input = None ;
3472
+ }
3473
+ }
3462
3474
} else {
3463
3475
ours_input = None ;
3464
3476
}
3465
3477
if let Some ( theirs) = conflict. their {
3466
- theirs_blob = repo
3467
- . find_blob ( theirs. id . clone ( ) )
3468
- . expect ( "failed to find blob of index entry to make MergeFileInput" ) ;
3469
- let theirs_content = theirs_blob. content ( ) ;
3470
- let mut input = MergeFileInput :: new ( ) ;
3471
- input. path ( String :: from_utf8 ( theirs. path ) . unwrap ( ) ) ;
3472
- input. mode ( Some ( FileMode :: from ( theirs. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3473
- input. content ( Some ( & theirs_content) ) ;
3474
- theirs_input = Some ( input) ;
3478
+ match repo. find_blob ( theirs. id . clone ( ) ) {
3479
+ Ok ( b) => {
3480
+ theirs_blob = b;
3481
+ let theirs_content = theirs_blob. content ( ) ;
3482
+ let mut input = MergeFileInput :: new ( ) ;
3483
+ input. path ( String :: from_utf8 ( theirs. path ) . unwrap ( ) ) ;
3484
+ input. mode ( Some ( FileMode :: from ( theirs. mode . try_into ( ) . unwrap ( ) ) ) ) ;
3485
+ input. content ( Some ( & theirs_content) ) ;
3486
+ theirs_input = Some ( input) ;
3487
+ }
3488
+ Err ( _e) => {
3489
+ theirs_input = None ;
3490
+ }
3491
+ }
3475
3492
} else {
3476
3493
theirs_input = None ;
3477
3494
}
@@ -3498,7 +3515,10 @@ mod tests {
3498
3515
} ,
3499
3516
merge_file_result_content
3500
3517
) ;
3518
+
3519
+ conflict_count += 1 ;
3501
3520
}
3521
+ assert_eq ! ( conflict_count, 1 , "There should be one conflict!" ) ;
3502
3522
}
3503
3523
3504
3524
/// create the following:
0 commit comments