* Write out bundle refs based on the tips already * parsed into revs.pending. As a side effect, may * manipulate revs.pending to include additional * necessary objects (like tags). * * Returns the number of refs written, or negative * on error. */
| 381 | * on error. |
| 382 | */ |
| 383 | static int write_bundle_refs(int bundle_fd, struct rev_info *revs) |
| 384 | { |
| 385 | int i; |
| 386 | int ref_count = 0; |
| 387 | struct strset objects = STRSET_INIT; |
| 388 | |
| 389 | for (i = 0; i < revs->pending.nr; i++) { |
| 390 | struct object_array_entry *e = revs->pending.objects + i; |
| 391 | struct object_id oid; |
| 392 | char *ref; |
| 393 | const char *display_ref; |
| 394 | int flag; |
| 395 | |
| 396 | if (e->item->flags & UNINTERESTING) |
| 397 | continue; |
| 398 | if (repo_dwim_ref(the_repository, e->name, strlen(e->name), |
| 399 | &oid, &ref, 0) != 1) |
| 400 | goto skip_write_ref; |
| 401 | if (refs_read_ref_full(get_main_ref_store(the_repository), e->name, RESOLVE_REF_READING, &oid, &flag)) |
| 402 | flag = 0; |
| 403 | display_ref = (flag & REF_ISSYMREF) ? e->name : ref; |
| 404 | |
| 405 | if (strset_contains(&objects, display_ref)) |
| 406 | goto skip_write_ref; |
| 407 | |
| 408 | if (e->item->type == OBJ_TAG && |
| 409 | !is_tag_in_date_range(e->item, revs)) { |
| 410 | e->item->flags |= UNINTERESTING; |
| 411 | goto skip_write_ref; |
| 412 | } |
| 413 | |
| 414 | /* |
| 415 | * Make sure the refs we wrote out is correct; --max-count and |
| 416 | * other limiting options could have prevented all the tips |
| 417 | * from getting output. |
| 418 | * |
| 419 | * Non commit objects such as tags and blobs do not have |
| 420 | * this issue as they are not affected by those extra |
| 421 | * constraints. |
| 422 | */ |
| 423 | if (!(e->item->flags & SHOWN) && e->item->type == OBJ_COMMIT) { |
| 424 | warning(_("ref '%s' is excluded by the rev-list options"), |
| 425 | e->name); |
| 426 | goto skip_write_ref; |
| 427 | } |
| 428 | |
| 429 | ref_count++; |
| 430 | strset_add(&objects, display_ref); |
| 431 | write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz); |
| 432 | write_or_die(bundle_fd, " ", 1); |
| 433 | write_or_die(bundle_fd, display_ref, strlen(display_ref)); |
| 434 | write_or_die(bundle_fd, "\n", 1); |
| 435 | skip_write_ref: |
| 436 | free(ref); |
| 437 | } |
| 438 | |
| 439 | strset_clear(&objects); |
| 440 |
no test coverage detected