@@ -3424,6 +3424,8 @@ mod tests {
34243424
34253425 assert ! ( index. has_conflicts( ) , "index should have conflicts" ) ;
34263426
3427+ let mut conflict_count = 0 ;
3428+
34273429 let index_conflicts = index. conflicts ( ) . unwrap ( ) ;
34283430 for conflict in index_conflicts {
34293431 let conflict = conflict. unwrap ( ) ;
@@ -3437,41 +3439,56 @@ mod tests {
34373439 let theirs_blob;
34383440
34393441 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+ }
34493456 } else {
34503457 ancestor_input = None ;
34513458 }
34523459 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+ }
34623474 } else {
34633475 ours_input = None ;
34643476 }
34653477 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+ }
34753492 } else {
34763493 theirs_input = None ;
34773494 }
@@ -3498,7 +3515,10 @@ mod tests {
34983515 } ,
34993516 merge_file_result_content
35003517 ) ;
3518+
3519+ conflict_count += 1 ;
35013520 }
3521+ assert_eq ! ( conflict_count, 1 , "There should be one conflict!" ) ;
35023522 }
35033523
35043524 /// create the following:
0 commit comments