@@ -2577,58 +2577,12 @@ impl Repository {
2577
2577
theirs : & IndexEntry ,
2578
2578
opts : Option < & mut MergeFileOptions > ,
2579
2579
) -> Result < MergeFileResult < ' _ > , Error > {
2580
- let create_raw_entry = |entry : & IndexEntry | -> Result < raw:: git_index_entry , Error > {
2581
- let path = CString :: new ( & entry. path [ ..] ) ?;
2582
-
2583
- // libgit2 encodes the length of the path in the lower bits of the
2584
- // `flags` entry, so mask those out and recalculate here to ensure we
2585
- // don't corrupt anything.
2586
- let mut flags = entry. flags & !raw:: GIT_INDEX_ENTRY_NAMEMASK ;
2587
-
2588
- if entry. path . len ( ) < raw:: GIT_INDEX_ENTRY_NAMEMASK as usize {
2589
- flags |= entry. path . len ( ) as u16 ;
2590
- } else {
2591
- flags |= raw:: GIT_INDEX_ENTRY_NAMEMASK ;
2592
- }
2593
-
2594
- unsafe {
2595
- let raw = raw:: git_index_entry {
2596
- dev : entry. dev ,
2597
- ino : entry. ino ,
2598
- mode : entry. mode ,
2599
- uid : entry. uid ,
2600
- gid : entry. gid ,
2601
- file_size : entry. file_size ,
2602
- id : * entry. id . raw ( ) ,
2603
- flags,
2604
- flags_extended : entry. flags_extended ,
2605
- path : path. as_ptr ( ) ,
2606
- mtime : raw:: git_index_time {
2607
- seconds : entry. mtime . seconds ( ) ,
2608
- nanoseconds : entry. mtime . nanoseconds ( ) ,
2609
- } ,
2610
- ctime : raw:: git_index_time {
2611
- seconds : entry. ctime . seconds ( ) ,
2612
- nanoseconds : entry. ctime . nanoseconds ( ) ,
2613
- } ,
2614
- } ;
2615
-
2616
- Ok ( raw)
2617
- }
2618
- } ;
2619
-
2620
- let mut ret = raw:: git_merge_file_result {
2621
- automergeable : 0 ,
2622
- path : ptr:: null_mut ( ) ,
2623
- mode : 0 ,
2624
- ptr : ptr:: null_mut ( ) ,
2625
- len : 0 ,
2626
- } ;
2627
- let ancestor = create_raw_entry ( ancestor) ?;
2628
- let ours = create_raw_entry ( ours) ?;
2629
- let theirs = create_raw_entry ( theirs) ?;
2580
+ let ( ancestor, _ancestor_path) = ancestor. to_raw ( ) ?;
2581
+ let ( ours, _ours_path) = ours. to_raw ( ) ?;
2582
+ let ( theirs, _theirs_path) = theirs. to_raw ( ) ?;
2630
2583
2631
2584
unsafe {
2585
+ let mut ret = mem:: zeroed ( ) ;
2632
2586
try_call ! ( raw:: git_merge_file_from_index(
2633
2587
& mut ret,
2634
2588
self . raw( ) ,
@@ -4182,6 +4136,7 @@ mod tests {
4182
4136
. unwrap ( ) ;
4183
4137
4184
4138
assert ! ( !merge_file_result. is_automergeable( ) ) ;
4139
+ assert_eq ! ( merge_file_result. path( ) , Some ( "file" ) ) ;
4185
4140
assert_eq ! (
4186
4141
String :: from_utf8_lossy( merge_file_result. content( ) ) . to_string( ) ,
4187
4142
r"<<<<<<< ours
0 commit comments