@@ -96,7 +96,6 @@ pub struct Expectation {
9696 pub their_side_name : String ,
9797 pub merge_info : MergeInfo ,
9898 pub case_name : String ,
99- pub index : gix_index:: File ,
10099 pub deviation : Option < Deviation > ,
101100}
102101
@@ -171,15 +170,6 @@ impl Iterator for Expectations<'_> {
171170 let our_commit_id = gix_hash:: ObjectId :: from_hex ( our_commit_id. as_bytes ( ) ) . unwrap ( ) ;
172171 let their_commit_id = gix_hash:: ObjectId :: from_hex ( their_commit_id. as_bytes ( ) ) . unwrap ( ) ;
173172 let merge_info = parse_merge_info ( std:: fs:: read_to_string ( subdir_path. join ( merge_info_filename) ) . unwrap ( ) ) ;
174- let index = gix_index:: File :: at (
175- subdir_path
176- . join ( ".git" )
177- . join ( format ! ( "{conflict_style_name}-{our_side_name}-{their_side_name}.index" ) ) ,
178- gix_hash:: Kind :: Sha1 ,
179- false , /* skip hash */
180- Default :: default ( ) ,
181- )
182- . expect ( "index should be present for each combination" ) ;
183173 Some ( Expectation {
184174 root : subdir_path,
185175 conflict_style,
@@ -189,7 +179,6 @@ impl Iterator for Expectations<'_> {
189179 their_commit_id,
190180 their_side_name : their_side_name. to_owned ( ) ,
191181 merge_info,
192- index,
193182 case_name : format ! (
194183 "{subdir}-{}" ,
195184 merge_info_filename
@@ -377,3 +366,35 @@ pub fn show_diff_and_fail(
377366 expected. information
378367 ) ;
379368}
369+
370+ pub ( crate ) fn apply_git_index_entries ( conflicts : Vec < Conflict > , state : & mut gix_index:: State ) {
371+ let len = state. entries ( ) . len ( ) ;
372+ for Conflict { ours, theirs, ancestor } in conflicts {
373+ for ( entry, stage) in [
374+ ancestor. map ( |e| ( e, gix_index:: entry:: Stage :: Base ) ) ,
375+ ours. map ( |e| ( e, gix_index:: entry:: Stage :: Ours ) ) ,
376+ theirs. map ( |e| ( e, gix_index:: entry:: Stage :: Theirs ) ) ,
377+ ]
378+ . into_iter ( )
379+ . filter_map ( std:: convert:: identity)
380+ {
381+ if let Some ( pos) = state. entry_index_by_path_and_stage_bounded (
382+ entry. location . as_str ( ) . into ( ) ,
383+ gix_index:: entry:: Stage :: Unconflicted ,
384+ len,
385+ ) {
386+ state. entries_mut ( ) [ pos] . flags . insert ( gix_index:: entry:: Flags :: REMOVE )
387+ }
388+
389+ state. dangerously_push_entry (
390+ Default :: default ( ) ,
391+ entry. id ,
392+ gix_index:: entry:: Flags :: empty ( ) | gix_index:: entry:: Flags :: from_bits ( ( stage as u32 ) << 12 ) . unwrap ( ) ,
393+ entry. mode . into ( ) ,
394+ entry. location . as_str ( ) . into ( ) ,
395+ ) ;
396+ }
397+ }
398+ state. sort_entries ( ) ;
399+ state. remove_entries ( |_, _, e| e. flags . contains ( gix_index:: entry:: Flags :: REMOVE ) ) ;
400+ }
0 commit comments