@@ -107,7 +107,7 @@ impl Graph {
107
107
gix:: head:: Kind :: Unborn ( ref_name) => {
108
108
let mut graph = Graph :: default ( ) ;
109
109
graph. insert_root ( branch_segment_from_name_and_meta (
110
- Some ( ref_name) ,
110
+ Some ( ( ref_name, None ) ) ,
111
111
meta,
112
112
None ,
113
113
) ?) ;
@@ -177,10 +177,10 @@ impl Graph {
177
177
hard_limit,
178
178
} : Options ,
179
179
) -> anyhow:: Result < Self > {
180
- let limit = Limit :: from ( limit) ;
180
+ let repo = tip. repo ;
181
+ let max_limit = Limit :: new ( limit, repo. object_hash ( ) ) ;
181
182
// TODO: also traverse (outside)-branches that ought to be in the workspace. That way we have the desired ones
182
183
// automatically and just have to find a way to prune the undesired ones.
183
- let repo = tip. repo ;
184
184
let ref_name = ref_name. into ( ) ;
185
185
if ref_name
186
186
. as_ref ( )
@@ -205,13 +205,15 @@ impl Graph {
205
205
None
206
206
} ) ,
207
207
) ?;
208
- let ( workspaces, target_refs, desired_refs ) =
208
+ let ( workspaces, target_refs) =
209
209
obtain_workspace_infos ( repo, ref_name. as_ref ( ) . map ( |rn| rn. as_ref ( ) ) , meta) ?;
210
210
let mut seen = gix:: revwalk:: graph:: IdMap :: < SegmentIndex > :: default ( ) ;
211
211
let mut goals = Goals :: default ( ) ;
212
- let tip_limit_with_goal = limit. with_goal ( tip. detach ( ) , & mut goals) ;
213
212
// The tip transports itself.
214
- let tip_flags = CommitFlags :: NotInRemote | tip_limit_with_goal. goal ;
213
+ let tip_flags = CommitFlags :: NotInRemote
214
+ | goals
215
+ . flag_for ( tip. detach ( ) )
216
+ . expect ( "we more than one bitflags for this" ) ;
215
217
216
218
let target_symbolic_remote_names = {
217
219
let remote_names = repo. remote_names ( ) ;
@@ -233,15 +235,15 @@ impl Graph {
233
235
. any ( |( _, wsrn, _) | Some ( wsrn) == ref_name. as_ref ( ) )
234
236
{
235
237
let current = graph. insert_root ( branch_segment_from_name_and_meta (
236
- ref_name. clone ( ) ,
238
+ ref_name. clone ( ) . map ( |rn| ( rn , None ) ) ,
237
239
meta,
238
240
Some ( ( & refs_by_id, tip. detach ( ) ) ) ,
239
241
) ?) ;
240
242
if next. push_back_exhausted ( (
241
243
tip. detach ( ) ,
242
244
tip_flags,
243
245
Instruction :: CollectCommit { into : current } ,
244
- limit ,
246
+ max_limit ,
245
247
) ) {
246
248
return Ok ( graph. with_hard_limit ( ) ) ;
247
249
}
@@ -261,12 +263,16 @@ impl Graph {
261
263
. map ( |tid| ( trn. clone ( ) , tid) )
262
264
} ) ;
263
265
264
- let ( ws_flags , ws_limit) = if Some ( & ws_ref) == ref_name. as_ref ( ) {
265
- ( tip_flags, limit )
266
+ let ( ws_extra_flags , ws_limit) = if Some ( & ws_ref) == ref_name. as_ref ( ) {
267
+ ( tip_flags, max_limit )
266
268
} else {
267
- ( CommitFlags :: empty ( ) , tip_limit_with_goal)
269
+ (
270
+ CommitFlags :: empty ( ) ,
271
+ max_limit. with_indirect_goal ( tip. detach ( ) , & mut goals, ws_tip) ,
272
+ )
268
273
} ;
269
- let mut ws_segment = branch_segment_from_name_and_meta ( Some ( ws_ref) , meta, None ) ?;
274
+ let mut ws_segment =
275
+ branch_segment_from_name_and_meta ( Some ( ( ws_ref, None ) ) , meta, None ) ?;
270
276
// The limits for the target ref and the worktree ref are synced so they can always find each other,
271
277
// while being able to stop when the entrypoint is included.
272
278
ws_segment. metadata = Some ( SegmentMetadata :: Workspace ( workspace_info) ) ;
@@ -279,15 +285,15 @@ impl Graph {
279
285
// We only allow workspaces that are not remote, and that are not target refs.
280
286
// Theoretically they can still cross-reference each other, but then we'd simply ignore
281
287
// their status for now.
282
- CommitFlags :: NotInRemote | ws_flags ,
288
+ CommitFlags :: NotInRemote | ws_extra_flags ,
283
289
Instruction :: CollectCommit { into : ws_segment } ,
284
290
ws_limit,
285
291
) ) {
286
292
return Ok ( graph. with_hard_limit ( ) ) ;
287
293
}
288
294
if let Some ( ( target_ref, target_ref_id) ) = target {
289
295
let target_segment = graph. insert_root ( branch_segment_from_name_and_meta (
290
- Some ( target_ref) ,
296
+ Some ( ( target_ref, None ) ) ,
291
297
meta,
292
298
None ,
293
299
) ?) ;
@@ -297,17 +303,18 @@ impl Graph {
297
303
Instruction :: CollectCommit {
298
304
into : target_segment,
299
305
} ,
300
- tip_limit_with_goal,
306
+ // Once the goal was found, be done immediately,
307
+ // we are not interested in these.
308
+ max_limit
309
+ . with_indirect_goal ( tip. detach ( ) , & mut goals, target_ref_id)
310
+ . without_allowance ( ) ,
301
311
) ) {
302
312
return Ok ( graph. with_hard_limit ( ) ) ;
303
313
}
304
314
}
305
315
}
306
316
307
317
max_commits_recharge_location. sort ( ) ;
308
- // Set max-limit so that we compensate for the way this is counted.
309
- // let max_limit = limit.incremented();
310
- let max_limit = limit;
311
318
while let Some ( ( id, mut propagated_flags, instruction, mut limit) ) = next. pop_front ( ) {
312
319
if max_commits_recharge_location. binary_search ( & id) . is_ok ( ) {
313
320
limit. set_but_keep_goal ( max_limit) ;
@@ -329,8 +336,8 @@ impl Graph {
329
336
& mut graph,
330
337
& mut seen,
331
338
& mut next,
332
- id,
333
339
limit,
340
+ id,
334
341
propagated_flags,
335
342
src_sidx,
336
343
) ?;
@@ -358,8 +365,8 @@ impl Graph {
358
365
& mut graph,
359
366
& mut seen,
360
367
& mut next,
361
- id,
362
368
limit,
369
+ id,
363
370
propagated_flags,
364
371
parent_above,
365
372
) ?;
@@ -432,7 +439,7 @@ impl Graph {
432
439
}
433
440
}
434
441
435
- prune_integrated_tips ( & mut graph, & mut next, & desired_refs , max_limit ) ;
442
+ prune_integrated_tips ( & mut graph, & mut next) ;
436
443
}
437
444
438
445
graph. post_processed (
@@ -459,15 +466,6 @@ struct Queue {
459
466
max : Option < usize > ,
460
467
}
461
468
462
- #[ derive( Debug , Copy , Clone ) ]
463
- struct Limit {
464
- inner : Option < usize > ,
465
- /// The commit we want to see to be able to assume normal limits. Until then there is no limit.
466
- /// This is represented by bitflag, one for each goal.
467
- /// The flag is empty if no goal is set.
468
- goal : CommitFlags ,
469
- }
470
-
471
469
/// A set of commits to keep track of in bitflags.
472
470
#[ derive( Default ) ]
473
471
struct Goals ( Vec < gix:: ObjectId > ) ;
0 commit comments