| 333 | } |
| 334 | |
| 335 | static int prefix_ref_iterator_advance(struct ref_iterator *ref_iterator) |
| 336 | { |
| 337 | struct prefix_ref_iterator *iter = |
| 338 | (struct prefix_ref_iterator *)ref_iterator; |
| 339 | int ok; |
| 340 | |
| 341 | while ((ok = ref_iterator_advance(iter->iter0)) == ITER_OK) { |
| 342 | int cmp = compare_prefix(iter->iter0->ref.name, iter->prefix); |
| 343 | if (cmp < 0) |
| 344 | continue; |
| 345 | /* |
| 346 | * As the source iterator is ordered, we |
| 347 | * can stop the iteration as soon as we see a |
| 348 | * refname that comes after the prefix: |
| 349 | */ |
| 350 | if (cmp > 0) |
| 351 | return ITER_DONE; |
| 352 | |
| 353 | iter->base.ref = iter->iter0->ref; |
| 354 | |
| 355 | if (iter->trim) { |
| 356 | /* |
| 357 | * It is nonsense to trim off characters that |
| 358 | * you haven't already checked for via a |
| 359 | * prefix check, whether via this |
| 360 | * `prefix_ref_iterator` or upstream in |
| 361 | * `iter0`). So if there wouldn't be at least |
| 362 | * one character left in the refname after |
| 363 | * trimming, report it as a bug: |
| 364 | */ |
| 365 | if (strlen(iter->base.ref.name) <= iter->trim) |
| 366 | BUG("attempt to trim too many characters"); |
| 367 | iter->base.ref.name += iter->trim; |
| 368 | } |
| 369 | |
| 370 | return ITER_OK; |
| 371 | } |
| 372 | |
| 373 | return ok; |
| 374 | } |
| 375 | |
| 376 | static int prefix_ref_iterator_seek(struct ref_iterator *ref_iterator, |
| 377 | const char *refname, unsigned int flags) |
nothing calls this directly
no test coverage detected