@@ -97,74 +97,102 @@ fn worktree_changes_inner(
97
97
let work_dir = repo. workdir ( ) . context ( "need non-bare repository" ) ?;
98
98
let mut tmp = Vec :: new ( ) ;
99
99
let mut ignored_changes = Vec :: new ( ) ;
100
+ let mut index_conflicts = Vec :: new ( ) ;
101
+ let mut index_changes = Vec :: new ( ) ;
100
102
for change in status_changes {
101
103
let change = change?;
102
- let change = match change. clone ( ) {
104
+ let change = match change {
103
105
status:: Item :: TreeIndex ( gix:: diff:: index:: Change :: Deletion {
104
106
location,
107
+ index,
105
108
id,
106
109
entry_mode,
107
- ..
108
- } ) => (
109
- Origin :: TreeIndex ,
110
- TreeChange {
111
- status : TreeStatus :: Deletion {
112
- previous_state : ChangeState {
113
- id : id. into_owned ( ) ,
114
- kind : into_tree_entry_kind ( entry_mode) ?,
110
+ } ) => {
111
+ let res = (
112
+ Origin :: TreeIndex ,
113
+ TreeChange {
114
+ status : TreeStatus :: Deletion {
115
+ previous_state : ChangeState {
116
+ id : id. clone ( ) . into_owned ( ) ,
117
+ kind : into_tree_entry_kind ( entry_mode) ?,
118
+ } ,
115
119
} ,
120
+ path : location. clone ( ) . into_owned ( ) ,
116
121
} ,
117
- path : location. into_owned ( ) ,
118
- status_item : Some ( change) ,
119
- } ,
120
- ) ,
122
+ ) ;
123
+ index_changes. push ( gix:: diff:: index:: Change :: Deletion {
124
+ location,
125
+ index,
126
+ id,
127
+ entry_mode,
128
+ } ) ;
129
+ res
130
+ }
121
131
status:: Item :: TreeIndex ( gix:: diff:: index:: Change :: Addition {
122
132
location,
133
+ index,
123
134
entry_mode,
124
135
id,
125
- ..
126
- } ) => (
127
- Origin :: TreeIndex ,
128
- TreeChange {
129
- path : location. into_owned ( ) ,
130
- status : TreeStatus :: Addition {
131
- is_untracked : false ,
132
- state : ChangeState {
133
- id : id. into_owned ( ) ,
134
- kind : into_tree_entry_kind ( entry_mode) ?,
136
+ } ) => {
137
+ let res = (
138
+ Origin :: TreeIndex ,
139
+ TreeChange {
140
+ path : location. clone ( ) . into_owned ( ) ,
141
+ status : TreeStatus :: Addition {
142
+ is_untracked : false ,
143
+ state : ChangeState {
144
+ id : id. clone ( ) . into_owned ( ) ,
145
+ kind : into_tree_entry_kind ( entry_mode) ?,
146
+ } ,
135
147
} ,
136
148
} ,
137
- status_item : Some ( change) ,
138
- } ,
139
- ) ,
149
+ ) ;
150
+ index_changes. push ( gix:: diff:: index:: ChangeRef :: Addition {
151
+ location,
152
+ index,
153
+ entry_mode,
154
+ id,
155
+ } ) ;
156
+ res
157
+ }
140
158
status:: Item :: TreeIndex ( gix:: diff:: index:: Change :: Modification {
141
159
location,
160
+ previous_index,
142
161
previous_entry_mode,
162
+ index,
143
163
entry_mode,
144
164
previous_id,
145
165
id,
146
- ..
147
166
} ) => {
148
167
let previous_state = ChangeState {
149
- id : previous_id. into_owned ( ) ,
168
+ id : previous_id. clone ( ) . into_owned ( ) ,
150
169
kind : into_tree_entry_kind ( previous_entry_mode) ?,
151
170
} ;
152
171
let state = ChangeState {
153
- id : id. into_owned ( ) ,
172
+ id : id. clone ( ) . into_owned ( ) ,
154
173
kind : into_tree_entry_kind ( entry_mode) ?,
155
174
} ;
156
- (
175
+ let res = (
157
176
Origin :: TreeIndex ,
158
177
TreeChange {
159
- path : location. into_owned ( ) ,
178
+ path : location. clone ( ) . into_owned ( ) ,
160
179
status : TreeStatus :: Modification {
161
180
previous_state,
162
181
state,
163
182
flags : ModeFlags :: calculate ( & previous_state, & state) ,
164
183
} ,
165
- status_item : Some ( change) ,
166
184
} ,
167
- )
185
+ ) ;
186
+ index_changes. push ( gix:: diff:: index:: Change :: Modification {
187
+ location,
188
+ previous_index,
189
+ previous_entry_mode,
190
+ previous_id,
191
+ index,
192
+ entry_mode,
193
+ id,
194
+ } ) ;
195
+ res
168
196
}
169
197
status:: Item :: IndexWorktree ( index_worktree:: Item :: Modification {
170
198
rela_path,
@@ -181,7 +209,6 @@ fn worktree_changes_inner(
181
209
kind : into_tree_entry_kind ( entry. mode ) ?,
182
210
} ,
183
211
} ,
184
- status_item : Some ( change) ,
185
212
} ,
186
213
) ,
187
214
status:: Item :: IndexWorktree ( index_worktree:: Item :: Modification {
@@ -208,7 +235,6 @@ fn worktree_changes_inner(
208
235
state,
209
236
flags : ModeFlags :: calculate ( & previous_state, & state) ,
210
237
} ,
211
- status_item : Some ( change) ,
212
238
} ,
213
239
)
214
240
}
@@ -245,7 +271,6 @@ fn worktree_changes_inner(
245
271
state,
246
272
flags : ModeFlags :: calculate ( & previous_state, & state) ,
247
273
} ,
248
- status_item : Some ( change) ,
249
274
} ,
250
275
)
251
276
}
@@ -267,7 +292,6 @@ fn worktree_changes_inner(
267
292
} ,
268
293
is_untracked : false ,
269
294
} ,
270
- status_item : Some ( change) ,
271
295
} ,
272
296
) ,
273
297
status:: Item :: IndexWorktree ( index_worktree:: Item :: DirectoryContents {
@@ -300,7 +324,6 @@ fn worktree_changes_inner(
300
324
} ,
301
325
is_untracked : true ,
302
326
} ,
303
- status_item : Some ( change) ,
304
327
} ,
305
328
)
306
329
}
@@ -340,7 +363,6 @@ fn worktree_changes_inner(
340
363
state,
341
364
flags : ModeFlags :: calculate ( & previous_state, & state) ,
342
365
} ,
343
- status_item : Some ( change) ,
344
366
} ,
345
367
)
346
368
}
@@ -396,7 +418,6 @@ fn worktree_changes_inner(
396
418
state,
397
419
flags : ModeFlags :: calculate ( & previous_state, & state) ,
398
420
} ,
399
- status_item : Some ( change) ,
400
421
} ,
401
422
)
402
423
}
@@ -427,19 +448,18 @@ fn worktree_changes_inner(
427
448
state,
428
449
flags : ModeFlags :: calculate ( & previous_state, & state) ,
429
450
} ,
430
- status_item : Some ( change) ,
431
451
} ,
432
452
)
433
453
}
434
454
status:: Item :: IndexWorktree ( index_worktree:: Item :: Modification {
435
455
rela_path,
436
- status : EntryStatus :: Conflict { .. } ,
456
+ status : EntryStatus :: Conflict { entries , .. } ,
437
457
..
438
458
} ) => {
459
+ index_conflicts. push ( ( rela_path. clone ( ) , entries) ) ;
439
460
ignored_changes. push ( IgnoredWorktreeChange {
440
461
path : rela_path,
441
462
status : IgnoredWorktreeTreeChangeStatus :: Conflict ,
442
- status_item : Some ( change) ,
443
463
} ) ;
444
464
continue ;
445
465
}
@@ -479,7 +499,6 @@ fn worktree_changes_inner(
479
499
let mut path_check = gix:: status:: plumbing:: SymlinkCheck :: new (
480
500
repo. workdir ( ) . map ( ToOwned :: to_owned) . context ( "non-bare" ) ?,
481
501
) ;
482
- let original_changes = tmp. iter ( ) . map ( |( _, change) | change. clone ( ) ) . collect ( ) ;
483
502
for ( _origin, change) in tmp {
484
503
// At this point we know that the current `change` is the tree/index variant
485
504
// of a prior change between index/worktree.
@@ -509,17 +528,15 @@ fn worktree_changes_inner(
509
528
changes. push ( merged) ;
510
529
IgnoredWorktreeTreeChangeStatus :: TreeIndex
511
530
}
512
- [ Some ( mut first) , Some ( mut second) ] => {
531
+ [ Some ( first) , Some ( second) ] => {
513
532
ignored_changes. push ( IgnoredWorktreeChange {
514
533
path : first. path . clone ( ) ,
515
534
status : IgnoredWorktreeTreeChangeStatus :: TreeIndex ,
516
- status_item : first. status_item . take ( ) ,
517
535
} ) ;
518
536
changes. push ( first) ;
519
537
ignored_changes. push ( IgnoredWorktreeChange {
520
538
path : second. path . clone ( ) ,
521
539
status : IgnoredWorktreeTreeChangeStatus :: TreeIndex ,
522
- status_item : second. status_item . take ( ) ,
523
540
} ) ;
524
541
changes. push ( second) ;
525
542
continue ;
@@ -528,7 +545,6 @@ fn worktree_changes_inner(
528
545
ignored_changes. push ( IgnoredWorktreeChange {
529
546
path : change_path,
530
547
status,
531
- status_item : None ,
532
548
} ) ;
533
549
continue ;
534
550
}
@@ -539,7 +555,8 @@ fn worktree_changes_inner(
539
555
Ok ( WorktreeChanges {
540
556
changes,
541
557
ignored_changes,
542
- original_changes,
558
+ index_changes,
559
+ index_conflicts,
543
560
} )
544
561
}
545
562
@@ -698,8 +715,6 @@ fn merge_changes(
698
715
status : TreeStatus :: Deletion {
699
716
previous_state : * previous_state,
700
717
} ,
701
- // NOTE: not relevant, as renames are disabled for snapshots where this is used.
702
- status_item : None ,
703
718
} ) ) ;
704
719
}
705
720
(
@@ -719,8 +734,6 @@ fn merge_changes(
719
734
// It's just in the index, which to us doesn't exist.
720
735
is_untracked : true ,
721
736
} ,
722
- // NOTE: not relevant, as renames are disabled for snapshots where this is used.
723
- status_item : None ,
724
737
} ) ,
725
738
Some ( TreeChange {
726
739
path : index_wt. path ,
@@ -732,8 +745,6 @@ fn merge_changes(
732
745
// read the initial state of a file from.
733
746
is_untracked : true ,
734
747
} ,
735
- // NOTE: not relevant, as renames are disabled for snapshots where this is used.
736
- status_item : None ,
737
748
} ) ,
738
749
] ) ;
739
750
}
0 commit comments