@@ -2577,58 +2577,12 @@ impl Repository {
25772577 theirs : & IndexEntry ,
25782578 opts : Option < & mut MergeFileOptions > ,
25792579 ) -> 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 ( ) ?;
26302583
26312584 unsafe {
2585+ let mut ret = mem:: zeroed ( ) ;
26322586 try_call ! ( raw:: git_merge_file_from_index(
26332587 & mut ret,
26342588 self . raw( ) ,
@@ -4182,6 +4136,7 @@ mod tests {
41824136 . unwrap ( ) ;
41834137
41844138 assert ! ( !merge_file_result. is_automergeable( ) ) ;
4139+ assert_eq ! ( merge_file_result. path( ) , Some ( "file" ) ) ;
41854140 assert_eq ! (
41864141 String :: from_utf8_lossy( merge_file_result. content( ) ) . to_string( ) ,
41874142 r"<<<<<<< ours
0 commit comments