@@ -2516,58 +2516,12 @@ impl Repository {
25162516 theirs : & IndexEntry ,
25172517 opts : Option < & mut MergeFileOptions > ,
25182518 ) -> Result < MergeFileResult < ' _ > , Error > {
2519- let create_raw_entry = |entry : & IndexEntry | -> Result < raw:: git_index_entry , Error > {
2520- let path = CString :: new ( & entry. path [ ..] ) ?;
2521-
2522- // libgit2 encodes the length of the path in the lower bits of the
2523- // `flags` entry, so mask those out and recalculate here to ensure we
2524- // don't corrupt anything.
2525- let mut flags = entry. flags & !raw:: GIT_INDEX_ENTRY_NAMEMASK ;
2526-
2527- if entry. path . len ( ) < raw:: GIT_INDEX_ENTRY_NAMEMASK as usize {
2528- flags |= entry. path . len ( ) as u16 ;
2529- } else {
2530- flags |= raw:: GIT_INDEX_ENTRY_NAMEMASK ;
2531- }
2532-
2533- unsafe {
2534- let raw = raw:: git_index_entry {
2535- dev : entry. dev ,
2536- ino : entry. ino ,
2537- mode : entry. mode ,
2538- uid : entry. uid ,
2539- gid : entry. gid ,
2540- file_size : entry. file_size ,
2541- id : * entry. id . raw ( ) ,
2542- flags,
2543- flags_extended : entry. flags_extended ,
2544- path : path. as_ptr ( ) ,
2545- mtime : raw:: git_index_time {
2546- seconds : entry. mtime . seconds ( ) ,
2547- nanoseconds : entry. mtime . nanoseconds ( ) ,
2548- } ,
2549- ctime : raw:: git_index_time {
2550- seconds : entry. ctime . seconds ( ) ,
2551- nanoseconds : entry. ctime . nanoseconds ( ) ,
2552- } ,
2553- } ;
2554-
2555- Ok ( raw)
2556- }
2557- } ;
2558-
2559- let mut ret = raw:: git_merge_file_result {
2560- automergeable : 0 ,
2561- path : ptr:: null_mut ( ) ,
2562- mode : 0 ,
2563- ptr : ptr:: null_mut ( ) ,
2564- len : 0 ,
2565- } ;
2566- let ancestor = create_raw_entry ( ancestor) ?;
2567- let ours = create_raw_entry ( ours) ?;
2568- let theirs = create_raw_entry ( theirs) ?;
2519+ let ( ancestor, _ancestor_path) = ancestor. to_raw ( ) ?;
2520+ let ( ours, _ours_path) = ours. to_raw ( ) ?;
2521+ let ( theirs, _theirs_path) = theirs. to_raw ( ) ?;
25692522
25702523 unsafe {
2524+ let mut ret = mem:: zeroed ( ) ;
25712525 try_call ! ( raw:: git_merge_file_from_index(
25722526 & mut ret,
25732527 self . raw( ) ,
@@ -4104,6 +4058,7 @@ mod tests {
41044058 . unwrap ( ) ;
41054059
41064060 assert ! ( !merge_file_result. is_automergeable( ) ) ;
4061+ assert_eq ! ( merge_file_result. path( ) , Some ( "file" ) ) ;
41074062 assert_eq ! (
41084063 String :: from_utf8_lossy( merge_file_result. content( ) ) . to_string( ) ,
41094064 r"<<<<<<< ours
0 commit comments