* mark_reachable_objects() should have been run prior to this and all * reachable commits marked as "SEEN", except when quick_prune is non-zero, * in which case lines are excised from the shallow file if they refer to * commits that do not exist (any longer). */
| 483 | * commits that do not exist (any longer). |
| 484 | */ |
| 485 | void prune_shallow(unsigned options) |
| 486 | { |
| 487 | struct shallow_lock shallow_lock = SHALLOW_LOCK_INIT; |
| 488 | struct strbuf sb = STRBUF_INIT; |
| 489 | unsigned flags = SEEN_ONLY; |
| 490 | int fd; |
| 491 | |
| 492 | if (options & PRUNE_QUICK) |
| 493 | flags |= QUICK; |
| 494 | |
| 495 | if (options & PRUNE_SHOW_ONLY) { |
| 496 | flags |= VERBOSE; |
| 497 | write_shallow_commits_1(&sb, 0, NULL, flags); |
| 498 | strbuf_release(&sb); |
| 499 | return; |
| 500 | } |
| 501 | fd = hold_lock_file_for_update(&shallow_lock.lock, |
| 502 | git_path_shallow(the_repository), |
| 503 | LOCK_DIE_ON_ERROR); |
| 504 | check_shallow_file_for_update(the_repository); |
| 505 | if (write_shallow_commits_1(&sb, 0, NULL, flags)) { |
| 506 | if (write_in_full(fd, sb.buf, sb.len) < 0) |
| 507 | die_errno("failed to write to %s", |
| 508 | get_lock_file_path(&shallow_lock.lock)); |
| 509 | commit_shallow_file(the_repository, &shallow_lock); |
| 510 | } else { |
| 511 | unlink(git_path_shallow(the_repository)); |
| 512 | rollback_shallow_file(the_repository, &shallow_lock); |
| 513 | } |
| 514 | strbuf_release(&sb); |
| 515 | } |
| 516 | |
| 517 | struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW); |
| 518 |
no test coverage detected